summaryrefslogtreecommitdiff
path: root/replay/spew.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /replay/spew.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'replay/spew.h')
-rw-r--r--replay/spew.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/replay/spew.h b/replay/spew.h
new file mode 100644
index 0000000..a567ad3
--- /dev/null
+++ b/replay/spew.h
@@ -0,0 +1,82 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=======================================================================================//
+
+#ifndef SPEW_H
+#define SPEW_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+//----------------------------------------------------------------------------------------
+
+class ISpewer
+{
+public:
+ virtual ~ISpewer() {}
+
+ virtual void PrintBlockStart() const = 0;
+ virtual void PrintBlockEnd() const = 0;
+ virtual void PrintEmptyLine() const = 0;
+ virtual void PrintEventStartMsg( const char *pMsg ) const = 0;
+ virtual void PrintEventResult( bool bSuccess ) const = 0;
+ virtual void PrintEventError( const char *pError ) const = 0;
+ virtual void PrintTestHeader( const char *pHeader ) const = 0;
+ virtual void PrintMsg( const char *pMsg ) const = 0;
+ virtual void PrintValue( const char *pWhat, const char *pValue ) const = 0;
+};
+
+//----------------------------------------------------------------------------------------
+
+extern ISpewer *g_pDefaultSpewer;
+extern ISpewer *g_pBlockSpewer;
+extern ISpewer *g_pSimpleSpewer;
+extern ISpewer *g_pNullSpewer;
+
+//----------------------------------------------------------------------------------------
+
+class CSpewScope
+{
+public:
+ CSpewScope( ISpewer *pSpewer )
+ {
+ m_pOldSpewer = g_pDefaultSpewer;
+ g_pDefaultSpewer = pSpewer;
+ }
+
+ ~CSpewScope()
+ {
+ g_pDefaultSpewer = m_pOldSpewer;
+ }
+
+private:
+ ISpewer *m_pOldSpewer;
+};
+
+//----------------------------------------------------------------------------------------
+
+class CBaseSpewer : public ISpewer
+{
+public:
+ CBaseSpewer( ISpewer *pSpewer = g_pDefaultSpewer );
+
+ //
+ // ISpewer implementation for shorthand.
+ //
+ virtual void PrintBlockStart() const { m_pSpewer->PrintBlockStart(); }
+ virtual void PrintBlockEnd() const { m_pSpewer->PrintBlockEnd(); }
+ virtual void PrintEmptyLine() const { m_pSpewer->PrintEmptyLine(); }
+ virtual void PrintEventStartMsg( const char *pMsg ) const { m_pSpewer->PrintEventStartMsg( pMsg ); }
+ virtual void PrintEventResult( bool bSuccess ) const { m_pSpewer->PrintEventResult( bSuccess ); }
+ virtual void PrintEventError( const char *pError ) const { m_pSpewer->PrintEventError( pError ); }
+ virtual void PrintTestHeader( const char *pHeader ) const { m_pSpewer->PrintTestHeader( pHeader ); }
+ virtual void PrintMsg( const char *pMsg ) const { m_pSpewer->PrintMsg( pMsg ); }
+ virtual void PrintValue( const char *pWhat, const char *pValue ) const { m_pSpewer->PrintValue( pWhat, pValue ); }
+
+private:
+ ISpewer *m_pSpewer;
+};
+
+//----------------------------------------------------------------------------------------
+
+#endif // SPEW_H