12 #include "uniconfgen.h"
13 #include "uniconfkey.h"
96 {
return xroot == NULL; }
112 {
return xfullkey.
last(); }
127 {
return (*
this)[
key]; }
133 xfullkey = other.xfullkey;
141 void prefetch(
bool recursive)
const;
160 {
return (*
this)[
key].getme(defvalue); }
169 int getmeint(
int defvalue = 0)
const;
173 {
return (*
this)[
key].getmeint(defvalue); }
195 void setme(WVSTRING_FORMAT_DECL)
const
200 { (*this)[
key].setme(value); }
209 { (*this)[
key].setmeint(value); }
233 {
setme(WvString::null); }
319 void add_callback(
void *cookie,
const UniConfCallback &callback,
320 bool recurse =
true)
const;
325 void del_callback(
void *cookie,
bool recurse =
true)
const;
331 void add_setbool(
bool *flag,
bool recurse =
true)
const;
336 void del_setbool(
bool *flag,
bool recurse =
true)
const;
377 void dump(
WvStream &stream,
bool everything =
false)
const;
399 class SortedIterBase;
403 class SortedRecursiveIter;
452 current = top[it->
key()];
459 {
return it->
value(); }
483 current = top[it->
key()];
490 {
return it->
value(); }
531 void enter(
const UniConf &child);
557 Comparator xcomparator;
565 std::vector<UniConf> xkeys;
568 void populate(
Iter &i)
571 for (i.rewind(); i.next(); )
An abstract data container that backs a UniConf tree.
An abstract iterator over keys and values in a generator.
virtual bool next()=0
Seeks to the next element in the sequence.
virtual WvString value() const =0
Returns the value of the current key.
virtual void rewind()=0
Rewinds the iterator.
virtual UniConfKey key() const =0
Returns the current key.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
UniConfKey last(int n=1) const
Returns the path formed by the n last segments of this path.
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
An implementation base class for key iterators.
This iterator walks through all immediate children of a UniConf node.
Iter(const UniConf &_top)
Creates an iterator over the direct children of a branch.
This iterator performs depth-first traversal of a subtree.
RecursiveIter(const UniConf &_top)
Creates a recursive iterator over a branch.
An implementation base class for sorted key iterators.
static int defcomparator(const UniConf &a, const UniConf &b)
Default comparator.
A sorted variant of UniConf::Iter.
A sorted variant of UniConf::RecursiveIter.
A sorted variant of UniConf::XIter.
This iterator walks over all children that match a wildcard pattern.
XIter(const UniConf &_top, const UniConfKey &pattern)
Creates a wildcard iterator.
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
UniConfKey key() const
Returns the path of this node relative to its parent.
void commit() const
Commits information about this key recursively.
void add_callback(void *cookie, const UniConfCallback &callback, bool recurse=true) const
Requests notification when any of the keys covered by the recursive depth specification change by inv...
void remove() const
Removes this key and all of its children from the registry.
void prefetch(bool recursive) const
See UniConfGen::prefetch().
UniConf root() const
Returns a handle to the root of the tree.
WvStringStar operator->() const
A different way to say cfg.getme().num(): use cfg->num() instead.
void xset(WvStringParm key, WvStringParm value) const
A different way to say cfg[x].setme(y).
void clear_delta()
Clears the list of pending notifications without sending them.
const UniConf u(const UniConfKey &key) const
Return a subtree handle (see operator[]).
void move(const UniConf &dst) const
Equivalent to "mv" in a standard unix filesystem.
WvString operator*() const
A different way to say cfg.getme(): use *cfg instead.
WvString xget(WvStringParm key, WvStringParm defvalue=WvString::null) const
A different way to say cfg[x].getme(y).
int getmeint(int defvalue=0) const
Fetches the integer value for this key from the registry.
bool haschildren() const
Returns true if this key has children.
UniConf parent() const
Returns a handle to the parent of this node.
void setme(WvStringParm value) const
Stores a string value for this key into the registry.
bool exists() const
Without fetching its value, returns true if this key exists.
void unmount(IUniConfGen *gen, bool commit) const
Unmounts the generator providing this key and destroys it.
bool isnull() const
Returns true if the handle is invalid (NULL).
UniConfKey fullkey(const UniConf &cfg) const
Returns the full path of this node, starting at the given handle.
UniConf()
Creates a NULL UniConf handle, useful for reporting errors.
void add_setbool(bool *flag, bool recurse=true) const
Requests notification when any of the keys covered by the recursive depth specification change by set...
void del_setbool(bool *flag, bool recurse=true) const
Cancels notification requested using add_setbool().
const UniConf operator[](const UniConfKey &key) const
Returns a handle for a subtree below this key.
bool refresh() const
Refreshes information about this key recursively.
UniConfRoot * rootobj() const
Returns a pointer to the UniConfRoot that manages this node.
IUniConfGen * mount(WvStringParm moniker, bool refresh=true) const
Mounts a generator at this key using a moniker.
int xgetint(WvStringParm key, int defvalue=0) const
A different way to say cfg[x].getmeint(y).
IUniConfGen * whichmount(UniConfKey *mountpoint=NULL) const
Finds the generator that owns this key.
UniConfKey fullkey() const
Returns the full path of this node, starting at the root.
void flush_delta()
Flushes the list of pending notifications by sending them.
void del_callback(void *cookie, bool recurse=true) const
Cancels notification requested using add_callback().
void copy(const UniConf &dst, bool force) const
Equivalent to "cp -r" in a standard unix filesystem.
bool isok() const
Returns true if the generator at this key isok().
void setme(WVSTRING_FORMAT_DECL) const
Stores a string value for this key into the registry.
void dump(WvStream &stream, bool everything=false) const
Prints the entire contents of this subtree to a stream.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
void setmeint(int value) const
Stores an integer value for this key into the registry.
virtual ~UniConf()
Destroys the UniConf handle.
void hold_delta()
Pauses notifications until matched with a call to unhold_delta().
bool ismountpoint() const
Determines if any generators are mounted at this key.
WvString getme(WvStringParm defvalue=WvString::null) const
Fetches the string value for this key from the registry.
IUniConfGen * mountgen(IUniConfGen *gen, bool refresh=true) const
Mounts a generator at this key.
void xsetint(WvStringParm key, int value) const
A different way to say cfg[x].setme(y).
UniConf & operator=(const UniConf &other)
Reassigns the target of this handle to match a different one.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
A ridiculous class needed because UniConf::operator->() needs to return a pointer,...
WvString is an implementation of a simple and efficient printable-string class.