1 #ifndef ALLOFW_CONFIG_H 2 #define ALLOFW_CONFIG_H 19 virtual bool isArray()
const = 0;
21 virtual bool isValue()
const = 0;
24 virtual void getString(
char* output,
size_t output_capacity,
const char* fallback =
"")
const = 0;
28 virtual int getInt32(
int fallback = 0)
const = 0;
30 virtual unsigned int getUInt32(
unsigned int fallback = 0)
const = 0;
32 virtual float getFloat(
float fallback = 0.0f)
const = 0;
34 virtual double getDouble(
double fallback = 0.0)
const = 0;
36 virtual bool getBoolean(
bool fallback = 0.0)
const = 0;
41 char* buffer =
new char[len + 1];
43 std::string result(buffer);
49 virtual Node*
get(
int index)
const = 0;
51 virtual Node*
get(
const char* key)
const = 0;
53 virtual size_t size()
const = 0;
65 virtual void getString(
const char* path,
char* output,
size_t output_capacity,
const char* fallback =
"") = 0;
67 virtual size_t getStringLength(
const char* path,
const char* fallback =
"") = 0;
70 virtual int getInt32(
const char* path,
int fallback = 0) = 0;
72 virtual unsigned int getUInt32(
const char* path,
unsigned int fallback = 0) = 0;
74 virtual float getFloat(
const char* path,
float fallback = 0.0f) = 0;
76 virtual double getDouble(
const char* path,
double fallback = 0.0) = 0;
78 virtual bool getBoolean(
const char* path,
bool fallback = 0.0) = 0;
81 virtual void parseFile(
const char* path) = 0;
83 virtual void parseFile(
const char* path,
const char* key) = 0;
86 std::string
getString(
const char* path,
const char* fallback =
"") {
88 char* buffer =
new char[len + 1];
89 getString(path, buffer, len + 1, fallback);
90 std::string result(buffer);
virtual bool getBoolean(bool fallback=0.0) const =0
Get boolean value.
virtual double getDouble(double fallback=0.0) const =0
Get double value.
virtual int getInt32(int fallback=0) const =0
Get int32 value.
virtual bool isDictionary() const =0
Is this an array?
virtual unsigned int getUInt32(unsigned int fallback=0) const =0
Get uint32 value.
virtual bool isArray() const =0
virtual Node * getNode(const char *key)=0
Get a node with a key (pair with destroyNode).
static Configuration * Create()
Create Configuration object.
Config node.
Definition: config.h:16
virtual float getFloat(float fallback=0.0f) const =0
Get float value.
virtual void getString(char *output, size_t output_capacity, const char *fallback="") const =0
Is this a value?
YAML-based configuration reader.
Definition: config.h:12
std::string getString(const char *path, const char *fallback="")
Get STL string at a given path.
Definition: config.h:86
std::string getString(const char *fallback="")
Get STL string value.
Definition: config.h:39
virtual bool isValue() const =0
Is this a dictionary?
virtual ~Node()
Definition: config.h:56
static Configuration * ParseMainArgs(int argc, char *argv[])
Create Configuration object by C++ main() arguments.
virtual size_t size() const =0
Get size of the node (for array and dictionary).
static Configuration * CreateFromFile(const char *args=nullptr)
Create Configuration object from file.
virtual size_t getStringLength(const char *fallback="") const =0
Get the length of the string.
virtual ~Configuration()
Definition: config.h:95
virtual void parseFile(const char *path)=0
Parse a YAML file.
virtual void destroyNode(Node *node)=0
Destroy the node.