diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index 1e83a93a..c66e9682 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -187,5 +187,106 @@ void Config::ParseConfigFile(const char* configfilename){ } } +void Config::SetStartUp(void (*_function)(void)) { + _start_function=_function; +} +void Config::StartUp(void) { + (*_start_function)(); +} + + + + +bool CommandLine::FindExist(char * name,bool remove) { + cmd_it it; + if (!(FindEntry(name,it,false))) return false; + if (remove) cmds.erase(it); + return true; +} + +bool CommandLine::FindHex(char * name,int & value,bool remove) { + cmd_it it,it_next; + if (!(FindEntry(name,it,true))) return false; + it_next=it;it_next++; + sscanf((*it_next).c_str(),"%X",&value); + if (remove) cmds.erase(it,it_next); + return true; +} + +bool CommandLine::FindInt(char * name,int & value,bool remove) { + cmd_it it,it_next; + if (!(FindEntry(name,it,true))) return false; + it_next=it;it_next++; + value=atoi((*it_next).c_str()); + if (remove) cmds.erase(it,it_next); + return true; +} + +bool CommandLine::FindString(char * name,std::string & value,bool remove) { + cmd_it it,it_next; + if (!(FindEntry(name,it,true))) return false; + it_next=it;it_next++; + value=*it_next; + if (remove) cmds.erase(it,it_next); + return true; +} + +bool CommandLine::FindFirst(std::string & value) { + if (cmds.empty()) return false; + value=*cmds.begin(); + return true; +} + +bool CommandLine::FindEntry(char * name,cmd_it & it,bool neednext) { + for (it=cmds.begin();it!=cmds.end();it++) { + if ((*it)==name) { + cmd_it itnext=it;itnext++; + if (neednext && (itnext==cmds.end())) return false; + return true; + } + } + return false; +} + +CommandLine::CommandLine(int argc,char * argv[]) { + if (argc>0) { + file_name=argv[0]; + } + int i=1; + while (i