4 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED 5 #define OPENVDB_METADATA_HAS_BEEN_INCLUDED 37 virtual Name typeName()
const = 0;
43 virtual void copy(
const Metadata& other) = 0;
46 virtual std::string str()
const = 0;
50 virtual bool asBool()
const = 0;
58 virtual Index32 size()
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;
101 void copy(
const Metadata&)
override;
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;
132 Name typeName()
const override;
134 void copy(
const Metadata& other)
override;
135 std::string str()
const override;
136 bool asBool()
const override;
140 void setValue(
const T&);
143 const T&
value()
const;
152 static void registerType();
153 static void unregisterType();
154 static bool isRegisteredType();
157 void readValue(std::istream&,
Index32 numBytes)
override;
158 void writeValue(std::ostream&)
const override;
174 const Index32 n = this->size();
175 os.write(reinterpret_cast<const char*>(&n),
sizeof(
Index32));
183 is.read(reinterpret_cast<char*>(&n),
sizeof(
Index32));
191 const Index32 numBytes = this->readSize(is);
192 this->readValue(is, numBytes);
200 this->writeValue(os);
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>
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
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
static fileSize_t write(std::ostream &os, const GridHandle< BufferT > &handle, Codec codec)
static void read(std::istream &is, GridHandle< BufferT > &handle, Codec codec)
std::ostream & operator<<(std::ostream &ostr, const Metadata &metadata)
Write a Metadata to an output stream.
Definition: Metadata.h:351
std::string Name
Definition: Name.h:17
Definition: Exceptions.h:13
ValueT value
Definition: GridBuilder.h:1287
Definition: Exceptions.h:64
uint32_t Index32
Definition: Types.h:52
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:338
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:477
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202