OpenVDB: StringMetadata.h Source File

OpenVDB 3.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

StringMetadata.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2015 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30
31 #ifndef OPENVDB_METADATA_STRINGMETADATA_HAS_BEEN_INCLUDED
32 #define OPENVDB_METADATA_STRINGMETADATA_HAS_BEEN_INCLUDED
33
34 #include <string>
35 #include <openvdb/metadata/Metadata.h>
36
37
38 namespace openvdb {
39 OPENVDB_USE_VERSION_NAMESPACE
40 namespace OPENVDB_VERSION_NAME {
41
42 typedef TypedMetadata<std::string> StringMetadata;
43
44
45 template <>
46 inline Index32
47 StringMetadata::size() const
48 {
49 return Index32(mValue.size());
50 }
51
52
53 template<>
54 inline void
55 StringMetadata::readValue(std::istream& is, Index32 size)
56 {
57 mValue.resize(size, '\0');
58 is.read(&mValue[0], size);
59 }
60
61 template<>
62 inline void
63 StringMetadata::writeValue(std::ostream &os) const
64 {
65 os.write(reinterpret_cast<const char*>(&mValue[0]), this->size());
66 }
67
68 } // namespace OPENVDB_VERSION_NAME
69 } // namespace openvdb
70
71 #endif // OPENVDB_METADATA_STRINGMETADATA_HAS_BEEN_INCLUDED
72
73 // Copyright (c) 2012-2015 DreamWorks Animation LLC
74 // All rights reserved. This software is distributed under the
75 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_1_0::StringMetadata
TypedMetadata< std::string > StringMetadata
Definition: StringMetadata.h:42
openvdb::v3_1_0::TypedMetadata
Templated metadata class to hold specific types.
Definition: metadata/Metadata.h:139
Metadata.h
openvdb::v3_1_0::TypedMetadata::readValue
virtual void readValue(std::istream &, Index32 numBytes)
Read the metadata from a stream.
Definition: metadata/Metadata.h:300
openvdb::v3_1_0::Index32
uint32_t Index32
Definition: Types.h:56
openvdb::v3_1_0::TypedMetadata::writeValue
virtual void writeValue(std::ostream &) const
Write the metadata to a stream.
Definition: metadata/Metadata.h:308
openvdb::v3_1_0::TypedMetadata::size
virtual Index32 size() const
Return the size of this metadata in bytes.
Definition: metadata/Metadata.h:155
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb
Definition: Exceptions.h:39
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71