Commit 0aa88318 authored by Payton Oliveri (Cont ARL/CISD) poliveri's avatar Payton Oliveri (Cont ARL/CISD) poliveri Committed by Brian Panneton
Browse files

Added in XdmfError

parent cd1e7aef
......@@ -78,6 +78,7 @@ set(XdmfCoreSources
XdmfArrayType
XdmfCoreItemFactory
XdmfCoreReader
XdmfError
XdmfHDF5Controller
XdmfHDF5Writer
XdmfHeavyDataController
......
#include <XdmfError.hpp>
XdmfError::XdmfError()
{}
XdmfError::~XdmfError()
{}
/*******************************
*** Public Static Functions ***
*******************************/
XdmfError::Level
XdmfError::getLevel()
{
return XdmfError::mLevel;
}
void
XdmfError::setLevel(Level l)
{
XdmfError::mLevel = l;
}
void
XdmfError::message(Level level, std::string msg)
{
if(level<=XdmfError::getLevel())
XdmfError::WriteToStream(msg);
}
void
XdmfError::setBuffer(std::streambuf* buf)
{
XdmfError::mBuf = buf;
}
std::streambuf*
XdmfError::getInternalBuffer()
{
return XdmfError::mStream.rdbuf();
}
std::string
XdmfError::getInternalString()
{
return XdmfError::mStream.str();
}
/********************************
*** Private Static Functions ***
********************************/
void
XdmfError::WriteToStream(std::string msg)
{
if(msg[msg.length()-1] != XdmfError::newline[0])
msg+=XdmfError::newline;
XdmfError::mBuf->sputn(msg.c_str(),msg.length());
}
/******************************************
*** Initialize Static Member Variables ***
******************************************/
XdmfError::Level XdmfError::mLevel = FATAL;
std::streambuf* XdmfError::mBuf=std::cout.rdbuf();
std::ostringstream XdmfError::mStream;
std::string XdmfError::newline = "\n";
#ifndef XDMFERROR_HPP_
#define XDMFERROR_HPP_
#include <iostream>
#include <sstream>
#include <Xdmf.hpp>
class XDMF_EXPORT XdmfError
{
public:
XdmfError();
~XdmfError();
enum Level {FATAL, WARNING, DEBUG};
static void setLevel(Level l);
static Level getLevel();
static void message(Level l, std::string msg);
static void setBuffer(std::streambuf* buf);
static std::streambuf* getInternalBuffer();
static std::string getInternalString();
private:
static Level mLevel;
static std::streambuf* mBuf;
static std::ostringstream mStream;
static std::string newline;
static void WriteToStream(std::string msg);
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment