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