4 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED
5 #define OPENVDB_METADATA_HAS_BEEN_INCLUDED
37 virtual Name typeName()
const = 0;
50 virtual bool asBool()
const = 0;
61 void read(std::istream&);
63 void write(std::ostream&)
const;
69 static bool isRegisteredType(
const Name& typeName);
72 static void clearRegistry();
75 static void registerType(
const Name& typeName,
Metadata::Ptr (*createMetadata)());
76 static void unregisterType(
const Name& typeName);
80 static Index32 readSize(std::istream&);
82 void writeSize(std::ostream&)
const;
85 virtual void readValue(std::istream&,
Index32 numBytes) = 0;
87 virtual void writeValue(std::ostream&)
const = 0;
102 std::string str()
const override {
return (mBytes.empty() ?
"" :
"<binary data>"); }
103 bool asBool()
const override {
return !mBytes.empty(); }
110 void readValue(std::istream&,
Index32 numBytes)
override;
111 void writeValue(std::ostream&)
const override;
136 bool asBool()
const override;
158 void writeValue(std::ostream&)
const override;
165 std::ostream&
operator<<(std::ostream& ostr,
const Metadata& metadata);
175 os.write(reinterpret_cast<const char*>(&n),
sizeof(
Index32));
183 is.read(reinterpret_cast<char*>(&n),
sizeof(
Index32));
207 template <
typename T>
213 template <
typename T>
219 template <
typename T>
227 template <
typename T>
233 template <
typename T>
240 template <
typename T>
247 template <
typename T>
254 template <
typename T>
261 template <
typename T>
266 metadata->copy(*
this);
270 template <
typename T>
275 if (t ==
nullptr)
OPENVDB_THROW(TypeError,
"Incompatible type during copy");
285 is.read(reinterpret_cast<char*>(&mValue), this->
size());
292 os.write(reinterpret_cast<const char*>(&mValue), this->
size());
295 template <
typename T>
299 std::ostringstream ostr;
311 template <
typename T>
319 template <
typename T>
327 template <
typename T>
334 template <
typename T>
346 return (mValue ?
"true" :
"false");
353 ostr << metadata.
str();
384 return static_cast<Index32>(mValue.size());
400 mValue.resize(size,
'\0');
401 is.read(&mValue[0], size);
408 os.write(reinterpret_cast<const char*>(&mValue[0]), this->
size());
414 #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 GLchar *const * string
#define OPENVDB_USE_VERSION_NAMESPACE
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)