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/html/htmlprotobuf.cpp | |
| 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/html/htmlprotobuf.cpp')
| -rw-r--r-- | mp/src/public/html/htmlprotobuf.cpp | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/mp/src/public/html/htmlprotobuf.cpp b/mp/src/public/html/htmlprotobuf.cpp index 59168c99..19822273 100644 --- a/mp/src/public/html/htmlprotobuf.cpp +++ b/mp/src/public/html/htmlprotobuf.cpp @@ -1,70 +1,70 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//=============================================================================//
-
-
-#include "html/htmlprotobuf.h"
-#include "tier0/vprof.h"
-#include "tier0/valve_minmax_off.h"
-
-
-#ifdef _WIN64
-// disable 64-bit warnings for the google headers
-#pragma warning(push)
-#pragma warning(disable:4244) // warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data
-#pragma warning(disable:4267) // warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
-#endif
-
-#include "tier0/memdbgoff.h"
-#include "protobuf-2.3.0/src/google/protobuf/message_lite.h"
-#include "tier0/memdbgon.h"
-
-#ifdef _WIN64
-#pragma warning(pop)
-#endif
-
-//-----------------------------------------------------------------------------
-// Purpose: serialize a protobuf into a utlbuffer
-//-----------------------------------------------------------------------------
-void CHTMLBaseProtoBufMsg::SerializeCrossProc( CUtlBuffer *pBuffer ) const
-{
- VPROF_BUDGET( "CUIProtoBufMsg::SerializeCrossProc", VPROF_BUDGETGROUP_OTHER_VGUI );
- uint32 unSize = ((google::protobuf::MessageLite *)m_pMsg)->ByteSize();
-
- // Ensure enough for type, size, and serialized data
- pBuffer->EnsureCapacity( pBuffer->TellPut() + sizeof(uint32) * 3 + unSize ); // bugbug cboyd - drop to * 2 whenpassthrough is removed below
-
- pBuffer->PutUnsignedInt( unSize );
-
- if ( unSize == 0 )
- return;
-
- uint8 *pBody = (uint8*)pBuffer->Base()+pBuffer->TellPut();
- ((google::protobuf::MessageLite *)m_pMsg)->SerializeWithCachedSizesToArray( pBody );
- pBuffer->SeekPut( CUtlBuffer::SEEK_CURRENT, unSize );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: grab a previously serialized protobuf
-//-----------------------------------------------------------------------------
-bool CHTMLBaseProtoBufMsg::BDeserializeCrossProc( CUtlBuffer *pBuffer )
-{
- VPROF_BUDGET( "CUIProtoBufMsg::BDeserialize", VPROF_BUDGETGROUP_OTHER_VGUI );
- if ( pBuffer->GetBytesRemaining() < (int)sizeof(uint32) )
- return false;
- uint32 unSize = pBuffer->GetUnsignedInt();
-
- if ( unSize == 0 )
- return true;
-
- if ( pBuffer->GetBytesRemaining() < (int)unSize )
- return false;
-
- bool bSucccess = ((google::protobuf::MessageLite *)m_pMsg)->ParseFromArray( (uint8*)pBuffer->Base()+pBuffer->TellGet(), unSize );
- pBuffer->SeekGet( CUtlBuffer::SEEK_CURRENT, unSize );
-
- return bSucccess;
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +//=============================================================================// + + +#include "html/htmlprotobuf.h" +#include "tier0/vprof.h" +#include "tier0/valve_minmax_off.h" + + +#ifdef _WIN64 +// disable 64-bit warnings for the google headers +#pragma warning(push) +#pragma warning(disable:4244) // warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data +#pragma warning(disable:4267) // warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data +#endif + +#include "tier0/memdbgoff.h" +#include "protobuf-2.3.0/src/google/protobuf/message_lite.h" +#include "tier0/memdbgon.h" + +#ifdef _WIN64 +#pragma warning(pop) +#endif + +//----------------------------------------------------------------------------- +// Purpose: serialize a protobuf into a utlbuffer +//----------------------------------------------------------------------------- +void CHTMLBaseProtoBufMsg::SerializeCrossProc( CUtlBuffer *pBuffer ) const +{ + VPROF_BUDGET( "CUIProtoBufMsg::SerializeCrossProc", VPROF_BUDGETGROUP_OTHER_VGUI ); + uint32 unSize = ((google::protobuf::MessageLite *)m_pMsg)->ByteSize(); + + // Ensure enough for type, size, and serialized data + pBuffer->EnsureCapacity( pBuffer->TellPut() + sizeof(uint32) * 3 + unSize ); // bugbug cboyd - drop to * 2 whenpassthrough is removed below + + pBuffer->PutUnsignedInt( unSize ); + + if ( unSize == 0 ) + return; + + uint8 *pBody = (uint8*)pBuffer->Base()+pBuffer->TellPut(); + ((google::protobuf::MessageLite *)m_pMsg)->SerializeWithCachedSizesToArray( pBody ); + pBuffer->SeekPut( CUtlBuffer::SEEK_CURRENT, unSize ); +} + + +//----------------------------------------------------------------------------- +// Purpose: grab a previously serialized protobuf +//----------------------------------------------------------------------------- +bool CHTMLBaseProtoBufMsg::BDeserializeCrossProc( CUtlBuffer *pBuffer ) +{ + VPROF_BUDGET( "CUIProtoBufMsg::BDeserialize", VPROF_BUDGETGROUP_OTHER_VGUI ); + if ( pBuffer->GetBytesRemaining() < (int)sizeof(uint32) ) + return false; + uint32 unSize = pBuffer->GetUnsignedInt(); + + if ( unSize == 0 ) + return true; + + if ( pBuffer->GetBytesRemaining() < (int)unSize ) + return false; + + bool bSucccess = ((google::protobuf::MessageLite *)m_pMsg)->ParseFromArray( (uint8*)pBuffer->Base()+pBuffer->TellGet(), unSize ); + pBuffer->SeekGet( CUtlBuffer::SEEK_CURRENT, unSize ); + + return bSucccess; +} + |