31 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED 32 #define OPENVDB_METADATA_HAS_BEEN_INCLUDED 58 virtual Name typeName()
const = 0;
64 virtual void copy(
const Metadata& other) = 0;
67 virtual std::string str()
const = 0;
71 virtual bool asBool()
const = 0;
82 void read(std::istream&);
84 void write(std::ostream&)
const;
90 static bool isRegisteredType(
const Name& typeName);
93 static void clearRegistry();
96 static void registerType(
const Name& typeName,
Metadata::Ptr (*createMetadata)());
97 static void unregisterType(
const Name& typeName);
101 static Index32 readSize(std::istream&);
103 void writeSize(std::ostream&)
const;
106 virtual void readValue(std::istream&,
Index32 numBytes) = 0;
108 virtual void writeValue(std::ostream&)
const = 0;
126 virtual std::string
str()
const {
return "<unknown>"; }
127 virtual bool asBool()
const {
return false; }
131 virtual void readValue(std::istream&s,
Index32 numBytes);
132 virtual void writeValue(std::ostream&)
const;
149 virtual Name typeName()
const;
151 virtual void copy(
const Metadata& other);
152 virtual std::string str()
const;
153 virtual bool asBool()
const;
157 void setValue(
const T&);
160 const T& value()
const;
169 static void registerType();
170 static void unregisterType();
171 static bool isRegisteredType();
174 virtual void readValue(std::istream&,
Index32 numBytes);
175 virtual void writeValue(std::ostream&)
const;
192 os.write(reinterpret_cast<const char*>(&n),
sizeof(
Index32));
200 is.read(reinterpret_cast<char*>(&n),
sizeof(
Index32));
208 const Index32 numBytes = this->readSize(is);
209 this->readValue(is, numBytes);
217 this->writeValue(os);
224 template <
typename T>
230 template <
typename T>
236 template <
typename T>
244 template <
typename T>
250 template <
typename T>
257 template <
typename T>
264 template <
typename T>
271 template <
typename T>
278 template <
typename T>
283 metadata->copy(*
this);
287 template <
typename T>
302 is.read(reinterpret_cast<char*>(&mValue), this->
size());
309 os.write(reinterpret_cast<const char*>(&mValue), this->
size());
312 template <
typename T>
316 std::ostringstream ostr;
328 template <
typename T>
336 template <
typename T>
344 template <
typename T>
351 template <
typename T>
363 return (mValue ?
"true" :
"false");
370 ostr << metadata.
str();
398 return static_cast<Index32>(mValue.size());
414 mValue.resize(
size,
'\0');
415 is.read(&mValue[0],
size);
422 os.write(reinterpret_cast<const char*>(&mValue[0]), this->
size());
428 #endif // OPENVDB_METADATA_HAS_BEEN_INCLUDED
std::shared_ptr< T > SharedPtr
Definition: Types.h:130
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:101
uint32_t Index32
Definition: Types.h:55
std::string Name
Definition: Name.h:44
#define OPENVDB_VERSION_NAME
Definition: version.h:43
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:308
Definition: Exceptions.h:39
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:487
Definition: Exceptions.h:91
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
static constexpr size_t size
The size of a LeafBuffer when LeafBuffer::mOutOfCore is atomic.
Definition: LeafBuffer.h:85
std::ostream & operator<<(std::ostream &ostr, const Metadata &metadata)
Write a Metadata to an output stream.
Definition: Metadata.h:368