4#ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED
5#define OPENVDB_METADATA_HAS_BEEN_INCLUDED
47 virtual std::string
str()
const = 0;
62 void read(std::istream&);
64 void write(std::ostream&)
const;
81 static Index32 readSize(std::istream&);
83 void writeSize(std::ostream&)
const;
103 std::string
str()
const override {
return (mBytes.empty() ?
"" :
"<binary data>"); }
104 bool asBool()
const override {
return !mBytes.empty(); }
133 Name typeName()
const override;
135 void copy(
const Metadata& other)
override;
136 std::string str()
const override;
137 bool asBool()
const override;
141 void setValue(
const T&);
144 const T& value()
const;
153 static void registerType();
154 static void unregisterType();
155 static bool isRegisteredType();
158 void readValue(std::istream&,
Index32 numBytes)
override;
159 void writeValue(std::ostream&)
const override;
173Metadata::writeSize(std::ostream& os)
const
175 const Index32 n = this->size();
176 os.write(
reinterpret_cast<const char*
>(&n),
sizeof(
Index32));
181Metadata::readSize(std::istream& is)
184 is.read(
reinterpret_cast<char*
>(&n),
sizeof(
Index32));
190Metadata::read(std::istream& is)
192 const Index32 numBytes = this->readSize(is);
193 this->readValue(is, numBytes);
198Metadata::write(std::ostream& os)
const
201 this->writeValue(os);
267 metadata->copy(*
this);
286 is.read(
reinterpret_cast<char*
>(&mValue), this->size());
293 os.write(
reinterpret_cast<const char*
>(&mValue), this->size());
300 std::ostringstream ostr;
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());
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
OPENVDB_API std::ostream & operator<<(std::ostream &os, half h)
Output h to os, formatted as a float.
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Definition Exceptions.h:64
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition Math.h:337
std::string Name
Definition Name.h:19
std::ostream & operator<<(std::ostream &ostr, const Metadata &metadata)
Write a Metadata to an output stream.
Definition Metadata.h:352
uint32_t Index32
Definition Types.h:52
std::shared_ptr< T > SharedPtr
Definition Types.h:114
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218