cleanup MaterialChunkType.h

This commit is contained in:
Mathias Agopian
2019-03-05 17:04:54 -08:00
committed by Mathias Agopian
parent 0f6f53d501
commit 4abe017bc5
2 changed files with 14 additions and 28 deletions

View File

@@ -14,14 +14,12 @@
* limitations under the License.
*/
#ifndef TNT_FILAMAT_FILAFLAT_DEFS_H
#define TNT_FILAMAT_FILAFLAT_DEFS_H
#ifndef TNT_FILAMAT_MATERIAL_CHUNK_TYPES_H
#define TNT_FILAMAT_MATERIAL_CHUNK_TYPES_H
#include <stdint.h>
#include <functional>
#include <utils/compiler.h>
#include <utils/CString.h>
namespace filamat {
@@ -38,17 +36,6 @@ constexpr inline uint64_t charTo64bitNum(const char str[9]) noexcept {
| ( static_cast<uint64_t >(str[7]) & 0x00000000000000FFU);
}
// Unpack a 64 bit integer into a std::string
inline utils::CString typeToString(uint64_t v) {
uint8_t* raw = (uint8_t*) &v;
char str[9];
for (size_t i = 0; i < 8; i++) {
str[7 - i] = raw[i];
}
str[8] = '\0';
return utils::CString(str, 7);
}
enum UTILS_PUBLIC ChunkType : uint64_t {
Unknown = charTo64bitNum("UNKNOWN "),
MaterialUib = charTo64bitNum("MAT_UIB "),
@@ -94,16 +81,4 @@ enum UTILS_PUBLIC ChunkType : uint64_t {
} // namespace filamat
// Custom specialization of std::hash can be injected in namespace std.
// In some build environments, std::hash<filamat::ChunkType> doesn't default.
// to std::hash<uint64_t>.
namespace std {
template<>
struct hash<filamat::ChunkType> {
std::size_t operator()(filamat::ChunkType chunkType) const noexcept {
return std::hash<uint64_t>()(chunkType);
}
};
}
#endif
#endif // TNT_FILAMAT_MATERIAL_CHUNK_TYPES_H

View File

@@ -597,6 +597,17 @@ static bool printParametersInfo(ChunkContainer container) {
return true;
}
// Unpack a 64 bit integer into a std::string
inline utils::CString typeToString(uint64_t v) {
uint8_t* raw = (uint8_t*) &v;
char str[9];
for (size_t i = 0; i < 8; i++) {
str[7 - i] = raw[i];
}
str[8] = '\0';
return utils::CString(str, 7);
}
static void printChunks(const ChunkContainer& container) {
std::cout << "Chunks:" << std::endl;