Recovered from microbel

This commit is contained in:
rot
2025-03-05 08:35:31 +01:00
committed by h7x4
commit 88b92402a8
601 changed files with 82177 additions and 0 deletions

91
common/include/option.H Normal file
View File

@@ -0,0 +1,91 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _OPTION_H
#define _OPTION_H
#include "object.H"
#include "objectlist.H"
#include <stdio.h>
class COptionItem : public CObject {
enum {STR_VALUE,INT_VALUE,DOUBLE_VALUE} m_type;
static char *m_typeString[];
union {
char * strValue;
int intValue;
double doubleValue;
} m_value;
char m_abbreviation;
public:
COptionItem(char * name, char abbreviation, char * strValue);
COptionItem(char * name, char abbreviation, int intValue);
COptionItem(char * name, char abbreviation, double doubleValue);
void setAbbreviation(char abbreviation);
char getAbbreviation();
void setValue(char * strValue);
void setValue(int intValue);
void setValue(double doubleValue);
void updateValue(char * valueString);
char * getString();
int getInt();
double getDouble();
void dump();
};
class COption : private CObjectList {
public:
COption();
void setValue(char * name, char abbreviation, char * strValue);
void setValue(char * name, char abbreviation, int intValue);
void setValue(char * name, char abbreviation, double doubleValue);
char * getString(char * name);
int getInt(char * name);
double getDouble(char * name);
void parseArguments(int argc, char * argv[]);
void loadOption(char * fileName);
void loadOption(FILE * file);
private:
void updateName(const char * name, char * valueString);
void updateAbbreviation(char abbreviation, char * valueString);
public:
void dump();
private:
COptionItem * findOptionItem(const char * name);
COptionItem * findOptionItemByAbbreviation(char abbreviation);
};
#endif // _OPTION_H