1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Props.hxx,v 1.15 2007/02/06 23:34:33 stephena Exp $
//============================================================================
#ifndef PROPERTIES_HXX
#define PROPERTIES_HXX
#include "m6502/src/bspf/src/bspf.hxx"
enum PropertyType {
Cartridge_MD5,
Cartridge_Manufacturer,
Cartridge_ModelNo,
Cartridge_Name,
Cartridge_Note,
Cartridge_Rarity,
Cartridge_Sound,
Cartridge_Type,
Console_LeftDifficulty,
Console_RightDifficulty,
Console_TelevisionType,
Console_SwapPorts,
Controller_Left,
Controller_Right,
Controller_SwapPaddles,
Display_Format,
Display_YStart,
Display_Height,
Display_Phosphor,
Display_PPBlend,
Emulation_HmoveBlanks,
LastPropType
};
/**
This class represents objects which maintain a collection of
properties. A property is a key and its corresponding value.
A properties object can contain a reference to another properties
object as its "defaults"; this second properties object is searched
if the property key is not found in the original property list.
@author Bradford W. Mott
@version $Id: Props.hxx,v 1.15 2007/02/06 23:34:33 stephena Exp $
*/
class Properties
{
friend class PropertiesSet;
public:
/**
Creates an empty properties object with the specified defaults. The
new properties object does not claim ownership of the defaults.
*/
Properties();
/**
Creates a properties list by copying another one
@param properties The properties to copy
*/
Properties(const Properties& properties);
/**
Destructor
*/
virtual ~Properties();
public:
/**
Get the value assigned to the specified key. If the key does
not exist then the empty string is returned.
@param key The key of the property to lookup
@return The value of the property
*/
const std::string& get(PropertyType key) const;
/**
Set the value associated with key to the given value.
@param key The key of the property to set
@param value The value to assign to the property
*/
void set(PropertyType key, const std::string& value);
/**
Load properties from the specified input stream
@param in The input stream to use
*/
void load(std::istream& in);
/**
Save properties to the specified output stream
@param out The output stream to use
*/
void save(std::ostream& out) const;
/**
Print the attributes of this properties object
*/
void print() const;
/**
Resets all properties to their defaults
*/
void setDefaults();
public:
/**
Overloaded assignment operator
@param properties The properties object to set myself equal to
@return Myself after assignment has taken place
*/
Properties& operator = (const Properties& properties);
private:
/**
Helper function to perform a deep copy of the specified
properties. Assumes that old properties have already been
freed.
@param properties The properties object to copy myself from
*/
void copy(const Properties& properties);
/**
Read the next quoted string from the specified input stream
and returns it.
@param in The input stream to use
@return The string inside the quotes
*/
static std::string readQuotedString(std::istream& in);
/**
Write the specified string to the given output stream as a
quoted string.
@param out The output stream to use
@param s The string to output
*/
static void writeQuotedString(std::ostream& out, const std::string& s);
/**
Get the property type associated with the named property
@param name The PropertyType key associated with the given string
*/
static PropertyType getPropertyType(const std::string& name);
private:
// The array of properties
std::string myProperties[LastPropType];
// List of default properties to use when none have been provided
static const char* ourDefaultProperties[LastPropType];
// The text strings associated with each property type
static const char* ourPropertyNames[LastPropType];
};
#endif