Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

  1. //========= Copyright (c), Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef KVPACKER_H
  8. #define KVPACKER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "keyvalues.h"
  13. //-----------------------------------------------------------------------------
  14. // Purpose: Handles packing KeyValues binary packing and unpacking in a a
  15. // consistent way across all branches, including Steam. If you change
  16. // this packing format you need to do so in a backward compatible way
  17. // so that the Steam servers and all the various GCs can still talk to
  18. // each other.
  19. //-----------------------------------------------------------------------------
  20. class KVPacker
  21. {
  22. public:
  23. bool WriteAsBinary( KeyValues *pNode, CUtlBuffer &buffer );
  24. bool ReadAsBinary( KeyValues *pNode, CUtlBuffer &buffer );
  25. private:
  26. // These types are used for serialization of KeyValues nodes.
  27. // Do not renumber them or you will break serialization across
  28. // branches.
  29. enum EPackType
  30. {
  31. PACKTYPE_NONE = 0,
  32. PACKTYPE_STRING,
  33. PACKTYPE_INT,
  34. PACKTYPE_FLOAT,
  35. PACKTYPE_PTR,
  36. PACKTYPE_WSTRING,
  37. PACKTYPE_COLOR,
  38. PACKTYPE_UINT64,
  39. PACKTYPE_NULLMARKER, // used to mark the end of a block in the binary format
  40. };
  41. };
  42. #endif // KVPACKER_H