Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

octanetester/standalonetester_main.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 //---------------------------------------------------------------------------
00013 
00014 //---------------------------------------------------------------------------
00015 // application includes
00016 #include "octanetester.hpp"
00017 //---------------------------------------------------------------------------
00018 
00019 //---------------------------------------------------------------------------
00020 // system includes
00021 using namespace std;
00022 //---------------------------------------------------------------------------
00023 
00024 
00025 //---------------------------------------------------------------------------
00026 // default file which contains commands we will run on interactive startup
00027 #define OCTANE_DEFAULTINIFILENAME "octane.ini"
00028 //---------------------------------------------------------------------------
00029 
00030 
00031 
00032 //---------------------------------------------------------------------------
00033 int main(int argc,char **argv)
00034 {
00035         // create an octane tester class
00036         OctaneTester octanetester;
00037 
00038         // if the default commandfile exists, run it
00039         octanetester.ExecuteCommandsFromFile(OCTANE_DEFAULTINIFILENAME,true);
00040         
00041         // parse commandline or enter an interactive test loop
00042         if (argc==1)
00043                 {
00044                 // no commandline arguments, so run it in an interactive test loop
00045                 octanetester.TestLoop();
00046                 }
00047         else
00048                 {
00049                 // parse the commandline arguments, which are just ; separated commands as described in Compressor.ShowHelp();
00050                 string commandstr;
00051                 bool runcommandnow=false;
00052                 for (int curarg=1;curarg<argc;++curarg)
00053                         {
00054                         if (strcmp(argv[curarg],";")!=0)
00055                                 {
00056                                 // add word to current command
00057                                 if (commandstr.length()>0)
00058                                         commandstr+=" ";
00059                                 commandstr+=argv[curarg];
00060                                 // check and make sure there is no attached separator
00061                                 if (commandstr[commandstr.length()-1]==';')
00062                                         {
00063                                         // yes we found a separator ; attached to end of this command
00064                                         commandstr=commandstr.substr(0,commandstr.length()-1);
00065                                         runcommandnow=true;
00066                                         }
00067                                 // always run it when we hit the end
00068                                 if (curarg==argc-1)
00069                                         runcommandnow=true;
00070                                 }
00071                         if (runcommandnow==true || strcmp(argv[curarg],";")==0)
00072                                 {
00073                                 // execute this command
00074                                 if (commandstr.length()>0)
00075                                         {
00076                                         cout << ">"<<commandstr<<endl;
00077                                         if (commandstr=="interactive")
00078                                                 {
00079                                                 // this is a commandline-only option that can force the system to go into interactive mode
00080                                                 octanetester.TestLoop();
00081                                                 }
00082                                         else
00083                                                 {
00084                                                 octanetester.ParseCommand(commandstr.c_str());
00085                                                 }
00086                                         }
00087                                 commandstr="";
00088                                 runcommandnow=false;
00089                                 }
00090                         }
00091                 }
00092 
00093         // return success
00094         return 0;
00095 }
00096 //---------------------------------------------------------------------------
 
Generated on 20 May 2004 by doxygen 1.3.3