WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
WXP::Resrc Class Reference

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 ()
 

Detailed Description

This class stores a set of resources to be used to set parameters in various objects.

Author
Dan Vietor

Member Enumeration Documentation

◆ ResrcType

Enumerator
NONE 

No source

BASE 

Predefined

FILE 

Resource/defaults file

ENV 

Environment variables

COMMAND 

Command line

USER 

Users specified

Constructor & Destructor Documentation

◆ Resrc()

Resrc::Resrc ( )

Constructor. Initializes class values

References init().

◆ ~Resrc()

Resrc::~Resrc ( )

Destructor. Deallocates resource list

References clear().

Member Function Documentation

◆ add()

int Resrc::add ( const char *  name,
const char *  data,
int  type 
)

Adds a resource to the resource list

Parameters
nameName of resource to add
dataThe value of the resource
typeThe type/source of resource

References WXP::StrLib::acopy(), and WXP::StrLib::equal().

Referenced by put(), set(), set(), and set().

◆ append()

int Resrc::append ( const char *  name,
const char *  data,
char  delim = '\n' 
)

Appends a value to the end of an existing resource

Parameters
nameThe resource to use
dataThe value to append
delimThe delimiter to add between the old and new value (defaults to newline)

References WXP::StrLib::acopy().

◆ clear()

int Resrc::clear ( )

Clears the resource lists. Deallocates string parameters

Referenced by ~Resrc().

◆ get() [1/4]

const char * Resrc::get ( const char *  name)

Gets the value of a resource

Parameters
nameThe resource to get

Referenced by get(), get(), get(), WXP::ResrcEnv::get(), getBool(), print(), scanf(), and WXP::ResrcFile::set().

◆ get() [2/4]

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.

Parameters
nameThe resource the get
defThe default value if the resource is not in the list

References get().

◆ get() [3/4]

float Resrc::get ( const char *  name,
float  val 
)

Gets the value of a resource and outputs a floating point value.

Parameters
nameThe name of the resource
valThe value to return if resource not in list or not a number

References get().

◆ get() [4/4]

int Resrc::get ( const char *  name,
int  val 
)

Gets the value of a resource and outputs a integer value.

Parameters
nameThe name of the resource
valThe value to return if resource not in list or not a number

References get().

◆ getBool()

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).

Parameters
nameThe name of the resource.

References get(), and WXP::StrLib::iequal().

◆ getNext()

const char * Resrc::getNext ( )

Returns the next resource name in the list

Returns
The resource name

◆ getValues()

int Resrc::getValues ( String name,
String value,
int  flag 
)

Gets each value out of the list.

Return values
nameThe resource name
valueThe value of the resource
Parameters
flagA flag (0=start of list, 1=next on list)
Returns
1=more values, 0=end of list

References WXP::String::copy().

◆ init()

int Resrc::init ( )

Initializes the class values

Referenced by Resrc().

◆ prepend()

int Resrc::prepend ( const char *  name,
const char *  data,
char  delim = '\n' 
)

Prepend a value to the beginning of an existing resource value

Parameters
nameThe resource to use
dataThe string to prepend
delimA delimiter to use in between old and new values (defaults to newline)

References WXP::StrLib::acopy(), and WXP::StrLib::equal().

◆ print()

int Resrc::print ( const char *  name)

Prints a specific resource and its value to standard output

Parameters
nameThe resource to print

References get().

◆ printAll()

int Resrc::printAll ( )

Prints all the resources and their values to standard output

References COMMAND, ENV, and FILE.

◆ put()

int Resrc::put ( const char *  name,
const char *  data 
)

Adds a resource to the resource list

Parameters
nameThe resource name to add
dataThe value of the resource
See also
Resrc::add

References add(), and USER.

◆ rewind()

int Resrc::rewind ( )

Sets the current pointer to the first resource in the list

◆ scanf()

int Resrc::scanf ( const char *  name,
const char *  form,
  ... 
)

Scans the value of a resource using sscanf.

Parameters
nameName of resource to scan
formThe scanf format to use
Return values
...The output variables to put data into.

References get().

◆ set() [1/3]

int Resrc::set ( const char *  name,
const char *  data 
)

Adds a resource to the resource list

Parameters
nameThe resource name to add
dataThe value of the resource
See also
Resrc::add

References add(), and USER.

Referenced by WXP::ResrcFile::readFile().

◆ set() [2/3]

int Resrc::set ( const char *  name,
const char *  data,
int  type 
)

Adds a resource to the resource list

Parameters
nameThe resource name to add
dataThe value of the resource
See also
Resrc::add

References add().

◆ set() [3/3]

int Resrc::set ( const char *  name,
String data 
)

Adds a resource to the resource list

Parameters
nameThe resource name to add
dataThe value of the resource
See also
Resrc::add

References add(), WXP::String::get(), and USER.


The documentation for this class was generated from the following files: