HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Name.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 #ifndef OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED
5 #define OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED
6 
7 #include <openvdb/Platform.h>
8 #include <openvdb/version.h>
9 #include <string>
10 #include <iostream>
11 #include <vector>
12 
13 namespace openvdb {
15 namespace OPENVDB_VERSION_NAME {
16 
17 typedef std::string Name;
18 
19 inline Name
20 readString(std::istream& is)
21 {
22  uint32_t size;
23  is.read(reinterpret_cast<char*>(&size), sizeof(uint32_t));
24  std::string buffer(size, ' ');
25  if (size>0) is.read(&buffer[0], size);
26  return buffer;
27 }
28 
29 
30 inline void
31 writeString(std::ostream& os, const Name& name)
32 {
33  uint32_t size = uint32_t(name.size());
34  os.write(reinterpret_cast<char*>(&size), sizeof(uint32_t));
35  os.write(&name[0], size);
36 }
37 
38 } // namespace OPENVDB_VERSION_NAME
39 } // namespace openvdb
40 
41 #endif // OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED
Definition: ImfName.h:54
GLsizeiptr size
Definition: glew.h:1681
GLuint const GLchar * name
Definition: glew.h:1814
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:166
void writeString(std::ostream &os, const Name &name)
Definition: Name.h:31
GLuint buffer
Definition: glew.h:1680
GLsizei const GLchar *const * string
Definition: glew.h:1844
Name readString(std::istream &is)
Definition: Name.h:20
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:112