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;
147 WvString getme(WvStringParm defvalue = WvString::null)
const;
159 WvStringParm defvalue = WvString::null)
const
160 {
return (*
this)[
key].getme(defvalue); }
169 int getmeint(
int defvalue = 0)
const;
173 {
return (*
this)[
key].getmeint(defvalue); }
190 void setme(WvStringParm value)
const;
195 void setme(WVSTRING_FORMAT_DECL)
const
199 void xset(WvStringParm
key, WvStringParm value)
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(); )
630 #endif // __UNICONF_H
An implementation base class for key iterators.
bool refresh() const
Refreshes information about this key recursively.
void commit() const
Commits information about this key recursively.
UniConf()
Creates a NULL UniConf handle, useful for reporting errors.
This iterator walks over all children that match a wildcard pattern.
WvStringStar operator->() const
A different way to say cfg.getme().num(): use cfg->num() instead.
virtual WvString value() const =0
Returns the value of the current key.
void setmeint(int value) const
Stores an integer value for this key into the registry.
int xgetint(WvStringParm key, int defvalue=0) const
A different way to say cfg[x].getmeint(y).
void del_callback(void *cookie, bool recurse=true) const
Cancels notification requested using add_callback().
Iter(const UniConf &_top)
Creates an iterator over the direct children of a branch.
virtual ~UniConf()
Destroys the UniConf handle.
UniConf & operator=(const UniConf &other)
Reassigns the target of this handle to match a different one.
void xset(WvStringParm key, WvStringParm value) const
A different way to say cfg[x].setme(y).
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
IUniConfGen * mountgen(IUniConfGen *gen, bool refresh=true) const
Mounts a generator at this key.
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...
An implementation base class for sorted key iterators.
bool isok() const
Returns true if the generator at this key isok().
void remove() const
Removes this key and all of its children from the registry.
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
virtual UniConfKey key() const =0
Returns the current key.
void setme(WVSTRING_FORMAT_DECL) const
Stores a string value for this key into the registry.
void prefetch(bool recursive) const
See UniConfGen::prefetch().
UniConf root() const
Returns a handle to the root of the tree.
WvString getme(WvStringParm defvalue=WvString::null) const
Fetches the string value for this key from the registry.
void dump(WvStream &stream, bool everything=false) const
Prints the entire contents of this subtree to a stream.
void unmount(IUniConfGen *gen, bool commit) const
Unmounts the generator providing this key and destroys it.
void flush_delta()
Flushes the list of pending notifications by sending them.
static int defcomparator(const UniConf &a, const UniConf &b)
Default comparator.
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...
WvString is an implementation of a simple and efficient printable-string class.
UniConf parent() const
Returns a handle to the parent of this node.
An abstract data container that backs a UniConf tree.
UniConfRoot * rootobj() const
Returns a pointer to the UniConfRoot that manages this node.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
void del_setbool(bool *flag, bool recurse=true) const
Cancels notification requested using add_setbool().
void copy(const UniConf &dst, bool force) const
Equivalent to "cp -r" in a standard unix filesystem.
A sorted variant of UniConf::RecursiveIter.
WvString operator*() const
A different way to say cfg.getme(): use *cfg instead.
void xsetint(WvStringParm key, int value) const
A different way to say cfg[x].setme(y).
int getmeint(int defvalue=0) const
Fetches the integer value for this key from the registry.
A ridiculous class needed because UniConf::operator->() needs to return a pointer,...
void setme(WvStringParm value) const
Stores a string value for this key into the registry.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
WvString xget(WvStringParm key, WvStringParm defvalue=WvString::null) const
A different way to say cfg[x].getme(y).
IUniConfGen * mount(WvStringParm moniker, bool refresh=true) const
Mounts a generator at this key using a moniker.
RecursiveIter(const UniConf &_top)
Creates a recursive iterator over a branch.
virtual void rewind()=0
Rewinds the iterator.
UniConfKey fullkey() const
Returns the full path of this node, starting at the root.
virtual bool next()=0
Seeks to the next element in the sequence.
void hold_delta()
Pauses notifications until matched with a call to unhold_delta().
XIter(const UniConf &_top, const UniConfKey &pattern)
Creates a wildcard iterator.
A sorted variant of UniConf::XIter.
bool haschildren() const
Returns true if this key has children.
A sorted variant of UniConf::Iter.
UniConfKey last(int n=1) const
Returns the path formed by the n last segments of this path.
const UniConf operator[](const UniConfKey &key) const
Returns a handle for a subtree below this key.
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
bool ismountpoint() const
Determines if any generators are mounted at this key.
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.
UniConfKey fullkey(const UniConf &cfg) const
Returns the full path of this node, starting at the given handle.
This iterator walks through all immediate children of a UniConf node.
bool exists() const
Without fetching its value, returns true if this key exists.
UniConfKey key() const
Returns the path of this node relative to its parent.
void clear_delta()
Clears the list of pending notifications without sending them.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
This iterator performs depth-first traversal of a subtree.
bool isnull() const
Returns true if the handle is invalid (NULL).
IUniConfGen * whichmount(UniConfKey *mountpoint=NULL) const
Finds the generator that owns this key.
An abstract iterator over keys and values in a generator.