Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
configfile.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/****************************************************************************\
20* C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *
21******************************************************************************
22Project Name: Carpenter (The RedAlert ladder creator)
23File Name : configfile.h
24Author : Neal Kettler
25Start Date : June 9, 1997
26Last Update : May 13, 1999
27\***************************************************************************/
28
29#ifndef CONFIGFILE_HEADER
30#define CONFIGFILE_HEADER
31
32#include "wstypes.h"
33#include "dictionary.h"
34#include "wstring.h"
35#include "critsec.h"
36#include "arraylist.h"
37
38class ConfigFile
39{
40 public:
43 bit8 readFile(FILE *config);
44 bit8 getString(IN Wstring &key,OUT Wstring &value, IN char *section=NULL) const;
45 bit8 getString(IN char *key,OUT Wstring &value, IN char *section=NULL) const;
46
47 bit8 getInt(IN Wstring &key,OUT sint32 &value, IN char *section=NULL) const;
48 bit8 getInt(IN char *key,OUT sint32 &value, IN char *section=NULL) const;
49
50 bit8 getInt(IN Wstring &key,OUT sint16 &value, IN char *section=NULL) const;
51 bit8 getInt(IN char *key,OUT sint16 &value, IN char *section=NULL) const;
52
53 // Enumerate through the config lines
54 bit8 enumerate(int &index, int &offset, Wstring &key, Wstring &value, IN char *section=NULL) const;
55
56 // Manual update of config file
57 bit8 setString(IN Wstring &key,IN Wstring &value, IN char *section=NULL);
58 bit8 setString(IN char *key,IN Wstring &value, IN char *section=NULL);
59 bit8 setInt(IN Wstring &key,IN sint32 &value, IN char *section=NULL);
60 bit8 setInt(IN char *key,IN sint32 &value, IN char *section=NULL);
61 bit8 removeEntry(IN Wstring &key, IN char *section=NULL);
62 bit8 removeEntry(IN char *key, IN char *section=NULL);
63 bit8 writeFile(FILE *config); // Does not preserve comments, etc
64
65 ArrayList<Wstring> sectionList; // stores the names of all sections
66
67 private:
68 Dictionary<Wstring,Wstring> Dictionary_; // stores the mappings from keys
69 // to value strings
70
71 // The lock is only needed around the immediate access to the dictionary, no writes
72 // are allowed so you don't need to worry about an outer lock around the enumerate
73 CritSec Critsec_; // lock around dictionary
74};
75
76#endif
#define NULL
Definition BaseType.h:92
void const char * value
char bit8
Definition wstypes.h:61
#define IN
Definition wstypes.h:57
#define OUT
Definition wstypes.h:58
signed short sint16
Definition bittype.h:50
signed long sint32
Definition bittype.h:51
bit8 getInt(IN Wstring &key, OUT sint32 &value, IN char *section=NULL) const
bit8 enumerate(int &index, int &offset, Wstring &key, Wstring &value, IN char *section=NULL) const
bit8 setInt(IN char *key, IN sint32 &value, IN char *section=NULL)
ArrayList< Wstring > sectionList
Definition configfile.h:65
bit8 getInt(IN Wstring &key, OUT sint16 &value, IN char *section=NULL) const
bit8 getInt(IN char *key, OUT sint32 &value, IN char *section=NULL) const
bit8 getInt(IN char *key, OUT sint16 &value, IN char *section=NULL) const
bit8 setString(IN Wstring &key, IN Wstring &value, IN char *section=NULL)
bit8 removeEntry(IN Wstring &key, IN char *section=NULL)
bit8 readFile(FILE *config)
bit8 getString(IN char *key, OUT Wstring &value, IN char *section=NULL) const
bit8 removeEntry(IN char *key, IN char *section=NULL)
bit8 setString(IN char *key, IN Wstring &value, IN char *section=NULL)
bit8 setInt(IN Wstring &key, IN sint32 &value, IN char *section=NULL)
bit8 writeFile(FILE *config)
bit8 getString(IN Wstring &key, OUT Wstring &value, IN char *section=NULL) const