WvStreams
|
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix filesystem. More...
#include <uniconfkey.h>
Classes | |
class | Iter |
An iterator over the segments of a key. More... | |
Public Member Functions | |
UniConfKey () | |
Constructs an empty UniConfKey (the 'root'). | |
UniConfKey (WvStringParm key) | |
Constructs a UniConfKey from a string. More... | |
UniConfKey (const char *key) | |
Constructs a UniConfKey from a string. More... | |
UniConfKey (int key) | |
Constructs a UniConfKey from an int. | |
UniConfKey (const UniConfKey &other) | |
Copies a UniConfKey. More... | |
UniConfKey (const UniConfKey &path, const UniConfKey &key) | |
Constructs a UniConfKey by concatenating two keys. More... | |
void | append (const UniConfKey &other) |
Appends a path to this path. More... | |
void | prepend (const UniConfKey &other) |
Prepends a path to this path. More... | |
bool | isempty () const |
Returns true if this path has zero segments (also known as root). More... | |
bool | iswild () const |
Returns true if the key contains a wildcard. | |
bool | hastrailingslash () const |
Returns true if the key has a trailing slash. | |
int | numsegments () const |
Returns the number of segments in this path. More... | |
UniConfKey | segment (int n) const |
Returns the specified segment of the path. More... | |
UniConfKey | pop (int n=1) |
Returns the path formed by the first n segments of this path and removes them from the key. More... | |
UniConfKey | first (int n=1) const |
Returns the path formed by the n first segments of this path. More... | |
UniConfKey | last (int n=1) const |
Returns the path formed by the n last segments of this path. More... | |
UniConfKey | removefirst (int n=1) const |
Returns the path formed by removing the first n segments of this path. More... | |
UniConfKey | removelast (int n=1) const |
Returns the path formed by removing the last n segments of this path. More... | |
UniConfKey | range (int i, int j) const |
Returns a range of segments. More... | |
WvString | printable () const |
Returns the canonical string representation of the path. More... | |
operator WvString () const | |
const char * | cstr () const |
Returns a (const char *) of printable() directly. | |
UniConfKey & | operator= (const UniConfKey &other) |
Assigns this path to equal another. More... | |
int | compareto (const UniConfKey &other) const |
Compares two paths lexicographically. More... | |
bool | matches (const UniConfKey &pattern) const |
Determines if the key matches a pattern. More... | |
bool | suborsame (const UniConfKey &key) const |
Returns true if 'key' is a the same, or a subkey, of this UniConfKey. | |
bool | suborsame (const UniConfKey &key, UniConfKey &subkey) const |
UniConfKey | subkey (const UniConfKey &key) const |
If this UniConfKey is a subkey of 'key', then return the subkey portion. More... | |
bool | operator== (const UniConfKey &other) const |
Determines if two paths are equal. More... | |
bool | operator!= (const UniConfKey &other) const |
Determines if two paths are unequal. More... | |
bool | operator< (const UniConfKey &other) const |
Determines if this path precedes the other lexicographically. More... | |
Static Public Attributes | |
static UniConfKey | EMPTY |
static UniConfKey | ANY |
static UniConfKey | RECURSIVE_ANY |
Friends | |
unsigned | WvHash (const UniConfKey &k) |
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix filesystem.
The following paths are equivalent when canonicalized:
Keys that may contain slashes or nulls should be escaped in some fashion prior to constructing a UniConfKey object. Simply prefixing slashes with backslashes is inadequate because UniConfKey does not give any special meaning to backslash.
Definition at line 38 of file uniconfkey.h.
|
inline |
Constructs a UniConfKey from a string.
See the rules above for information about how the key string is canonicalized.
"key" is the key as a string
Definition at line 192 of file uniconfkey.h.
|
inline |
Constructs a UniConfKey from a string.
See the rules above for information about how the key string is canonicalized. This constructor only exists to help out the C++ compiler with its automatic type conversions.
"key" is the key as a string
Definition at line 208 of file uniconfkey.h.
|
inline |
UniConfKey::UniConfKey | ( | const UniConfKey & | path, |
const UniConfKey & | key | ||
) |
Constructs a UniConfKey by concatenating two keys.
"path" is the initial part of the new path "key" is the tail of the new path
Definition at line 99 of file uniconfkey.cc.
References hastrailingslash(), isempty(), and segment().
void UniConfKey::append | ( | const UniConfKey & | other | ) |
Appends a path to this path.
"other" is the path
Definition at line 130 of file uniconfkey.cc.
References hastrailingslash(), isempty(), and segment().
Referenced by UniConf::XIter::XIter().
void UniConfKey::prepend | ( | const UniConfKey & | other | ) |
Prepends a path to this path.
"other" is the path
Definition at line 152 of file uniconfkey.cc.
References segment().
Referenced by _UniSecureIter::value().
|
inline |
Returns true if this path has zero segments (also known as root).
Returns: numsegments() == 0
Definition at line 264 of file uniconfkey.h.
Referenced by append(), UniTempGen::get(), UniSubtreeGen::keymap(), matches(), UniTempGen::set(), UniIniGen::set(), UniConfKey(), and UniConf::XIter::XIter().
|
inline |
Returns the number of segments in this path.
The number of segments is equal to the number of slashes in the path unless the path is "/" (the root), which has zero segments.
Returns: the number of segments
Definition at line 287 of file uniconfkey.h.
Referenced by UniTransactionGen::create_value(), UniTransactionGen::gencallback(), UniWvConfGen::get(), UniTransactionGen::get(), UniTransactionGen::iterator(), UniMountGen::iterator(), UniDefGen::keymap(), last(), removelast(), UniTempGen::set(), UniWvConfGen::set(), UniRegistryGen::set(), and suborsame().
|
inline |
Returns the specified segment of the path.
"i" is the segment index Returns: the segment
Definition at line 297 of file uniconfkey.h.
References range().
Referenced by append(), UniTransactionGen::create_value(), UniTransactionGen::gencallback(), UniTransactionGen::get(), UniTransactionGen::iterator(), prepend(), and UniConfKey().
UniConfKey UniConfKey::pop | ( | int | n = 1 | ) |
Returns the path formed by the first n segments of this path and removes them from the key.
Returns: the path
Definition at line 183 of file uniconfkey.cc.
References UniConfKey().
Referenced by UniTempGen::set().
|
inline |
Returns the path formed by the n first segments of this path.
"n" is the number of segments Returns: the path
Definition at line 314 of file uniconfkey.h.
References range().
Referenced by UniTransactionGen::create_value(), UniWvConfGen::get(), UniTransactionGen::get(), UniMountGen::iterator(), matches(), UniWvConfGen::set(), UniRegistryGen::set(), suborsame(), and UniConf::XIter::XIter().
|
inline |
Returns the path formed by the n last segments of this path.
"n" is the number of segments Returns: the path
Definition at line 324 of file uniconfkey.h.
References numsegments(), and range().
Referenced by UniTempGen::get(), UniWvConfGen::get(), UniRegistryGen::get(), UniFastRegetGen::get(), UniPStoreGen::get(), UniTransactionGen::get(), UniTransactionGen::iterator(), UniMountGen::iterator(), UniConf::key(), UniWvConfGen::set(), UniRegistryGen::set(), and UniPStoreGen::set().
|
inline |
Returns the path formed by removing the first n segments of this path.
"n" is the number of segments Returns: the path
Definition at line 335 of file uniconfkey.h.
References range().
Referenced by matches(), and UniConf::XIter::XIter().
|
inline |
Returns the path formed by removing the last n segments of this path.
"n" is the number of segments Returns: the path
Definition at line 346 of file uniconfkey.h.
References numsegments(), and range().
Referenced by UniSecureGen::exists(), UniFastRegetGen::get(), UniConf::parent(), and UniFileSystemGen::set().
UniConfKey UniConfKey::range | ( | int | i, |
int | j | ||
) | const |
Returns a range of segments.
"i" is the first segment index, beginning if <= 0 "j" is the last segment index, end if >= numsegments() Returns: the path, empty if j <= i
Definition at line 200 of file uniconfkey.cc.
References UniConfKey().
Referenced by first(), last(), removefirst(), removelast(), and segment().
WvString UniConfKey::printable | ( | ) | const |
Returns the canonical string representation of the path.
If the UniConfKey was constructed in part or whole from strings, then the string returned here will have the same case information as those strings but the arrangement of slashes may differ. That is, the identity UniConfKey(string).printable() == string does not hold.
Returns: the path as a string
Definition at line 212 of file uniconfkey.cc.
References WvBufBase< unsigned char >::getstr(), and WvBufBase< unsigned char >::putstr().
Referenced by cstr(), UniRetryGen::exists(), UniPStoreGen::get(), UniRetryGen::get(), UniRegistryGen::set(), UniPStoreGen::set(), UniReplicateGen::set(), and subkey().
|
inline |
Assigns this path to equal another.
"other" is the other path
Definition at line 384 of file uniconfkey.h.
int UniConfKey::compareto | ( | const UniConfKey & | other | ) | const |
Compares two paths lexicographically.
Uses case-insensitive matching on the path string to produce a total ordering of all paths. "other" is the other path Returns: 0 if *this == other, < 0 if *this < other, else > 0
Definition at line 235 of file uniconfkey.cc.
Referenced by UniConf::SortedIterBase::defcomparator(), operator!=(), operator<(), and operator==().
bool UniConfKey::matches | ( | const UniConfKey & | pattern | ) | const |
Determines if the key matches a pattern.
Patterns are simply keys that may have path segments consiting entirely of "*". Optional path segments are indicated by the segment "..." which matches zero or more segments.
Using wildcards to represent part of a segment is not supported yet. "pattern" is the pattern Returns: true if the key matches, false otherwise
Definition at line 256 of file uniconfkey.cc.
References ANY, first(), isempty(), matches(), RECURSIVE_ANY, and removefirst().
Referenced by matches().
UniConfKey UniConfKey::subkey | ( | const UniConfKey & | key | ) | const |
If this UniConfKey is a subkey of 'key', then return the subkey portion.
Behaviour is undefined when this is not the same. Use suborsame() to check.
Definition at line 324 of file uniconfkey.cc.
References printable(), and suborsame().
Referenced by UniConf::fullkey().
|
inline |
Determines if two paths are equal.
"other" is the other path Returns: true in that case
Definition at line 435 of file uniconfkey.h.
References compareto().
|
inline |
Determines if two paths are unequal.
"other" is the other path Returns: true in that case
Definition at line 443 of file uniconfkey.h.
References compareto().
|
inline |
Determines if this path precedes the other lexicographically.
"other" is the other path Returns: true in that case
Definition at line 451 of file uniconfkey.h.
References compareto().
|
static |
represents "" (root)
Definition at line 171 of file uniconfkey.h.
Referenced by UniConfGen::NullIter::key(), UniIniGen::refresh(), UniConf::root(), UniIniGen::set(), and UniIniGen::UniIniGen().
|
static |
|
static |