args.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2000-2001  The Exult Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef _ARGS_H_
00020 #define _ARGS_H_
00021 
00022 // Handy argument processor. I'm certain the implementation could be better
00023 // but it suffices quite well at the moment.
00024 
00025 #include "exult_types.h"
00026 
00027 #ifdef __DECCXX
00028 #  undef declare
00029 #endif
00030 
00031 #ifndef ALPHA_LINUX_CXX
00032 #  include <string>
00033 #endif
00034 #include <vector>
00035 
00036 class Args
00037 {
00038   struct Opts
00039   {
00040     std::string option;
00041     bool  *bval;
00042     std::string  *sval;
00043     int *ival;
00044     uint32 *uval;
00045 
00046     bool  dbval;
00047     std::string dsval;
00048     int dival;
00049     uint32 duval;
00050     enum { no_type=0,type_bool,type_string,type_int,type_unsigned } valuetype;
00051     Opts() :option(""),valuetype(no_type) {};
00052     ~Opts() {};
00053   };
00054   std::vector<Opts> options;
00055   public:
00056   Args() {};
00057   ~Args() {};
00058   void  declare(const char *s,bool *b,bool defval=true);
00059   void  declare(const char *s,std::string *b,const char *defval=0);
00060   void  declare(const char *s,int *b,int defval=0);
00061   void  declare(const char *s,uint32 *b,uint32 defval=0);
00062   void  process(int argc,char **argv);
00063 };
00064 
00065 #endif

Generated on Mon Jul 9 14:42:40 2007 for ExultEngine by  doxygen 1.5.1