22namespace WEMPersistenceHelper
42 static_assert(std::is_integral_v<DT> || std::is_floating_point_v<DT>,
"Only integral or floating point types are currently supported.");
46 if constexpr (std::is_same_v<DT, bool>)
48 const auto *
tmp = getCurrentAddress(1);
53 memcpy(&value, getCurrentAddress(
sizeof(DT)),
sizeof(DT));
56 MLSwapBytes(
reinterpret_cast<unsigned char *
>(&value),
sizeof(DT),
sizeof(DT));
63 template <
typename DT>
67 static_assert(!std::is_same_v<DT, bool> ||
sizeof(
bool) == 1,
"Sizeof bool is expected to be 1!");
68 _currentAddress +=
sizeof(DT);
88 bool _readValueWillBeWithinFileMapping(
size_t byteSize)
const;
91 const char*
const _initialAddress;
92 char* _currentAddress;
93 const char*
const _endAddress;
104 template <
typename DT>
107 outstream->write(
reinterpret_cast<const char*
>(&value),
byteSize);
115 std::ostream* outstream;
FileMapReadOutOfBoundsException()
Wraps a FileMap so we can handle errors and exceptions more easily.
MLuint64 getNumBytesRead() const
void advance(size_t byteSize)
void readVector4FromMap(Vector4 &value, size_t byteSize)
FileMapWrapper(MLuint64 filesize, char *startAddress)
void setSwapBytes(bool swapBytes)
const char * getCurrentAddress() const
void readStringWithSizeFromMap(std::string &value)
void readStringFromMap(std::string &value, size_t stringLength)
DT readValueFromMapAhead()
const char * getCurrentAddress(size_t byteSize)
const char * getInitialAddress() const
void readVector3FromMap(Vector3 &value, size_t byteSize)
void writePrimitiveIdToStream(WEMPrimitive *primitive)
void writeStringWithSizeToStream(const std::string &value)
OutStreamWrapper(std::ostream &outstream)
void writeValueToStream(const DT &value, size_t byteSize)
void writeStringToStream(const std::string &value)
This is the base class for the WEM elements nodes, edges, and faces.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
UINT64 MLuint64
Introduce platform independent 64 bit unsigned integer type.
ML_UTILS_EXPORT void MLSwapBytes(unsigned char *data, size_t numBytes, size_t dTypeSize)
Takes numBytes starting at position data and swaps byte 0 with byte numBytes - 1, byte 1 with numByte...
bool isWEMFormatIdentifier(const std::string &wemIdentifier)