89 public:
const std::string
ReadString(
int entity,
const char* name,
const std::string& value);
92 public:
void WriteString(
int entity,
const char *name,
const std::string& value );
95 public:
int ReadInt(
int entity,
const char *name,
int value);
98 public:
void WriteInt(
int entity,
const char *name,
int value);
101 public:
double ReadFloat(
int entity,
const char *name,
double value);
104 public:
void WriteFloat(
int entity,
const char *name,
double value);
107 public:
double ReadLength(
int entity,
const char *name,
double value)
113 public:
void WriteLength(
int entity,
const char *name,
double value);
116 public:
double ReadAngle(
int entity,
const char *name,
double value)
125 public: uint32_t
ReadColor(
int entity,
const char *name, uint32_t value);
130 public:
const char *
ReadFilename(
int entity,
const char *name,
const char *value);
133 public:
int ReadTuple(
const int entity,
const char* name,
134 const unsigned int first,
const unsigned int num,
const char* format, ... );
137 public:
void WriteTuple(
const int entity,
const char *name,
138 const unsigned int first,
const unsigned int count,
const char* format, ... );
145 private:
bool LoadTokens(FILE *file,
int include);
148 private:
bool LoadTokenComment(FILE *file,
int *line,
int include);
151 private:
bool LoadTokenWord(FILE *file,
int *line,
int include);
154 private:
bool LoadTokenInclude(FILE *file,
int *line,
int include);
157 private:
bool LoadTokenNum(FILE *file,
int *line,
int include);
160 private:
bool LoadTokenString(FILE *file,
int *line,
int include);
163 private:
bool LoadTokenSpace(FILE *file,
int *line,
int include);
166 private:
bool SaveTokens(FILE *file);
169 private:
void ClearTokens();
172 private:
bool AddToken(
int type,
const char *value,
int include);
175 private:
bool SetTokenValue(
int index,
const char *value);
178 private:
const char *GetTokenValue(
int index);
181 private:
void DumpTokens();
184 private:
bool ParseTokens();
187 private:
bool ParseTokenInclude(
int *index,
int *line);
190 private:
bool ParseTokenDefine(
int *index,
int *line);
193 private:
bool ParseTokenWord(
int entity,
int *index,
int *line);
196 private:
bool ParseTokenEntity(
int entity,
int *index,
int *line);
199 private:
bool ParseTokenProperty(
int entity,
int *index,
int *line);
202 private:
bool ParseTokenTuple(
CProperty* property,
int *index,
int *line);
205 private:
void ClearMacros();
208 private:
void AddMacro(
const char *macroname,
const char *entityname,
209 int line,
int starttoken,
int endtoken);
215 private: CMacro* LookupMacro(
const char *macroname);
218 private:
void DumpMacros();
221 private:
void ClearEntities();
224 private:
int AddEntity(
int parent,
const char *type);
241 private:
void DumpEntities();
244 private:
void ClearProperties();
247 private:
CProperty* AddProperty(
int entity,
const char *name,
int line);
249 private:
void AddPropertyValue(
CProperty* property,
int index,
int value_token);
259 private:
void SetPropertyValue(
CProperty* property,
int index,
const char *value);
265 private:
void DumpProperties();
271 TokenWord, TokenNum, TokenString,
272 TokenOpenEntity, TokenCloseEntity,
273 TokenOpenTuple, TokenCloseTuple,
291 CToken(
int include,
int type,
const char* value ) :
292 include(include), type(type), value(value) {}
298 private: std::vector<CToken> tokens;
306 std::string macroname;
309 std::string entityname;
315 int starttoken, endtoken;
317 CMacro(
const char *macroname,
const char *entityname,
318 int line,
int starttoken,
int endtoken) :
319 macroname(macroname),
320 entityname(entityname),
322 starttoken(starttoken),
323 endtoken(endtoken) {}
327 private: std::map<std::string,CMacro> macros;
340 CEntity(
int parent,
const char* type ) : parent(parent), type(type) {}
344 private: std::vector<CEntity> entities;
347 private: std::map<std::string,CProperty*> properties;
std::string name
Name of property.
Definition: worldfile.hh:44
int GetEntityParent(int entity)
Definition: worldfile.cc:1204
bool used
Flag set if property has been used.
Definition: worldfile.hh:53
int LookupEntity(const char *type)
Definition: worldfile.cc:1225
double unit_angle
Definition: worldfile.hh:354
The Stage library uses its own namespace.
Definition: canvas.hh:8
const char * GetEntityType(int entity)
Definition: worldfile.cc:1214
int line
Line this property came from.
Definition: worldfile.hh:50
CProperty(int entity, const char *name, int line)
Definition: worldfile.hh:55
const std::string ReadString(int entity, const char *name, const std::string &value)
Definition: worldfile.cc:1376
CProperty * GetProperty(int entity, const char *name)
Definition: worldfile.cc:1298
const char * GetPropertyValue(CProperty *property, int index)
Definition: worldfile.cc:1345
const char * ReadFilename(int entity, const char *name, const char *value)
Definition: worldfile.cc:1450
int ReadTuple(const int entity, const char *name, const unsigned int first, const unsigned int num, const char *format,...)
Definition: worldfile.cc:1506
void WriteInt(int entity, const char *name, int value)
Definition: worldfile.cc:1409
void WriteTuple(const int entity, const char *name, const unsigned int first, const unsigned int count, const char *format,...)
Definition: worldfile.cc:1573
bool Save(const std::string &filename)
Definition: worldfile.cc:193
bool PropertyExists(int section, const char *token)
Definition: worldfile.cc:1324
std::string filename
Definition: worldfile.hh:350
int entity
Index of entity this property belongs to.
Definition: worldfile.hh:41
~Worldfile()
Definition: worldfile.cc:78
double ReadLength(int entity, const char *name, double value)
Definition: worldfile.hh:107
uint32_t ReadColor(int entity, const char *name, uint32_t value)
void WriteString(int entity, const char *name, const std::string &value)
Definition: worldfile.cc:1387
Worldfile()
Definition: worldfile.cc:64
void WriteFloat(int entity, const char *name, double value)
Definition: worldfile.cc:1418
double unit_length
Definition: worldfile.hh:353
bool WarnUnused()
Definition: worldfile.cc:224
int GetEntityCount()
Definition: worldfile.cc:1196
void WriteLength(int entity, const char *name, double value)
double ReadFloat(int entity, const char *name, double value)
Definition: worldfile.cc:1434
Definition: worldfile.hh:69
int ReadInt(int entity, const char *name, int value)
Definition: worldfile.cc:1398
bool Load(const std::string &filename)
Definition: worldfile.cc:125
double ReadAngle(int entity, const char *name, double value)
Definition: worldfile.hh:116
FILE * FileOpen(const std::string &filename, const char *method)
Definition: worldfile.cc:86
Property class.
Definition: worldfile.hh:37
std::vector< int > values
A list of token indexes.
Definition: worldfile.hh:47