From 765726f755bf6758534720dff30d1a822245cd5d Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Sun, 29 Sep 2002 13:59:46 +0000 Subject: [PATCH] Addes some new functions to commandline class. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@310 --- src/misc/setup.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index c66e9682..01fa0d1f 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -233,9 +233,12 @@ bool CommandLine::FindString(char * name,std::string & value,bool remove) { return true; } -bool CommandLine::FindFirst(std::string & value) { - if (cmds.empty()) return false; - value=*cmds.begin(); +bool CommandLine::FindCommand(int which,std::string & value) { + if (which<1) return false; + if (which>cmds.size()) return false; + cmd_it it=cmds.begin(); + for (;which>1;which--) it++; + value=(*it); return true; } @@ -250,6 +253,24 @@ bool CommandLine::FindEntry(char * name,cmd_it & it,bool neednext) { return false; } +bool CommandLine::FindStringBegin(char * begin,std::string & value, bool remove) { + cmd_it it; + for (it=cmds.begin();it!=cmds.end();it++) { + if (strncmp(begin,(*it).c_str(),strlen(begin))==0) { + value=((*it).c_str()+strlen(begin)); + return true; + } + } + return false; + + + +} + +int CommandLine::GetCount(void) { + return cmds.size(); +} + CommandLine::CommandLine(int argc,char * argv[]) { if (argc>0) { file_name=argv[0];