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;
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(); )
604 Comparator comparator = defcomparator)
622 Comparator comparator = defcomparator)
630 #endif // __UNICONF_H UniConf root() const
Returns a handle to the root of the tree.
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...
This iterator performs depth-first traversal of a subtree.
A ridiculous class needed because UniConf::operator->() needs to return a pointer, even though that pointer is going to be dereferenced immediately anyway.
void unmount(IUniConfGen *gen, bool commit) const
Unmounts the generator providing this key and destroys it.
This iterator walks through all immediate children of a UniConf node.
An abstract data container that backs a UniConf tree.
int getmeint(int defvalue=0) const
Fetches the integer value for this key from the registry.
const UniConf operator[](const UniConfKey &key) const
Returns a handle for a subtree below this key.
An abstract iterator over keys and values in a generator.
UniConfKey last(int n=1) const
Returns the path formed by the n last segments of this path.
virtual bool next()=0
Seeks to the next element in the sequence.
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.
WvString operator*() const
A different way to say cfg.getme(): use *cfg instead.
bool isnull() const
Returns true if the handle is invalid (NULL).
An implementation base class for key iterators.
bool refresh() const
Refreshes information about this key recursively.
void setme(WvStringParm value) const
Stores a string value for this key into the registry.
bool haschildren() const
Returns true if this key has children.
IUniConfGen * mount(WvStringParm moniker, bool refresh=true) const
Mounts a generator at this key using a moniker.
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.
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.
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.
UniConfKey fullkey() const
Returns the full path of this node, starting at the root.
void xset(WvStringParm key, WvStringParm value) const
A different way to say cfg[x].setme(y).
IUniConfGen * whichmount(UniConfKey *mountpoint=NULL) const
Finds the generator that owns this key.
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.
UniConf()
Creates a NULL UniConf handle, useful for reporting errors.
bool isok() const
Returns true if the generator at this key isok().
WvStringStar operator->() const
A different way to say cfg.getme().num(): use cfg->num() instead.
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[]).
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
virtual void rewind()=0
Rewinds the iterator.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
UniConf & operator=(const UniConf &other)
Reassigns the target of this handle to match a different one.
void dump(WvStream &stream, bool everything=false) const
Prints the entire contents of this subtree to a stream.
void flush_delta()
Flushes the list of pending notifications by sending them.
IUniConfGen * mountgen(IUniConfGen *gen, bool refresh=true) const
Mounts a generator at this key.
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 parent() const
Returns a handle to the parent of this node.
void commit() const
Commits information about this key recursively.
void setmeint(int value) const
Stores an integer value for this key into the registry.
A sorted variant of UniConf::Iter.
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().
void setme(WVSTRING_FORMAT_DECL) const
Stores a string value for this key into the registry.
virtual UniConfKey key() const =0
Returns the current key.
void prefetch(bool recursive) const
See UniConfGen::prefetch().
virtual ~UniConf()
Destroys the UniConf handle.
WvString getme(WvStringParm defvalue=WvString::null) const
Fetches the string value for this key from the registry.
WvString is an implementation of a simple and efficient printable-string class.
virtual WvString value() const =0
Returns the value of the current 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...
UniConfRoot * rootobj() const
Returns a pointer to the UniConfRoot that manages this node.
void xsetint(WvStringParm key, int value) const
A different way to say cfg[x].setme(y).
WvString xget(WvStringParm key, WvStringParm defvalue=WvString::null) const
A different way to say cfg[x].getme(y).
A sorted variant of UniConf::XIter.
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...