OpenVDB 5.1.0

Name.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2018 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_UTIL_NAME_HAS_BEEN_INCLUDED
32 #define OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED
33
34 #include <openvdb/Platform.h>
35 #include <openvdb/version.h>
36 #include <string>
37 #include <iostream>
38 #include <vector>
39
40 namespace openvdb {
41 OPENVDB_USE_VERSION_NAMESPACE
42 namespace OPENVDB_VERSION_NAME {
43
44 typedef std::string Name;
45
46 inline Name
47 readString(std::istream& is)
48 {
49 uint32_t size;
50 is.read(reinterpret_cast<char*>(&size), sizeof(uint32_t));
51 std::string buffer(size, ' ');
52 if (size>0) is.read(&buffer[0], size);
53 return buffer;
54 }
55
56
57 inline void
58 writeString(std::ostream& os, const Name& name)
59 {
60 uint32_t size = uint32_t(name.size());
61 os.write(reinterpret_cast<char*>(&size), sizeof(uint32_t));
62 os.write(&name[0], size);
63 }
64
65 } // namespace OPENVDB_VERSION_NAME
66 } // namespace openvdb
67
68 #endif // OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED
69
70 // Copyright (c) 2012-2018 DreamWorks Animation LLC
71 // All rights reserved. This software is distributed under the
72 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v5_1::Name
std::string Name
Definition: Name.h:44
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb::v5_1::writeString
void writeString(std::ostream &os, const Name &name)
Definition: Name.h:58
openvdb
Definition: Exceptions.h:40
openvdb::v5_1::readString
Name readString(std::istream &is)
Definition: Name.h:47
version.h
Library and file format version numbers.
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
Platform.h