Line | Branch | Exec | Source |
---|---|---|---|
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 { | ||
14 | OPENVDB_USE_VERSION_NAMESPACE | ||
15 | namespace OPENVDB_VERSION_NAME { | ||
16 | |||
17 | typedef std::string Name; | ||
18 | |||
19 | inline Name | ||
20 | 2369 | readString(std::istream& is) | |
21 | { | ||
22 | uint32_t size; | ||
23 | 2369 | is.read(reinterpret_cast<char*>(&size), sizeof(uint32_t)); | |
24 | 2369 | std::string buffer(size, ' '); | |
25 |
4/6✓ Branch 0 taken 2259 times.
✓ Branch 1 taken 110 times.
✓ Branch 3 taken 2259 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2259 times.
✗ Branch 7 not taken.
|
2369 | if (size>0) is.read(&buffer[0], size); |
26 | 2369 | return buffer; | |
27 | } | ||
28 | |||
29 | |||
30 | inline void | ||
31 | 2955 | writeString(std::ostream& os, const Name& name) | |
32 | { | ||
33 | 2955 | uint32_t size = uint32_t(name.size()); | |
34 | 2955 | os.write(reinterpret_cast<char*>(&size), sizeof(uint32_t)); | |
35 | 2955 | os.write(&name[0], size); | |
36 | 2955 | } | |
37 | |||
38 | } // namespace OPENVDB_VERSION_NAME | ||
39 | } // namespace openvdb | ||
40 | |||
41 | #endif // OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED | ||
42 |