WXP C++ Library Version 6.74.9
|
This class stores a set of resources to be used to set parameters in various objects. More...
#include "../include/Resrc.h"
Public Types | |
enum | ResrcType { NONE , BASE , FILE , ENV , COMMAND , USER } |
Public Member Functions | |
Resrc () | |
~Resrc () | |
int | clear () |
int | init () |
int | add (const char *name, const char *data, int type) |
int | set (const char *name, const char *data) |
int | set (const char *name, const char *data, int type) |
int | set (const char *name, String &data) |
int | put (const char *name, const char *data) |
int | prepend (const char *name, const char *data, char delim='\n') |
int | append (const char *name, const char *data, char delim='\n') |
const char * | get (const char *name) |
const char * | get (const char *name, const char *def) |
int | getType (const char *name) |
int | getValues (String &name, String &value, int flag) |
bool | getBool (const char *name) |
float | get (const char *name, float val) |
int | get (const char *name, int val) |
int | scanf (const char *name, const char *form,...) |
int | rewind () |
const char * | getNext () |
int | print (const char *name) |
int | printAll () |
This class stores a set of resources to be used to set parameters in various objects.
Resrc::Resrc | ( | ) |
Constructor. Initializes class values
References init().
Resrc::~Resrc | ( | ) |
Destructor. Deallocates resource list
References clear().
int Resrc::add | ( | const char * | name, |
const char * | data, | ||
int | type | ||
) |
Adds a resource to the resource list
name | Name of resource to add |
data | The value of the resource |
type | The type/source of resource |
References WXP::StrLib::acopy(), and WXP::StrLib::equal().
int Resrc::append | ( | const char * | name, |
const char * | data, | ||
char | delim = '\n' |
||
) |
Appends a value to the end of an existing resource
name | The resource to use |
data | The value to append |
delim | The delimiter to add between the old and new value (defaults to newline) |
References WXP::StrLib::acopy().
int Resrc::clear | ( | ) |
Clears the resource lists. Deallocates string parameters
Referenced by ~Resrc().
const char * Resrc::get | ( | const char * | name | ) |
Gets the value of a resource
name | The resource to get |
Referenced by get(), get(), get(), WXP::ResrcEnv::get(), getBool(), print(), scanf(), and WXP::ResrcFile::set().
const char * Resrc::get | ( | const char * | name, |
const char * | def | ||
) |
Gets the value of a resource. If the resource is not in the list, use a default value.
name | The resource the get |
def | The default value if the resource is not in the list |
References get().
float Resrc::get | ( | const char * | name, |
float | val | ||
) |
Gets the value of a resource and outputs a floating point value.
name | The name of the resource |
val | The value to return if resource not in list or not a number |
References get().
int Resrc::get | ( | const char * | name, |
int | val | ||
) |
Gets the value of a resource and outputs a integer value.
name | The name of the resource |
val | The value to return if resource not in list or not a number |
References get().
bool Resrc::getBool | ( | const char * | name | ) |
Gets the value of the resource and outputs a boolean value. This assumes the value is set to something like (yes/no), (off/on), (true/false).
name | The name of the resource. |
References get(), and WXP::StrLib::iequal().
const char * Resrc::getNext | ( | ) |
Returns the next resource name in the list
Gets each value out of the list.
name | The resource name |
value | The value of the resource |
flag | A flag (0=start of list, 1=next on list) |
References WXP::String::copy().
int Resrc::init | ( | ) |
Initializes the class values
Referenced by Resrc().
int Resrc::prepend | ( | const char * | name, |
const char * | data, | ||
char | delim = '\n' |
||
) |
Prepend a value to the beginning of an existing resource value
name | The resource to use |
data | The string to prepend |
delim | A delimiter to use in between old and new values (defaults to newline) |
References WXP::StrLib::acopy(), and WXP::StrLib::equal().
int Resrc::print | ( | const char * | name | ) |
Prints a specific resource and its value to standard output
name | The resource to print |
References get().
int Resrc::printAll | ( | ) |
int Resrc::put | ( | const char * | name, |
const char * | data | ||
) |
Adds a resource to the resource list
name | The resource name to add |
data | The value of the resource |
int Resrc::rewind | ( | ) |
Sets the current pointer to the first resource in the list
int Resrc::scanf | ( | const char * | name, |
const char * | form, | ||
... | |||
) |
Scans the value of a resource using sscanf.
name | Name of resource to scan |
form | The scanf format to use |
... | The output variables to put data into. |
References get().
int Resrc::set | ( | const char * | name, |
const char * | data | ||
) |
Adds a resource to the resource list
name | The resource name to add |
data | The value of the resource |
Referenced by WXP::ResrcFile::readFile().
int Resrc::set | ( | const char * | name, |
const char * | data, | ||
int | type | ||
) |
Adds a resource to the resource list
name | The resource name to add |
data | The value of the resource |
References add().
int Resrc::set | ( | const char * | name, |
String & | data | ||
) |
Adds a resource to the resource list
name | The resource name to add |
data | The value of the resource |
References add(), WXP::String::get(), and USER.