ucommon

keyfile Class Reference

Traditional keypair config file parsing class. More...

#include <keydata.h>

Inheritance diagram for keyfile:
Collaboration diagram for keyfile:

Public Types

typedef linked_pointer< keydataiterator
 Convenience typedef for iterative pointer.

Public Member Functions

keydatabegin (void) const
 Get first keydata object, for iterative examinations.
keydataend (void) const
 Get last keydata object, for iterative examinations.
int err (void)
keydataget (void) const
 Get the non-sectioned defaults if there are any.
keydataget (const char *section) const
 Get a keydata section name.
 keyfile (size_t pagesize=0)
 Create an empty key file ready for loading.
 keyfile (const char *path, size_t pagesize=0)
 Create a key file object from an existing config file.
 keyfile (const keyfile &copy, size_t pagesize=0)
void load (const char *path)
 Load (overlay) another config file over the currently loaded one.
void load (const keydata *source)
 Load a single set of keys.
void load (const keyfile *source)
 Load from an existing keyfile object.
keydataoperator() (const char *section) const
keydataoperator[] (const char *section) const
void release (void)
 Release and re-initialize keyfile.
bool save (const char *path)
 Save (write) a set of config keys to dist.

Protected Member Functions

keydatacreate (const char *section)

Friends

class keydata

Detailed Description

Traditional keypair config file parsing class.

This is used to get generic config data either from a /etc/xxx.conf, a windows style xxx.ini file, or a ~/.xxxrc file, and parses [] sections from the entire file at once.

Examples:

keydata.cpp.

Definition at line 150 of file keydata.h.


Constructor & Destructor Documentation

keyfile::keyfile ( size_t  pagesize = 0)

Create an empty key file ready for loading.

Parameters:
pagesizefor memory paging.
keyfile::keyfile ( const char *  path,
size_t  pagesize = 0 
)

Create a key file object from an existing config file.

Parameters:
pathto load from.
pagesizefor memory paging.

Member Function Documentation

keydata* keyfile::begin ( void  ) const [inline]

Get first keydata object, for iterative examinations.

Returns:
first key value in chain.

Definition at line 238 of file keydata.h.

keydata* keyfile::end ( void  ) const [inline]

Get last keydata object, for iterative examinations.

Returns:
first key value in chain.

Definition at line 245 of file keydata.h.

keydata* keyfile::get ( const char *  section) const

Get a keydata section name.

Parameters:
sectionname to look for.
Returns:
keydata section object if found, NULL if not.
Examples:
keydata.cpp.
keydata* keyfile::get ( void  ) const [inline]

Get the non-sectioned defaults if there are any.

Returns:
default key section.

Definition at line 231 of file keydata.h.

void keyfile::load ( const keyfile source)

Load from an existing keyfile object.

Parameters:
sourceto copy from.
void keyfile::load ( const keydata source)

Load a single set of keys.

Parameters:
sourceof keys to copy.
void keyfile::load ( const char *  path)

Load (overlay) another config file over the currently loaded one.

This is used to merge key data, such as getting default values from a global config, and then overlaying a local home config file.

Parameters:
pathto load keys from into current object.
bool keyfile::save ( const char *  path)

Save (write) a set of config keys to dist.

Parameters:
pathof file to save keys to.
Returns:
true on success.

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