11 #include "wvlinklist.h"
47 Segment(WvStringParm str) :
48 WvString((!str)? WvString::empty: str)
51 Segment(
const Segment &
segment) :
58 return *
this ==
"*" || *
this ==
"...";
67 SegmentVector(
int size) :
70 vec(
new Segment[_size])
78 void resize(
int size,
int shift = 0)
84 for (
int i=_used-1; i>=0; --i)
85 vec[i+shift] = vec[i];
90 Segment *old_vec = vec;
91 vec =
new Segment[size];
94 int limit = size-shift;
99 for (
int i=0; i<limit; ++i)
100 vec[i+shift] = old_vec[i];
123 void append(WvStringParm
string)
127 void replace(
int index,
const Segment &
segment)
133 void replace(
int index, WvStringParm
string)
135 replace(index, Segment(
string));
137 const Segment &operator [](
int index)
const
145 SegmentVector segments;
148 Store(
int size,
int _ref_count, WvStringParm key = WvString::null);
154 static Store EMPTY_store;
155 static Store ANY_store;
156 static Store RECURSIVE_ANY_store;
158 UniConfKey(Store *_store,
int _left,
int _right) :
193 store(new Store(4, 1, key)),
195 right(store->segments.used())
211 right(store->segments.used())
219 right(store->segments.used())
244 if (--store->ref_count == 0)
266 return right == left;
275 return right > left && !store->segments[right-1];
299 return range(n, n + 1);
337 return range(n, INT_MAX);
386 if (--store->ref_count == 0)
477 {
return seg >= 0 && seg < max; }
480 { seg++; curseg = key.
segment(seg);
return cur(); }
488 #endif // __UNICONFKEY_H
UniConfKey(WvStringParm key)
Constructs a UniConfKey from a string.
UniConfKey removefirst(int n=1) const
Returns the path formed by removing the first n segments of this path.
UniConfKey pop(int n=1)
Returns the path formed by the first n segments of this path and removes them from the key.
int compareto(const UniConfKey &other) const
Compares two paths lexicographically.
UniConfKey(const char *key)
Constructs a UniConfKey from a string.
bool operator==(const UniConfKey &other) const
Determines if two paths are equal.
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
bool operator<(const UniConfKey &other) const
Determines if this path precedes the other lexicographically.
void prepend(const UniConfKey &other)
Prepends a path to this path.
WvString printable() const
Returns the canonical string representation of the path.
UniConfKey subkey(const UniConfKey &key) const
If this UniConfKey is a subkey of 'key', then return the subkey portion.
UniConfKey(const UniConfKey &other)
Copies a UniConfKey.
WvString is an implementation of a simple and efficient printable-string class.
const char * cstr() const
Returns a (const char *) of printable() directly.
bool matches(const UniConfKey &pattern) const
Determines if the key matches a pattern.
UniConfKey(int key)
Constructs a UniConfKey from an int.
An iterator over the segments of a key.
bool operator!=(const UniConfKey &other) const
Determines if two paths are unequal.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
bool suborsame(const UniConfKey &key) const
Returns true if 'key' is a the same, or a subkey, of this UniConfKey.
bool isempty() const
Returns true if this path has zero segments (also known as root).
UniConfKey first(int n=1) const
Returns the path formed by the n first segments of this path.
UniConfKey range(int i, int j) const
Returns a range of segments.
#define deletev
Remplacement for delete[].
bool hastrailingslash() const
Returns true if the key has a trailing slash.
UniConfKey segment(int n) const
Returns the specified segment of the path.
UniConfKey last(int n=1) const
Returns the path formed by the n last segments of this path.
bool iswild() const
Returns true if the key contains a wildcard.
UniConfKey()
Constructs an empty UniConfKey (the 'root').
int numsegments() const
Returns the number of segments in this path.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
UniConfKey & operator=(const UniConfKey &other)
Assigns this path to equal another.
void append(const UniConfKey &other)
Appends a path to this path.
static UniConfKey RECURSIVE_ANY