4 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED
5 #define OPENVDB_METADATA_HAS_BEEN_INCLUDED
38 virtual Name typeName()
const = 0;
47 virtual std::string str()
const = 0;
51 virtual bool asBool()
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;
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;
136 std::string
str()
const override;
137 bool asBool()
const override;
159 void writeValue(std::ostream&)
const override;
166 std::ostream&
operator<<(std::ostream& ostr,
const Metadata& metadata);
176 os.write(reinterpret_cast<const char*>(&n),
sizeof(
Index32));
184 is.read(reinterpret_cast<char*>(&n),
sizeof(
Index32));
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>
276 if (t ==
nullptr)
OPENVDB_THROW(TypeError,
"Incompatible type during copy");
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
std::ostream & operator<<(std::ostream &ostr, const Metadata &metadata)
Write a Metadata to an output stream.
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
GLsizei const GLfloat * value
#define OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_ASSERT(X)
std::shared_ptr< T > SharedPtr
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Library and file format version numbers.
LeafData & operator=(const LeafData &)=delete
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
#define OPENVDB_THROW(exception, message)