UCommon
Public Types | Public Member Functions | Protected Member Functions | Friends
ucommon::keyfile Class Reference

Traditional keypair config file parsing class. More...

#include <keydata.h>

Inheritance diagram for ucommon::keyfile:
Inheritance graph
[legend]
Collaboration diagram for ucommon::keyfile:
Collaboration graph
[legend]

Public Types

typedef linked_pointer< keydatapointer
 Convenience typedef for iterative pointer.
 

Public Member Functions

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

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. More...
 
page_t * pager (void)
 Acquire a new page from the heap. More...
 

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.

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:

◆ 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 keyfile source)

Load from an existing keyfile object.

Parameters
sourceto copy from.

◆ load() [3/3]

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

Load a single set of keys.

Parameters
sourceof keys to copy.

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

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