Go to the documentation of this file.
4 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED
5 #define OPENVDB_METADATA_HAS_BEEN_INCLUDED
46 virtual std::string
str()
const = 0;
61 void read(std::istream&);
63 void write(std::ostream&)
const;
80 static Index32 readSize(std::istream&);
82 void writeSize(std::ostream&)
const;
91 #if OPENVDB_ABI_VERSION_NUMBER >= 5
104 std::string
str()
const override {
return (mBytes.empty() ?
"" :
"<binary data>"); }
105 bool asBool()
const override {
return !mBytes.empty(); }
120 #else // if OPENVDB_ABI_VERSION_NUMBER < 5
127 Name typeName()
const override {
return "<unknown>"; }
129 void copy(
const Metadata&)
override {
OPENVDB_THROW(TypeError,
"Destination has unknown type");}
130 std::string str()
const override {
return "<unknown>"; }
131 bool asBool()
const override {
return false; }
132 Index32 size()
const override {
return 0; }
135 void readValue(std::istream&,
Index32 numBytes)
override;
136 void writeValue(std::ostream&)
const override;
155 Name typeName()
const override;
157 void copy(
const Metadata& other)
override;
158 std::string str()
const override;
159 bool asBool()
const override;
163 void setValue(
const T&);
166 const T& value()
const;
175 static void registerType();
176 static void unregisterType();
177 static bool isRegisteredType();
180 void readValue(std::istream&,
Index32 numBytes)
override;
181 void writeValue(std::ostream&)
const override;
197 const Index32 n = this->size();
198 os.write(
reinterpret_cast<const char*
>(&n),
sizeof(
Index32));
206 is.read(
reinterpret_cast<char*
>(&n),
sizeof(
Index32));
214 const Index32 numBytes = this->readSize(is);
215 this->readValue(is, numBytes);
223 this->writeValue(os);
230 template <
typename T>
236 template <
typename T>
242 template <
typename T>
250 template <
typename T>
256 template <
typename T>
263 template <
typename T>
270 template <
typename T>
277 template <
typename T>
284 template <
typename T>
289 metadata->copy(*
this);
293 template <
typename T>
308 is.read(
reinterpret_cast<char*
>(&mValue), this->size());
315 os.write(
reinterpret_cast<const char*
>(&mValue), this->size());
318 template <
typename T>
322 std::ostringstream ostr;
334 template <
typename T>
342 template <
typename T>
350 template <
typename T>
357 template <
typename T>
369 return (mValue ?
"true" :
"false");
376 ostr << metadata.
str();
407 return static_cast<Index32>(mValue.size());
423 mValue.resize(
size,
'\0');
424 is.read(&mValue[0],
size);
431 os.write(
reinterpret_cast<const char*
>(&mValue[0]), this->
size());
437 #endif // OPENVDB_METADATA_HAS_BEEN_INCLUDED
Library and file format version numbers.
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Definition: Exceptions.h:64
std::ostream & operator<<(std::ostream &ostr, const Metadata &metadata)
Write a Metadata to an output stream.
Definition: Metadata.h:374
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
std::string Name
Definition: Name.h:17
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
uint32_t Index32
Definition: Types.h:29
Definition: Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:82
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:281