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);
189 virtual void rewind()
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.
virtual WvString get(const UniConfKey &key)=0
Fetches a string value for a key from the registry.
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().
virtual void add_callback(void *cookie, const UniConfGenCallback &callback)
Adds a callback for change notification.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
virtual ~UniConfGen()
Destroys the UniConfGen and may discard uncommitted data.
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 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...
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
void append(const UniConfKey &other)
Appends a path to this path.
Represents a simple key-value pair.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
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.
bool isempty() const
Quickly determines if the list is empty.
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.
void prepend(T *data, bool autofree, const char *id=NULL)
Prepends the element to the beginning of the list.
T * first() const
Returns a pointer to the first element in the linked list.
void zap(bool destroy=true)
Clears the linked list.
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.