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< keydataiterator
 Convenience typedef for iterative pointer.

Public Member Functions

keydatabegin (void)
 Get first keydata object, for iterative examinations.
keydataend (void)
 Get last keydata object, for iterative examinations.
int err (void)
keydataget (char *section)
 Get a keydata section name.
keydataget (void)
 Get the non-sectioned defaults if there are any.
 keyfile (size_t pagesize=0)
 Create an empty key file ready for loading.
 keyfile (char *path, size_t pagesize=0)
 Create a key file object from an existing config file.
 keyfile (keyfile &copy, size_t pagesize=0)
void load (char *path)
 Load (overlay) another config file over the currently loaded one.
void load (keyfile *source)
 Load from an existing keyfile object.
void load (keydata *source)
 Load a single set of keys.
keydataoperator() (char *section)
keydataoperator[] (char *section)
void release (void)
 Release and re-initialize keyfile.
bool save (char *path)
 Save (write) a set of config keys to dist.
- Public Member Functions inherited from ucommon::memalloc
virtual void * _alloc (size_t size)
 Allocate memory from the pager heap.
unsigned getAlloc (void)
 Get the size of a memory page.
unsigned getLimit (void)
 Get the maximum number of pages that are permitted.
unsigned getPages (void)
 Get the number of pages that have been allocated from the real heap.
 memalloc (size_t page=0)
 Construct a memory pager.
void purge (void)
 Purge all allocated memory and heap pages immediately.
unsigned utilization (void)
 Determine fragmentation level of acquired heap pages.
virtual ~memalloc ()
 Destroy a memory pager.
- Public Member Functions inherited from ucommon::MemoryProtocol
void * alloc (size_t size)
 Convenience function.
char * dup (const char *string)
 Duplicate NULL terminated string into allocated memory.
void * dup (void *memory, size_t size)
 Duplicate existing memory block into allocated memory.
void * zalloc (size_t size)
 Allocate memory from the pager heap.

Protected Member Functions

keydatacreate (char *section)
- Protected Member Functions inherited from ucommon::memalloc
page_t * pager (void)
 Acquire a new page from the heap.
- Protected Member Functions inherited from ucommon::MemoryProtocol
virtual void * _alloc (size_t size)=0
 Protocol to allocate memory from the pager heap.
virtual void _lock (void)
virtual void _unlock (void)

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.

Definition at line 150 of file keydata.h.

Constructor & Destructor Documentation

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

Create an empty key file ready for loading.

Parameters
pagesizefor memory paging.
ucommon::keyfile::keyfile ( 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* ucommon::keyfile::begin ( void  )
inline

Get first keydata object, for iterative examinations.

Returns
first key value in chain.

Definition at line 238 of file keydata.h.

Here is the call graph for this function:

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

Get last keydata object, for iterative examinations.

Returns
first key value in chain.

Definition at line 245 of file keydata.h.

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

Get a keydata section name.

Parameters
sectionname to look for.
Returns
keydata section object if found, NULL if not.
keydata* ucommon::keyfile::get ( void  )
inline

Get the non-sectioned defaults if there are any.

Returns
default key section.

Definition at line 231 of file keydata.h.

void ucommon::keyfile::load ( 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.
void ucommon::keyfile::load ( keyfile source)

Load from an existing keyfile object.

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

Load a single set of keys.

Parameters
sourceof keys to copy.
bool ucommon::keyfile::save ( 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: