proj home

Files   Classes   Functions   Hierarchy  

messagetest.cpp

Go to the documentation of this file.
00001 #include <string>
00002 using namespace std;
00003 
00004 #include <message.h>
00005 
00006 #include <messagetest.h>
00007 #include <print.h>
00008 
00009 string messagetest::doc[] = 
00010 {
00011   "",
00012   "Write messages to log error file.",
00013   "Overloading << with return type message, write messages to log error file.",
00014   "Overloading << with return type message, write messages to log list of strings."
00015 };
00016 
00017 
00018 void messagetest::test01()
00019 {
00020   cout << "Testing messagefile" << endl;
00021 
00022   stringc filename("error.txt");
00023   cout << "Appending to file " << filename << endl;
00024   cout << "On unix use $tail -f " << filename << " to follow changes" << endl;
00025 
00026 
00027   messagefile err(filename.c_str(),false);
00028   
00029   cout << "Enter text, " << endl;
00030   string quit("quit");
00031   cout << "To terminate enter " << quit << endl;
00032   char buff[256];
00033   for (;;)
00034   {
00035     cin.getline(buff,256);
00036 
00037     string in(buff);
00038 
00039     if (in==quit)
00040       return;
00041 
00042     err() << in << endl;
00043   }
00044 }
00045 
00046 //typedef endl<char, char_traits<char> > endl3;
00047 
00048 void messagetest::test02()
00049 {
00050   cout << "Testing messagefile with implicit calls." << endl;
00051 
00052   stringc filename("error.txt");
00053   messagefile err(filename);
00054   
00055   cout << "Enter text, " << endl;
00056   string quit("quit");
00057   cout << "To terminate enter " << quit << endl;
00058   char buff[256];
00059   for (;;)
00060   {
00061     cin.getline(buff,256);
00062     string in(buff);
00063 
00064     if (in==quit)
00065       return;
00066 
00067 /*    (message&)err << in; // << endl; */
00068 //    ((message&)err << in) << endl;
00069 //    (message&)err << endl;
00070     // http://www.velocityreviews.com/forums/t279958-stdendl-type-unknown.html
00071     (message&)err << in << endl<char, char_traits<char> >;
00072   }
00073 }
00074 
00075 void messagetest::test03()
00076 {
00077   messagelist err;  
00078 
00079   cout << "Adding some inapropriate message" << endl;
00080   (message&)err << "a" << "love" << "boat" << "at" << "work";
00081 
00082   cout << "Enter text, " << endl;
00083   string quit("quit");
00084   cout << "To terminate enter " << quit << endl;
00085   char buff[256];
00086   for (;;)
00087   {
00088     cin.getline(buff,256);
00089     string in(buff);
00090 
00091     if (in==quit)
00092       break;
00093 
00094     (message&)err << in; // << "a" << "cat" << "b"; //endl<char, char_traits<char> >;
00095   }
00096 
00097   cout << SHOW(err.vi.size()) << endl;
00098   for (uint i=0; i<err.vi.size(); ++i)
00099     cout << "*" << err.vi[i] << "*" << endl;
00100 
00101 }
00102 
00103 
00104 
00105 
00106 
00107 

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