proj home

Files   Classes   Functions   Hierarchy  

message.cpp

Go to the documentation of this file.
00001 #include <cassert>
00002 #include <fstream>
00003 using namespace std;
00004 
00005 #include <message.h>
00006 
00007 message* message::global = 0;
00008 
00009 
00010 message& messageglobal()
00011 {
00012   assert(message::global);
00013   return (*message::global);
00014 }
00015 
00016 messagefile::messagefile()
00017 {
00018   assert(false);
00019 }
00020 
00021 ostream& messagefile::operator()()
00022 {
00023   assert(os!=0);
00024   return *os;
00025 }
00026 
00027 messagefile::~messagefile()
00028 {
00029   delete os;
00030   os = 0;
00031 }
00032 
00033 messagefile::messagefile
00034 (
00035   stringc & filename,
00036   boolc killprevfile,
00037   boolc binary
00038 )
00039 {
00040   std::_Ios_Openmode i = std::ios::out|std::ios::app;
00041 
00042   // Can not append and truncate a file at the same time.
00043   if (killprevfile)
00044     i = std::ios::out | std::ios::trunc;
00045 
00046   // UNTESTED
00047   if (binary)
00048     i = i | std::ios::binary; 
00049 
00050   os = new fstream(filename.c_str(),i);
00051 }
00052 
00053 // TODO look at tokenizer
00054 // TODO Looked at deriving from ostream - apparently a
00055 //   buffer is needed so perahps derive from stringstream
00056 //   See http://www.tacc.utexas.edu/services/userguides/pgi/pgC++_lib/stdlibug/cre_2288.htm
00057 
00058 
00059 void messagelist::pre()
00060 {
00061   ss.str("");
00062 }
00063 
00064 void messagelist::post()
00065 {
00066   vi.push_back(ss.str());
00067 }
00068 
00069 ostream& messagelist::operator()() 
00070 { 
00071   return ss; 
00072 }
00073 
00074 
00075 
00076 
00077 
00078 
00079 

Generated on Fri Mar 4 00:49:29 2011 for Chelton Evans Source by  doxygen 1.5.8