7 #include "uniconfgen.h"
11 IUniConfGen::~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)
93 void 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()
225 for (i.rewind(); i.next(); )
virtual bool isok()
Determines if the generator is usable and working properly.
void dispatch_delta(const UniConfKey &key, WvStringParm value)
Immediately sends notification that a key has possibly changed.
virtual ~UniConfGen()
Destroys the UniConfGen and may discard uncommitted data.
virtual WvString get(const UniConfKey &key)=0
Fetches a string value for a key from the registry.
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
#define UUID_MAP_ENTRY(iface)
Add an entry to an interface map.
virtual int str2int(WvStringParm s, int defvalue) const
Converts a string to an integer.
#define UUID_MAP_BEGIN(component)
Start the interface map for "component".
virtual Iter * recursiveiterator(const UniConfKey &key)
Like iterator(), but the returned iterator is recursive, that is, it will return children of the imme...
virtual WvString get(const UniConfKey &key)=0
Fetches a string value for a key from the registry.
T * first() const
Returns a pointer to the first element in the linked list.
void unhold_delta()
Resumes notifications when each hold_delta() has been matched.
WvString is an implementation of a simple and efficient printable-string class.
bool isempty() const
Quickly determines if the list is empty.
An abstract data container that backs a UniConf tree.
bool isnull() const
returns true if this string is null
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
virtual void set(const UniConfKey &key, WvStringParm value)=0
Stores a string value for a key into the registry.
#define UUID_MAP_END
Marks the end of an interface map.
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
void delta(const UniConfKey &key, WvStringParm value)
Call this when a key's value or children have possibly changed.
void clear_delta()
Clears the list of pending notifications without sending them.
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
virtual void rewind()=0
Rewinds the iterator.
void zap(bool destroy=true)
Clears the linked list.
virtual Iter * iterator(const UniConfKey &key)=0
Returns an iterator over the children of the specified key.
virtual bool next()=0
Seeks to the next element in the sequence.
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.
virtual void add_callback(void *cookie, const UniConfGenCallback &callback)
Adds a callback for change notification.
UniConfGen()
Creates a UniConfGen object.
Represents a simple key-value pair.
virtual void del_callback(void *cookie)
Removes a callback for change notification.
void hold_delta()
Pauses notifications until matched with a call to unhold_delta().
void append(const UniConfKey &other)
Appends a path to this path.
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
void prepend(T *data, bool autofree, const char *id=NULL)
Prepends the element to the beginning of the list.
An abstract iterator over keys and values in a generator.