31 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED 32 #define OPENVDB_METADATA_HAS_BEEN_INCLUDED 64 virtual Name typeName()
const = 0;
70 virtual void copy(
const Metadata& other) = 0;
73 virtual std::string str()
const = 0;
77 virtual bool asBool()
const = 0;
85 virtual Index32 size()
const = 0;
88 void read(std::istream&);
90 void write(std::ostream&)
const;
96 static bool isRegisteredType(
const Name& typeName);
99 static void clearRegistry();
102 static void registerType(
const Name& typeName,
Metadata::Ptr (*createMetadata)());
103 static void unregisterType(
const Name& typeName);
107 static Index32 readSize(std::istream&);
109 void writeSize(std::ostream&)
const;
112 virtual void readValue(std::istream&,
Index32 numBytes) = 0;
114 virtual void writeValue(std::ostream&)
const = 0;
118 #if OPENVDB_ABI_VERSION_NUMBER >= 5 130 void copy(
const Metadata&)
override;
131 std::string
str()
const override {
return (mBytes.empty() ?
"" :
"<binary data>"); }
132 bool asBool()
const override {
return !mBytes.empty(); }
139 void readValue(std::istream&,
Index32 numBytes)
override;
140 void writeValue(std::ostream&)
const override;
147 #else // if OPENVDB_ABI_VERSION_NUMBER < 5 154 Name typeName()
const override {
return "<unknown>"; }
157 std::string str()
const override {
return "<unknown>"; }
158 bool asBool()
const override {
return false; }
159 Index32 size()
const override {
return 0; }
162 void readValue(std::istream&,
Index32 numBytes)
override;
163 void writeValue(std::ostream&)
const override;
182 Name typeName()
const override;
184 void copy(
const Metadata& other)
override;
185 std::string str()
const override;
186 bool asBool()
const override;
190 void setValue(
const T&);
193 const T& value()
const;
202 static void registerType();
203 static void unregisterType();
204 static bool isRegisteredType();
207 void readValue(std::istream&,
Index32 numBytes)
override;
208 void writeValue(std::ostream&)
const override;
224 const Index32 n = this->size();
225 os.write(reinterpret_cast<const char*>(&n),
sizeof(
Index32));
233 is.read(reinterpret_cast<char*>(&n),
sizeof(
Index32));
241 const Index32 numBytes = this->readSize(is);
242 this->readValue(is, numBytes);
250 this->writeValue(os);
257 template <
typename T>
263 template <
typename T>
269 template <
typename T>
277 template <
typename T>
283 template <
typename T>
290 template <
typename T>
297 template <
typename T>
304 template <
typename T>
311 template <
typename T>
316 metadata->copy(*
this);
320 template <
typename T>
335 is.read(reinterpret_cast<char*>(&mValue), this->
size());
342 os.write(reinterpret_cast<const char*>(&mValue), this->
size());
345 template <
typename T>
349 std::ostringstream ostr;
361 template <
typename T>
369 template <
typename T>
377 template <
typename T>
384 template <
typename T>
396 return (mValue ?
"true" :
"false");
403 ostr << metadata.
str();
431 return static_cast<Index32>(mValue.size());
447 mValue.resize(size,
'\0');
448 is.read(&mValue[0], size);
455 os.write(reinterpret_cast<const char*>(&mValue[0]), this->
size());
461 #endif // OPENVDB_METADATA_HAS_BEEN_INCLUDED
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
std::string Name
Definition: Name.h:44
Definition: Exceptions.h:91
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
Definition: Exceptions.h:40
Library and file format version numbers.
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:488
std::ostream & operator<<(std::ostream &ostr, const Metadata &metadata)
Write a Metadata to an output stream.
Definition: Metadata.h:401
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:308
uint32_t Index32
Definition: Types.h:59