From 13bba0357a6c41a7f2416fe110eec6a9d37f0ce1 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Wed, 18 Sep 2002 15:30:56 +0000 Subject: [PATCH] Added support for Command Line option detection. This includes a new class for that and some additions for the config class to handle it. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@292 --- include/setup.h | 57 ++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/include/setup.h b/include/setup.h index a729f897..95fa2f03 100644 --- a/include/setup.h +++ b/include/setup.h @@ -19,10 +19,31 @@ #ifndef _SETUP_H_ #define _SETUP_H_ +#pragma warning ( disable : 4786 ) + #include #include #include +class CommandLine { +public: + CommandLine(int argc,char * argv[]); + CommandLine(char * name,char * cmdline); + const char * GetFileName(){ return file_name.c_str();} + + bool FindExist(char * name,bool remove=false); + bool FindHex(char * name,int & value,bool remove=false); + bool FindInt(char * name,int & value,bool remove=false); + bool FindString(char * name,std::string & value,bool remove=false); + + bool FindFirst(std::string & value); +private: + typedef std::list::iterator cmd_it; + std::list cmds; + std::string file_name; + bool FindEntry(char * name,cmd_it & it,bool neednext=false); +}; + union Value{ int _hex; bool _bool; @@ -121,7 +142,9 @@ public: class Config{ public: - Config(){}; + Config(CommandLine * cmd){ cmdline=cmd;} + + CommandLine * cmdline; Section * AddSection(const char * _name,void (*_initfunction)(Section*)); Section_line * AddSection_line(const char * _name,void (*_initfunction)(Section*)); @@ -129,37 +152,17 @@ public: Section* GetSection(const char* _sectionname); + void SetStartUp(void (*_function)(void)); void Init(); - void ParseConfigFile(const char* configfilename); + void ShutDown(); + void StartUp(); + void ParseConfigFile(const char* configfilename); + std::list sectionlist; typedef std::list::iterator it; -}; - - - - - - -enum { S_STRING,S_HEX,S_INT,S_BOOL}; - -typedef char *(String_Handler)(char * input); -typedef char *(Hex_Handler)(Bitu * input); -typedef char *(Int_Handler)(Bits * input); -typedef char *(Bool_Handler)(bool input); - -class Setup { - - private: - int argc; - char * * argv; - + void (* _start_function)(void); }; - - -extern char dosbox_basedir[CROSS_LEN]; - - #endif