4 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED 5 #define OPENVDB_METADATA_HAS_BEEN_INCLUDED 38 virtual Name typeName()
const = 0;
44 virtual void copy(
const Metadata& other) = 0;
47 virtual std::string str()
const = 0;
51 virtual bool asBool()
const = 0;
59 virtual Index32 size()
const = 0;
62 void read(std::istream&);
64 void write(std::ostream&)
const;
70 static bool isRegisteredType(
const Name& typeName);
73 static void clearRegistry();
76 static void registerType(
const Name& typeName,
Metadata::Ptr (*createMetadata)());
77 static void unregisterType(
const Name& typeName);
81 static Index32 readSize(std::istream&);
83 void writeSize(std::ostream&)
const;
86 virtual void readValue(std::istream&,
Index32 numBytes) = 0;
88 virtual void writeValue(std::ostream&)
const = 0;
102 void copy(
const Metadata&)
override;
103 std::string
str()
const override {
return (mBytes.empty() ?
"" :
"<binary data>"); }
104 bool asBool()
const override {
return !mBytes.empty(); }
111 void readValue(std::istream&,
Index32 numBytes)
override;
112 void writeValue(std::ostream&)
const override;
133 Name typeName()
const override;
135 void copy(
const Metadata& other)
override;
136 std::string str()
const override;
137 bool asBool()
const override;
141 void setValue(
const T&);
144 const T& value()
const;
153 static void registerType();
154 static void unregisterType();
155 static bool isRegisteredType();
158 void readValue(std::istream&,
Index32 numBytes)
override;
159 void writeValue(std::ostream&)
const override;
175 const Index32 n = this->size();
176 os.write(reinterpret_cast<const char*>(&n),
sizeof(
Index32));
184 is.read(reinterpret_cast<char*>(&n),
sizeof(
Index32));
192 const Index32 numBytes = this->readSize(is);
193 this->readValue(is, numBytes);
201 this->writeValue(os);
208 template <
typename T>
214 template <
typename T>
220 template <
typename T>
228 template <
typename T>
234 template <
typename T>
241 template <
typename T>
248 template <
typename T>
255 template <
typename T>
262 template <
typename T>
267 metadata->copy(*
this);
271 template <
typename T>
286 is.read(reinterpret_cast<char*>(&mValue), this->
size());
293 os.write(reinterpret_cast<const char*>(&mValue), this->
size());
296 template <
typename T>
300 std::ostringstream ostr;
312 template <
typename T>
320 template <
typename T>
328 template <
typename T>
335 template <
typename T>
347 return (mValue ?
"true" :
"false");
354 ostr << metadata.
str();
385 return static_cast<Index32>(mValue.size());
401 mValue.resize(size,
'\0');
402 is.read(&mValue[0], size);
409 os.write(reinterpret_cast<const char*>(&mValue[0]), this->
size());
415 #endif // OPENVDB_METADATA_HAS_BEEN_INCLUDED
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:474
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:337
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
Definition: Exceptions.h:13
uint32_t Index32
Definition: Types.h:52
std::ostream & operator<<(std::ostream &ostr, const Metadata &metadata)
Write a Metadata to an output stream.
Definition: Metadata.h:352
Definition: Exceptions.h:64
std::string Name
Definition: Name.h:19
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218