ObjectStream.cpp 1.3 KB

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