proj home

Files   Classes   Functions   Hierarchy  

mkerrorsconfig.cpp

Go to the documentation of this file.
00001 #include <fstream>
00002 using namespace std;
00003 
00004 #include <mkerrorsconfig.h>
00005 #include <stringserialization.h>
00006 #include <tokenizerlocal.h>
00007 
00008 string mkerrorsconfig::globalconfigfile="../mkerrorsconfig.txt";
00009 
00010 mkerrorsconfig::mkerrorsconfig()
00011 {
00012   globalconfigfile_exists=false;
00013 
00014   string lib;
00015   vi.push_back( mkerrorscompiletag("debug","make",lib) );
00016   vi.push_back( mkerrorscompiletag("gdb","make CC=\"g++ -g -Wall\"",lib) );
00017   vi.push_back( mkerrorscompiletag("gprof","make CC=\"g++ -pg -g -Wall\"",lib) );
00018   vi.push_back( mkerrorscompiletag("release","make CC=\"g++ -DNDEBUG -O3 -Wall\"",lib) );
00019   vi.push_back( mkerrorscompiletag("clean","make clean","") );
00020 }
00021 
00022 boolc mkerrorsconfig::read()
00023 {
00024 // Look for global config file
00025 //   if present load it.
00026 
00027 // Overwrite default settings.
00028 // e.g. if same tag then replace 
00029 
00030   globalconfigfile_exists=true;
00031   string str;
00032   globalconfigfile_exists &= filestring::serialize(str,globalconfigfile);
00033 
00034 //cout << "read" << endl;
00035 //cout << SHOW3(str) << endl;
00036 
00037   if (globalconfigfile_exists==false)
00038     return false;
00039 
00040   tokenizer tk(str);
00041   tokenizerlocal tl1(tk);
00042   tl1.scope("vi");
00043 //cout << SHOW3(tl1.debug01()) << endl;
00044 
00045 //  for (tl1.reset(); !tl1; ++tl1)
00046 //  {
00047 //     cout << SHOW3(tl1()) << endl;
00048 //  }
00049 
00050   string id;
00051   string command;
00052   string libraries;
00053 
00054   // Have the compiler tags inserted in order that client would expect.
00055   // i.e. first to last are inserted in front as first to last.
00056 
00057   deque<mkerrorscompiletag> vi2;
00058 
00059   // Make robust and have the tags read order independent
00060   
00061   tokenizerlocalvar tl2(tl1,"compiletag");
00062 //cout << SHOW3(tl2.debug01()) << endl;
00063 //  tl2.reset();
00064 //  for ( ; tl2.scope("compiletag"); ++tl2)
00065   for ( ; !tl2; ++tl2)
00066   {
00067 //cout << SHOW3(tl2.debug01()) << endl;
00068 
00069     id.clear();
00070     command.clear();
00071     libraries.clear();
00072 
00073     // Have a valid data structure
00074     // e.g. id and command required (at present, could do merging...)
00075 
00076     tokenizerlocal tl3(tl2);
00077     if (tl3.read(id,"id")==false)
00078       continue;
00079     tl3.reset();
00080     if (tl3.read(command,"command")==false)
00081       continue;
00082     tl3.reset();
00083     tl3.read(libraries,"libraries");
00084 
00085     vi2.push_front( mkerrorscompiletag(id,command,libraries) );
00086   }
00087 
00088   if (vi2.empty()==false)
00089   {
00090     uint imax=vi2.size();
00091     for (uint i=0; i<imax; ++i)
00092       vi.push_front( vi2[i] );
00093   }
00094 
00095   return true;
00096 }
00097 
00098 boolc mkerrorsconfig::find
00099 ( 
00100   mkerrorscompiletag& ct, 
00101   stringc & id
00102 ) const
00103 {
00104   // Reset.
00105   ct=mkerrorscompiletag();
00106 
00107   // Find first match and return.
00108   uint imax=vi.size();
00109   for (uint i=0; i<imax; ++i)
00110   {
00111     if (vi[i].id==id)
00112     {
00113       ct=vi[i]; 
00114       return true;
00115     }
00116   }
00117 
00118   return false;
00119 }
00120 

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