2
0

ObjectStream.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #include <Jolt/Jolt.h>
  4. #include <Jolt/ObjectStream/ObjectStream.h>
  5. JPH_NAMESPACE_BEGIN
  6. // Define macro to declare functions for a specific primitive type
  7. #define JPH_DECLARE_PRIMITIVE(name) \
  8. bool OSIsType(name *, int inArrayDepth, EOSDataType inDataType, const char *inClassName) \
  9. { \
  10. return inArrayDepth == 0 && inDataType == EOSDataType::T_##name; \
  11. } \
  12. bool OSReadData(IObjectStreamIn &ioStream, name &outPrimitive) \
  13. { \
  14. return ioStream.ReadPrimitiveData(outPrimitive); \
  15. } \
  16. void OSWriteDataType(IObjectStreamOut &ioStream, name *) \
  17. { \
  18. ioStream.WriteDataType(EOSDataType::T_##name); \
  19. } \
  20. void OSWriteData(IObjectStreamOut &ioStream, const name &inPrimitive) \
  21. { \
  22. ioStream.HintNextItem(); \
  23. ioStream.WritePrimitiveData(inPrimitive); \
  24. }
  25. // This file uses the JPH_DECLARE_PRIMITIVE macro to define all types
  26. #include <Jolt/ObjectStream/ObjectStreamTypes.h>
  27. JPH_NAMESPACE_END