diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/public/stdstring.h | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/public/stdstring.h')
| -rw-r--r-- | mp/src/public/stdstring.h | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/mp/src/public/stdstring.h b/mp/src/public/stdstring.h index 7ec2dd14..c72320f7 100644 --- a/mp/src/public/stdstring.h +++ b/mp/src/public/stdstring.h @@ -1,88 +1,88 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#include "isaverestore.h"
-
-#ifndef STDSTRING_H
-#define STDSTRING_H
-
-#if defined( _WIN32 )
-#pragma once
-#endif
-
-#ifdef _WIN32
-#pragma warning(push)
-#include <yvals.h> // warnings get enabled in yvals.h
-#pragma warning(disable:4663)
-#pragma warning(disable:4530)
-#pragma warning(disable:4245)
-#pragma warning(disable:4018)
-#pragma warning(disable:4511)
-#endif
-
-#include "tier0/valve_minmax_off.h" // GCC 4.2.2 headers screw up our min/max defs.
-#include <string>
-#include "tier0/valve_minmax_on.h" // GCC 4.2.2 headers screw up our min/max defs.
-
-#ifdef _WIN32
-#pragma warning(pop)
-#endif
-
-class CStdStringSaveRestoreOps : public CDefSaveRestoreOps
-{
-public:
- enum
- {
- MAX_SAVE_LEN = 4096,
- };
-
- // save data type interface
- virtual void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave )
- {
- std::string *pString = (std::string *)fieldInfo.pField;
- Assert( pString->length() < MAX_SAVE_LEN - 1 );
- if ( pString->length() < MAX_SAVE_LEN - 1 )
- pSave->WriteString( pString->c_str() );
- else
- pSave->WriteString( "<<invalid>>" );
- }
-
- virtual void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore )
- {
- std::string *pString = (std::string *)fieldInfo.pField;
- char szString[MAX_SAVE_LEN];
- pRestore->ReadString( szString, sizeof(szString), 0 );
- szString[MAX_SAVE_LEN - 1] = 0;
- pString->assign( szString );
- }
-
- virtual void MakeEmpty( const SaveRestoreFieldInfo_t &fieldInfo )
- {
- std::string *pString = (std::string *)fieldInfo.pField;
- pString->erase();
- }
-
- virtual bool IsEmpty( const SaveRestoreFieldInfo_t &fieldInfo )
- {
- std::string *pString = (std::string *)fieldInfo.pField;
- return pString->empty();
- }
-};
-
-//-------------------------------------
-
-inline ISaveRestoreOps *GetStdStringDataOps()
-{
- static CStdStringSaveRestoreOps ops;
- return &ops;
-}
-
-//-------------------------------------
-
-#define DEFINE_STDSTRING(name) \
- { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, 1, FTYPEDESC_SAVE, NULL, GetStdStringDataOps(), NULL }
-
-#endif // STDSTRING_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "isaverestore.h" + +#ifndef STDSTRING_H +#define STDSTRING_H + +#if defined( _WIN32 ) +#pragma once +#endif + +#ifdef _WIN32 +#pragma warning(push) +#include <yvals.h> // warnings get enabled in yvals.h +#pragma warning(disable:4663) +#pragma warning(disable:4530) +#pragma warning(disable:4245) +#pragma warning(disable:4018) +#pragma warning(disable:4511) +#endif + +#include "tier0/valve_minmax_off.h" // GCC 4.2.2 headers screw up our min/max defs. +#include <string> +#include "tier0/valve_minmax_on.h" // GCC 4.2.2 headers screw up our min/max defs. + +#ifdef _WIN32 +#pragma warning(pop) +#endif + +class CStdStringSaveRestoreOps : public CDefSaveRestoreOps +{ +public: + enum + { + MAX_SAVE_LEN = 4096, + }; + + // save data type interface + virtual void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave ) + { + std::string *pString = (std::string *)fieldInfo.pField; + Assert( pString->length() < MAX_SAVE_LEN - 1 ); + if ( pString->length() < MAX_SAVE_LEN - 1 ) + pSave->WriteString( pString->c_str() ); + else + pSave->WriteString( "<<invalid>>" ); + } + + virtual void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore ) + { + std::string *pString = (std::string *)fieldInfo.pField; + char szString[MAX_SAVE_LEN]; + pRestore->ReadString( szString, sizeof(szString), 0 ); + szString[MAX_SAVE_LEN - 1] = 0; + pString->assign( szString ); + } + + virtual void MakeEmpty( const SaveRestoreFieldInfo_t &fieldInfo ) + { + std::string *pString = (std::string *)fieldInfo.pField; + pString->erase(); + } + + virtual bool IsEmpty( const SaveRestoreFieldInfo_t &fieldInfo ) + { + std::string *pString = (std::string *)fieldInfo.pField; + return pString->empty(); + } +}; + +//------------------------------------- + +inline ISaveRestoreOps *GetStdStringDataOps() +{ + static CStdStringSaveRestoreOps ops; + return &ops; +} + +//------------------------------------- + +#define DEFINE_STDSTRING(name) \ + { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, 1, FTYPEDESC_SAVE, NULL, GetStdStringDataOps(), NULL } + +#endif // STDSTRING_H |