WXP::Resrc Class Reference

This class defines a set of global resources to be used. More...

#include "../include/Resrc.h"

List of all members.

Classes

struct  ResrcItem

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 defines a set of global resources to be used.

Author:
Dan Vietor

Constructor & Destructor Documentation

Resrc::Resrc (  ) 

Constructor. Initializes class values

References init().

Resrc::~Resrc (  ) 

Destructor. Deallocates resource list

References clear().


Member Function Documentation

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

Adds a resource to the resource list

Parameters:
name Name of resource to add
data The value of the resource

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

Referenced by put(), and set().

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

Appends a value to the end of an existing resource

Parameters:
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().

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

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

Parameters:
name The name of the resource
val The value to return if resource not in list or not a number
float Resrc::get ( const char *  name,
float  val 
)

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

Parameters:
name The name of the resource
val The value to return if resource not in list or not a number
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:
name The resource the get
def The default value if the resource is not in the list
const char * Resrc::get ( const char *  name  ) 

Gets the value of a resource

Parameters:
name The resource to get

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

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:
name The name of the resource.

References WXP::StrLib::iequal().

const char * Resrc::getNext (  ) 

Returns the next resource name in the list

Returns:
The resource name
int Resrc::getValues ( String name,
String value,
int  flag 
)

Gets each value out of the list.

Return values:
name The resource name
value The value of the resource
Parameters:
flag A flag (0=start of list, 1=next on list)
Returns:
1=more values, 0=end of 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

Parameters:
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

Parameters:
name The resource to print
int Resrc::printAll (  ) 

Prints all the resources and their values to standard output

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

Adds a resource to the resource list

Parameters:
name The resource name to add
data The value of the resource
See also:
Resrc::add

References add().

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.

Parameters:
name Name of resource to scan
form The scanf format to use
Return values:
... The output variables to put data into.
int Resrc::set ( const char *  name,
String data 
)

Adds a resource to the resource list

Parameters:
name The resource name to add
data The value of the resource
See also:
Resrc::add

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

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

Adds a resource to the resource list

Parameters:
name The resource name to add
data The value of the resource
See also:
Resrc::add

References add().

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

Adds a resource to the resource list

Parameters:
name The resource name to add
data The value of the resource
See also:
Resrc::add

References add().

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


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

Generated on 8 Jan 2010 for WXP C++ Library by  doxygen 1.6.1