1
0
Fork 0

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
This commit is contained in:
Sjoerd van der Berg 2002-09-18 15:30:56 +00:00
parent 4b4a8dfad3
commit 13bba0357a

View file

@ -19,10 +19,31 @@
#ifndef _SETUP_H_
#define _SETUP_H_
#pragma warning ( disable : 4786 )
#include <cross.h>
#include <string>
#include <list>
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<std::string>::iterator cmd_it;
std::list<std::string> 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<Section*> sectionlist;
typedef std::list<Section*>::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