8 #include "uniconfroot.h" 9 #include "uniconfgen.h" 17 : xroot(root), xfullkey(fullkey)
30 : xroot(other.xroot), xfullkey(other.xfullkey)
52 return xroot->mounts.exists(xfullkey);
58 return xroot->mounts.haschildren(xfullkey);
64 xroot->mounts.prefetch(xfullkey, recursive);
70 WvString value = xroot->mounts.get(xfullkey);
79 return xroot->mounts.str2int(
getme(), defvalue);
85 xroot->mounts.set(xfullkey, value);
110 for (i.rewind(); i.next(); )
112 UniConf dst2 = dst[i->fullkey(*
this)];
114 dst2.
setme(i->getme());
121 return xroot->mounts.refresh();
127 xroot->mounts.commit();
133 return xroot->mounts.mount(xfullkey, moniker, refresh);
139 return xroot->mounts.mountgen(xfullkey, gen, refresh);
145 return xroot->mounts.unmount(gen, commit);
151 return xroot->mounts.ismountpoint(xfullkey);
157 return xroot->mounts.whichmount(xfullkey, mountpoint);
164 return gen && gen->
isok();
171 xroot->add_callback(cookie, xfullkey, callback, recurse);
177 xroot->del_callback(cookie, xfullkey, recurse);
183 xroot->add_setbool(xfullkey, flag, recurse);
189 xroot->del_setbool(xfullkey, flag, recurse);
195 xroot->mounts.hold_delta();
201 xroot->mounts.unhold_delta();
207 xroot->mounts.clear_delta();
213 xroot->mounts.flush_delta();
220 for (it.rewind(); it.next(); )
223 if (everything || !!value)
224 stream.print(
"%s = %s\n", it->fullkey(), value);
254 :
IterBase(_top), pathead(pattern.first()),
255 pattail(pattern.removefirst()), subit(NULL), it(NULL), recit(NULL)
264 if (patnext.iswild())
273 UniConf::XIter::~XIter()
279 void UniConf::XIter::cleanup()
299 void UniConf::XIter::rewind()
328 current = top[pathead];
344 inline bool UniConf::XIter::qnext()
348 bool found = subit->next();
367 void UniConf::XIter::enter(
const UniConf &child)
374 bool UniConf::XIter::next()
384 if (it && it->next())
394 if (recit && recit->next())
411 UniConf::SortedIterBase::SortedIterBase(
const UniConf &
root,
412 UniConf::SortedIterBase::Comparator comparator)
413 :
IterBase(root), xcomparator(comparator), xkeys()
418 UniConf::SortedIterBase::~SortedIterBase()
431 static UniConf::SortedIterBase::Comparator innercomparator = NULL;
435 return innercomparator(a, b) < 0;
439 void UniConf::SortedIterBase::_purge()
441 count = xkeys.size();
446 void UniConf::SortedIterBase::_rewind()
449 count = xkeys.size();
452 innercomparator = xcomparator;
453 std::sort(xkeys.begin(), xkeys.end(), wrapcomparator);
457 bool UniConf::SortedIterBase::next()
461 current = xkeys[index];
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...
bool isempty() const
Returns true if this path has zero segments (also known as root).
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.
void unmount(IUniConfGen *gen, bool commit) const
Unmounts the generator providing this key and destroys it.
UniConfKey first(int n=1) const
Returns the path formed by the n first segments of this path.
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.
bool isnull() const
returns true if this string is null
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.
void append(const UniConfKey &other)
Appends a path to this path.
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.
XIter(const UniConf &_top, const UniConfKey &pattern)
Creates a wildcard iterator.
void move(const UniConf &dst) const
Equivalent to "mv" in a standard unix filesystem.
bool exists() const
Without fetching its value, returns true if this key exists.
bool iswild() const
Returns true if the key contains a wildcard.
static UniConfKey RECURSIVE_ANY
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 ...
UniConfKey fullkey() const
Returns the full path of this node, starting at the root.
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().
RecursiveIter(const UniConf &_top)
Creates a recursive iterator over a branch.
int compareto(const UniConfKey &other) const
Compares two paths lexicographically.
An iterator that's always empty.
UniConf()
Creates a NULL UniConf handle, useful for reporting errors.
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.
bool ismountpoint() const
Determines if any generators are mounted at this key.
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
Iter(const UniConf &_top)
Creates an iterator over the direct children of a branch.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
void dump(WvStream &stream, bool everything=false) const
Prints the entire contents of this subtree to a stream.
UniConfKey subkey(const UniConfKey &key) const
If this UniConfKey is a subkey of 'key', then return the subkey portion.
virtual bool isok()=0
Determines if the generator is usable and working properly.
void flush_delta()
Flushes the list of pending notifications by sending them.
static int defcomparator(const UniConf &a, const UniConf &b)
Default comparator.
UniConfKey removefirst(int n=1) const
Returns the path formed by removing the first n segments of this path.
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...
void commit() const
Commits information about this key recursively.
void setmeint(int value) const
Stores an integer value for this key into the registry.
void del_callback(void *cookie, bool recurse=true) const
Cancels notification requested using add_callback().
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.
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.
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...