47 #if defined (PLAYER_STATIC)
48 #define PLAYERCORE_EXPORT
49 #elif defined (playercore_EXPORTS)
50 #define PLAYERCORE_EXPORT __declspec (dllexport)
52 #define PLAYERCORE_EXPORT __declspec (dllimport)
55 #define PLAYERCORE_EXPORT
60#include <libplayerinterface/player.h>
199 public:
ConfigFile(uint32_t _default_host, uint32_t _default_robot);
202 public:
ConfigFile(
const char* _default_host, uint32_t _default_robot);
216 public:
bool Load(
const char *filename);
232 private:
bool Save(
const char *filename);
243 public:
bool ReadBool(
int section,
const char *name,
bool value);
246 private:
void WriteBool(
int section,
const char* name,
bool value);
249 private:
void WriteBool_Compat(
int section,
const char* name,
bool value);
262 private:
void WriteString(
int section,
276 private:
void WriteInt(
int section,
290 private:
void WriteFloat(
int section,
304 private:
void WriteLength(
int section,
317 public:
double ReadAngle(
int section,
const char *name,
double value);
363 private:
void WriteTupleString(
int section,
380 private:
void WriteTupleInt(
int section,
398 private:
void WriteTupleFloat(
int section,
415 private:
void WriteTupleLength(
int section,
436 private:
void WriteTupleAngle(
int section,
470 const char *name,
int code,
int index,
474 public:
bool ParseDriver(
int section);
477 public:
bool ParseInterface(
int section);
480 public:
bool ParseAllDrivers();
483 public:
bool ParseAllInterfaces();
504 private:
bool LoadTokens(FILE *file,
int include);
507 private:
bool LoadTokenComment(FILE *file,
int *line,
int include);
510 private:
bool LoadTokenWord(FILE *file,
int *line,
int include);
513 private:
bool LoadTokenInclude(FILE *file,
int *line,
int include);
516 private:
bool LoadTokenNum(FILE *file,
int *line,
int include);
519 private:
bool LoadTokenString(FILE *file,
int *line,
int include);
522 private:
bool LoadTokenSpace(FILE *file,
int *line,
int include);
525 private:
bool SaveTokens(FILE *file);
528 private:
void ClearTokens();
531 private:
bool AddToken(
int type,
const char *value,
int include);
534 private:
bool SetTokenValue(
int index,
const char *value);
537 private:
const char *GetTokenValue(
int index);
543 private:
bool ParseTokens();
546 private:
bool ParseTokenInclude(
int *index,
int *line);
549 private:
bool ParseTokenDefine(
int *index,
int *line);
552 private:
bool ParseTokenPlugin(
int *index,
int *line);
555 private:
bool ParseTokenWord(
int section,
int *index,
int *line);
558 private:
bool ParseTokenSection(
int section,
int *index,
int *line);
561 private:
bool ParseTokenField(
int section,
int *index,
int *line);
564 private:
bool ParseTokenTuple(
int section,
int field,
565 int *index,
int *line);
568 private:
void ClearMacros();
571 private:
int AddMacro(
const char *macroname,
const char *sectionname,
572 int line,
int starttoken,
int endtoken);
576 private:
int LookupMacro(
const char *macroname);
579 private:
void DumpMacros();
582 private:
void ClearSections();
585 private:
int AddSection(
int parent,
const char *type);
591 private:
void ClearFields();
594 private:
int AddField(
int section,
const char *name,
int line);
597 private:
void AddFieldValue(
int field,
int index,
int value_token);
600 private:
int GetField(
int section,
const char *name);
603 private:
int GetFieldValueCount(
int field);
607 private:
const char *GetFieldValue(
int field,
int index,
bool flag_used =
true);
610 private:
void SetFieldValue(
int field,
int index,
const char *value);
616 private: uint32_t LookupColor(
const char *name);
625 TokenWord, TokenNum, TokenString, TokenBool,
626 TokenOpenSection, TokenCloseSection,
627 TokenOpenTuple, TokenCloseTuple,
646 private:
int token_size, token_count;
647 private:
Token *tokens;
653 const char *macroname;
656 const char *sectionname;
662 int starttoken, endtoken;
666 private:
int macro_size;
667 private:
int macro_count;
681 private:
int section_size;
682 private:
int section_count;
706 private:
int field_size;
707 private:
int field_count;
708 private:
Field *fields;
709 private: uint32_t default_host;
710 private: uint32_t default_robot;
713 private:
double unit_length;
714 private:
double unit_angle;
Class for loading configuration file information.
Definition configfile.h:197
double ReadTupleAngle(int section, const char *name, int index, double value)
Read an angle form a tuple (includes units conversion)
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
double ReadTupleFloat(int section, const char *name, int index, double value)
Read a float (double) from a tuple field.
int LookupSection(const char *type)
Lookup a section number by section type name.
char * filename
Name of the file we loaded.
Definition configfile.h:619
int ReadTupleInt(int section, const char *name, int index, int value)
Read an integer from a tuple field.
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
double ReadAngle(int section, const char *name, double value)
Read an angle (includes unit conversion).
ConfigFile(uint32_t _default_host, uint32_t _default_robot)
Standard constructor.
void InsertFieldValue(int index, const char *name, const char *value)
Add a (name,value) pair directly into the database, without reading from a file.
bool Load(const char *filename)
Load config from file.
int ReadInt(int section, const char *name, int value)
Read an integer value.
uint32_t ReadColor(int section, const char *name, uint32_t value)
Read a color (includes text to RGB conversion)
void DumpTokens()
Dump the token list (for debugging).
const char * ReadFilename(int section, const char *name, const char *value)
Read a filename.
const char * GetSectionType(int section)
Get a section type name.
ConfigFile()
Alternate constructor, used when not loading from a file.
int GetTupleCount(int section, const char *name)
Get the number of values in a tuple.
bool WarnUnused()
Check for unused fields and print warnings.
void DumpSections()
Dump the section list for debugging.
int GetSectionCount()
Get the number of sections.
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
bool ReadBool(int section, const char *name, bool value)
Read a boolean value (one of: yes, no, true, false, 1, 0)
double ReadTupleLength(int section, const char *name, int index, double value)
Read a length from a tuple (includes units conversion)
double ReadLength(int section, const char *name, double value)
Read a length (includes unit conversion, if any).
~ConfigFile()
Standard destructor.
const char * ReadTupleString(int section, const char *name, int index, const char *value)
Read a string from a tuple field.
uint32_t ReadTupleColor(int section, const char *name, int index, uint32_t value)
Read a color (includes text to RGB conversion)
ConfigFile(const char *_default_host, uint32_t _default_robot)
Alternate constructor, to specify the host as a string.
int GetSectionParent(int section)
Get a section's parent section.
void DumpFields()
Dump the field list for debugging.
Definition configfile.h:651
Definition configfile.h:687
Definition configfile.h:672
Definition configfile.h:633
A device address.
Definition player.h:146