debuglog.cpp

来自「把html转成txt 把html转成txt」· C++ 代码 · 共 67 行

CPP
67
字号
//---------------------------------------------------------------------------


#pragma hdrstop

#include "DebugLog.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

namespace DoxEngine
{

   // basic_ostream::basic_ostream(NULL) generates a NULL stream
   DebugLog::DebugLog():nullstream(NULL)
   {

   }

   // basic_ostream::basic_ostream(NULL) generates a NULL stream   
   DebugLog::DebugLog(const DebugLog &rhs):nullstream(NULL)
   {
     map = rhs.map;
   }

   DebugLog::~DebugLog()
   {

   }

   DebugLog& DebugLog::operator=(const DebugLog &rhs)
   {
     if (this == &rhs)
       return *this;
       
     map = rhs.map;
     return *this;
   }

  // Note: DebugLog does not take ownership or copy of stream
  void DebugLog::SetStream(const LogLevel level, std::ostream &stream)
  {
    map.insert(LevelToStreamMap::value_type(level, &stream));
  }

  std::ostream& DebugLog::GetStream(const LogLevel level)
  {
    LevelToStreamMap::iterator streamIterator = map.find(level);
    if (streamIterator != map.end())
      return *(streamIterator->second);
    else
      return nullstream;

  }

  std::ostream& DebugLog::operator[](const LogLevel level)
  {
    return GetStream(level);
  }





}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?