11IUniConfGen::~IUniConfGen()
28 assert(cblist.isempty());
40 assert(hold_nesting > 0);
41 if (hold_nesting == 1)
55 UniConfPairList::Iter it(deltas);
79 if (hold_nesting == 0)
93void UniConfGen::setv_naive(
const UniConfPairList &pairs)
95 UniConfPairList::Iter pair(pairs);
96 for (pair.rewind(); pair.next(); )
97 set(pair->key(), pair->value());
103 bool children =
false;
111 if (it->
next()) children =
true;
129 const char *strs[] = {
130 "true",
"yes",
"on",
"enabled",
131 "false",
"no",
"off",
"disabled"
133 const size_t numtruestrs = 4;
139 int num = strtol(value.
cstr(), &end, 0);
140 if (end != value.
cstr())
144 for (
size_t i = 0; i <
sizeof(strs) /
sizeof(
const char*); ++i)
145 if (strcasecmp(value, strs[i]) == 0)
146 return i < numtruestrs;
159 const UniConfGenCallback &callback)
161 cblist.add(callback, cookie);
172class _UniConfGenRecursiveIter :
public IUniConfGen::Iter
187 virtual ~_UniConfGenRecursiveIter() { }
189 virtual void rewind()
199 itlist.prepend(subi,
true);
214 Iter *newsub = gen->iterator(
UniConfKey(top, newkey));
217 current.append(subkey);
220 itlist.prepend(newsub,
true);
235 current = current.removelast();
247 if (!itlist.isempty())
248 return UniConfKey(current, itlist.first()->key());
The basic interface which is included by all other XPLC interfaces and objects.
An abstract data container that backs a UniConf tree.
virtual Iter * iterator(const UniConfKey &key)=0
Returns an iterator over the children of the specified key.
An abstract iterator over keys and values in a generator.
virtual bool next()=0
Seeks to the next element in the sequence.
virtual void rewind()=0
Rewinds the iterator.
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
void dispatch_delta(const UniConfKey &key, WvStringParm value)
Immediately sends notification that a key has possibly changed.
void hold_delta()
Pauses notifications until matched with a call to unhold_delta().
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
virtual ~UniConfGen()
Destroys the UniConfGen and may discard uncommitted data.
virtual void set(const UniConfKey &key, WvStringParm value)=0
Stores a string value for a key into the registry.
UniConfGen()
Creates a UniConfGen object.
void delta(const UniConfKey &key, WvStringParm value)
Call this when a key's value or children have possibly changed.
virtual WvString get(const UniConfKey &key)=0
Fetches a string value for a key from the registry.
virtual Iter * recursiveiterator(const UniConfKey &key)
Like iterator(), but the returned iterator is recursive, that is, it will return children of the imme...
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
virtual void add_callback(void *cookie, const UniConfGenCallback &callback)
Adds a callback for change notification.
virtual int str2int(WvStringParm s, int defvalue) const
Converts a string to an integer.
virtual void del_callback(void *cookie)
Removes a callback for change notification.
void flush_delta()
Flushes the list of pending notifications by sending them.
virtual Iter * iterator(const UniConfKey &key)=0
Returns an iterator over the children of the specified key.
void clear_delta()
Clears the list of pending notifications without sending them.
virtual bool isok()
Determines if the generator is usable and working properly.
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Represents a simple key-value pair.
bool isnull() const
returns true if this string is null
const char * cstr() const
return a (const char *) for this string.
void rewind()
Rewinds the iterator to make it point to an imaginary element preceeding the first element of the lis...
WvLink * next()
Moves the iterator along the list to point to the next element.
The iterator type for linked lists.
void xunlink(bool destroy=true)
Unlinks the current element from the list but unlike unlink() automatically returns the iterator to t...
A linked list container class.
WvString is an implementation of a simple and efficient printable-string class.
#define UUID_MAP_END
Marks the end of an interface map.
#define UUID_MAP_BEGIN(component)
Start the interface map for "component".
#define UUID_MAP_ENTRY(iface)
Add an entry to an interface map.