Write a Variable Index (VX) data type to the given stream
| 15 | |
| 16 | // Write a Variable Index (VX) data type to the given stream |
| 17 | void writeVariableIndex(std::ostream& stream, std::size_t index) |
| 18 | { |
| 19 | // LWO2 defines the variable index VX data type which is |
| 20 | // 32 bit as soon as the index value is greater than 0xFF00, otherwise 16 bit |
| 21 | if (index < 0xFF00) |
| 22 | { |
| 23 | writeBigEndian<uint16_t>(stream, static_cast<uint16_t>(index)); |
| 24 | } |
| 25 | else |
| 26 | { |
| 27 | // According to the specs, for values greater than 0xFF00: |
| 28 | // "the index is written as an unsigned four byte integer with bits 24-31 set" |
| 29 | writeBigEndian<uint32_t>(stream, static_cast<uint32_t>(index) | 0xFF000000); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | // Writes an S0 datatype to the given stream |
| 34 | void writeString(std::ostream& stream, const std::string& str) |