UCommon
ucommon::keyfile Class Reference

Traditional keypair config file parsing class. More...

#include <keydata.h>

Inheritance diagram for ucommon::keyfile:
Collaboration diagram for ucommon::keyfile:

Public Types

typedef linked_pointer< keydatapointer
 Convenience typedef for iterative pointer.
 

Public Member Functions

void assign (keyfile &source)
 Assign foreign pager to us.
 
keydatabegin (void) const
 Get first keydata object, for iterative examinations.
 
keydataend (void) const
 Get last keydata object, for iterative examinations.
 
int err (void) const
 
keydataget (const char *section) const
 Get a keydata section name.
 
keydataget (void) const
 Get the non-sectioned defaults if there are any.
 
 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)
 
 keyfile (size_t pagesize=0)
 Create an empty key file ready for loading.
 
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
 
keyfileoperator= (keyfile &source)
 
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.
 
- Public Member Functions inherited from ucommon::memalloc
void assign (memalloc &source)
 Assign foreign pager to us.
 
unsigned max (void) const
 Get the maximum number of pages that are permitted.
 
 memalloc (const memalloc &copy)
 
 memalloc (size_t page=0)
 Construct a memory pager.
 
unsigned pages (void) const
 Get the number of pages that have been allocated from the real heap.
 
void purge (void)
 Purge all allocated memory and heap pages immediately.
 
size_t size (void) const
 Get the size of a memory page.
 
unsigned utilization (void) const
 Determine fragmentation level of acquired heap pages.
 
virtual ~memalloc ()
 Destroy a memory pager.
 

Protected Member Functions

keydatacreate (const char *section)
 
- Protected Member Functions inherited from ucommon::memalloc
virtual void * _alloc (size_t size)
 Allocate memory from the pager heap.
 
page_t * pager (void)
 Acquire a new page from the heap.
 

Friends

class keydata
 

Additional Inherited Members

- Protected Attributes inherited from ucommon::memalloc
unsigned limit
 

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 160 of file keydata.h.

Member Typedef Documentation

◆ pointer

Convenience typedef for iterative pointer.

Definition at line 266 of file keydata.h.

Constructor & Destructor Documentation

◆ keyfile() [1/2]

ucommon::keyfile::keyfile ( size_t pagesize = 0)

Create an empty key file ready for loading.

Parameters
pagesizefor memory paging.

◆ keyfile() [2/2]

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

◆ assign()

void ucommon::keyfile::assign ( keyfile & source)

Assign foreign pager to us.

This relocates the heap references to our object, clears the other object.

◆ begin()

keydata * ucommon::keyfile::begin ( void ) const
inline

Get first keydata object, for iterative examinations.

Returns
first key value in chain.

Definition at line 251 of file keydata.h.

Here is the call graph for this function:

◆ end()

keydata * ucommon::keyfile::end ( void ) const
inline

Get last keydata object, for iterative examinations.

Returns
first key value in chain.

Definition at line 259 of file keydata.h.

Here is the call graph for this function:

◆ err()

int ucommon::keyfile::err ( void ) const
inline

Definition at line 268 of file keydata.h.

◆ get() [1/2]

keydata * ucommon::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.

◆ get() [2/2]

keydata * ucommon::keyfile::get ( void ) const
inline

Get the non-sectioned defaults if there are any.

Returns
default key section.

Definition at line 243 of file keydata.h.

◆ load() [1/3]

void ucommon::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.

◆ load() [2/3]

void ucommon::keyfile::load ( const keydata * source)

Load a single set of keys.

Parameters
sourceof keys to copy.

◆ load() [3/3]

void ucommon::keyfile::load ( const keyfile * source)

Load from an existing keyfile object.

Parameters
sourceto copy from.

◆ operator()()

keydata * ucommon::keyfile::operator() ( const char * section) const
inline

Definition at line 231 of file keydata.h.

◆ operator=()

keyfile & ucommon::keyfile::operator= ( keyfile & source)
inline

Definition at line 278 of file keydata.h.

◆ operator[]()

keydata * ucommon::keyfile::operator[] ( const char * section) const
inline

Definition at line 235 of file keydata.h.

◆ save()

bool ucommon::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.

Friends And Related Symbol Documentation

◆ keydata

friend class keydata
friend

Definition at line 163 of file keydata.h.


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