Team Fortress 2 Source Code as on 22/4/2020
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.

53 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef SAVERESTORE_UTLSYMBOL_H
  7. #define SAVERESTORE_UTLSYMBOL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "utlsymbol.h"
  12. class CUtlSymbolDataOps : public CDefSaveRestoreOps
  13. {
  14. public:
  15. CUtlSymbolDataOps( CUtlSymbolTable &masterTable ) : m_symbolTable(masterTable) {}
  16. virtual void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave )
  17. {
  18. CUtlSymbol *sym = ((CUtlSymbol *)fieldInfo.pField);
  19. pSave->WriteString( m_symbolTable.String( *sym ) );
  20. }
  21. virtual void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore )
  22. {
  23. CUtlSymbol *sym = ((CUtlSymbol *)fieldInfo.pField);
  24. char tmp[1024];
  25. pRestore->ReadString( tmp, sizeof(tmp), 0 );
  26. *sym = m_symbolTable.AddString( tmp );
  27. }
  28. virtual void MakeEmpty( const SaveRestoreFieldInfo_t &fieldInfo )
  29. {
  30. CUtlSymbol *sym = ((CUtlSymbol *)fieldInfo.pField);
  31. *sym = UTL_INVAL_SYMBOL;
  32. }
  33. virtual bool IsEmpty( const SaveRestoreFieldInfo_t &fieldInfo )
  34. {
  35. CUtlSymbol *sym = ((CUtlSymbol *)fieldInfo.pField);
  36. return (*sym).IsValid() ? false : true;
  37. }
  38. private:
  39. CUtlSymbolTable &m_symbolTable;
  40. };
  41. #endif // SAVERESTORE_UTLSYMBOL_H