Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

UniConfKey Class Reference

#include <uniconfkey.h>

Collaboration diagram for UniConfKey:

[legend]
List of all members.

Detailed Description

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 36 of file uniconfkey.h.

Public Member Functions

 UniConfKey ()
 Constructs an empty UniConfKey (the 'root').

 UniConfKey (WvStringParm key)
 Constructs a UniConfKey from a string.

 UniConfKey (const char *key)
 Constructs a UniConfKey from a string.

 UniConfKey (int key)
 Constructs a UniConfKey from an int.

 UniConfKey (const UniConfKey &other)
 Copies a UniConfKey.

 UniConfKey (const UniConfKey &path, const UniConfKey &key)
 Constructs a UniConfKey by concatenating two keys.

void append (const UniConfKey &other)
 Appends a path to this path.

void prepend (const UniConfKey &other)
 Prepends a path to this path.

bool isempty () const
 Returns true if this path has zero segments (also known as root).

bool iswild () const
 Returns true if the key contains a wildcard.

int numsegments () const
 Returns the number of segments in this path.

UniConfKey segment (int i) const
 Returns the specified segment of the path.

UniConfKey first (int n=1) const
 Returns the path formed by the n first segments of this path.

UniConfKey last (int n=1) const
 Returns the path formed by the n last segments of this path.

UniConfKey removefirst (int n=1) const
 Returns the path formed by removing the first n segments of this path.

UniConfKey removelast (int n=1) const
 Returns the path formed by removing the last n segments of this path.

UniConfKey range (int i, int j) const
 Returns a range of segments.

WvString printable () const
 Returns the canonical string representation of the path.

 operator WvString () const
UniConfKeyoperator= (const UniConfKey &other)
 Assigns this path to equal another.

int compareto (const UniConfKey &other) const
 Compares two paths lexicographically.

bool matches (const UniConfKey &pattern) const
 Determines if the key matches a pattern.

bool suborsame (const UniConfKey &key) const
 Returns true if this key is either the same key as the key specified or a subkey of that key.

bool operator== (const UniConfKey &other) const
 Determines if two paths are equal.

bool operator!= (const UniConfKey &other) const
 Determines if two paths are unequal.

bool operator< (const UniConfKey &other) const
 Determines if this path precedes the other lexicographically.


Static Public Attributes

UniConfKey EMPTY
UniConfKey ANY
UniConfKey RECURSIVE_ANY

Protected Member Functions

void init (WvStringParm key)


Constructor & Destructor Documentation

UniConfKey::UniConfKey  ) 
 

Constructs an empty UniConfKey (the 'root').

Definition at line 18 of file uniconfkey.cc.

UniConfKey::UniConfKey WvStringParm  key  )  [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 56 of file uniconfkey.h.

References init(), and WvStringParm.

UniConfKey::UniConfKey const char *  key  )  [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 68 of file uniconfkey.h.

References init().

UniConfKey::UniConfKey int  key  )  [inline]
 

Constructs a UniConfKey from an int.

Definition at line 72 of file uniconfkey.h.

References init().

UniConfKey::UniConfKey const UniConfKey other  ) 
 

Copies a UniConfKey.

"other" is the key to copy

Definition at line 62 of file uniconfkey.cc.

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 67 of file uniconfkey.cc.

References path.


Member Function Documentation

void UniConfKey::append const UniConfKey other  ) 
 

Appends a path to this path.

"other" is the path

Definition at line 78 of file uniconfkey.cc.

References path.

Referenced by UniConfDaemonConn::deltacallback().

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 209 of file uniconfkey.cc.

References path.

Referenced by operator<(), and operator==().

UniConfKey UniConfKey::first int  n = 1  )  const
 

Returns the path formed by the n first segments of this path.

"n" is the number of segments Returns: the path

Definition at line 130 of file uniconfkey.cc.

References range().

Referenced by UniMountTree::MountIter::head(), matches(), UniWvConfGen::set(), UniRegistryGen::set(), suborsame(), and UniRegistryGen::UniRegistryGen().

void UniConfKey::init WvStringParm  key  )  [protected]
 

Definition at line 25 of file uniconfkey.cc.

References WvString::edit(), WvFastString::isnull(), WvFastString::setsize(), and WvStringParm.

Referenced by UniConfKey().

bool UniConfKey::isempty  )  const
 

Returns true if this path has zero segments (also known as root).

Returns: numsegments() == 0

Definition at line 96 of file uniconfkey.cc.

Referenced by UniHashTreeBase::_findchild(), UniPermGen::getgroup(), UniPermGen::getowner(), matches(), and UniIniGen::refresh().

bool UniConfKey::iswild  )  const
 

Returns true if the key contains a wildcard.

Definition at line 102 of file uniconfkey.cc.

UniConfKey UniConfKey::last int  n = 1  )  const
 

Returns the path formed by the n last segments of this path.

"n" is the number of segments Returns: the path

Definition at line 136 of file uniconfkey.cc.

References numsegments(), and range().

Referenced by UniRegistryGen::get(), UniPStoreGen::get(), UniClientGen::RemoteKeyIter::key(), UniWvConfGen::set(), UniRegistryGen::set(), and UniPStoreGen::set().

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 215 of file uniconfkey.cc.

References ANY, first(), isempty(), RECURSIVE_ANY, and removefirst().

int UniConfKey::numsegments  )  const
 

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 109 of file uniconfkey.cc.

Referenced by last(), removelast(), UniConfKey::Iter::rewind(), UniWvConfGen::set(), UniRegistryGen::set(), suborsame(), and UniRegistryGen::UniRegistryGen().

UniConfKey::operator WvString  )  const [inline]
 

Definition at line 177 of file uniconfkey.h.

References printable().

bool UniConfKey::operator!= const UniConfKey other  )  const [inline]
 

Determines if two paths are unequal.

"other" is the other path Returns: true in that case

Definition at line 227 of file uniconfkey.h.

bool UniConfKey::operator< const UniConfKey other  )  const [inline]
 

Determines if this path precedes the other lexicographically.

"other" is the other path Returns: true in that case

Definition at line 235 of file uniconfkey.h.

References compareto().

UniConfKey & UniConfKey::operator= const UniConfKey other  ) 
 

Assigns this path to equal another.

"other" is the other path

Definition at line 202 of file uniconfkey.cc.

References path.

bool UniConfKey::operator== const UniConfKey other  )  const [inline]
 

Determines if two paths are equal.

"other" is the other path Returns: true in that case

Definition at line 219 of file uniconfkey.h.

References compareto().

void UniConfKey::prepend const UniConfKey other  ) 
 

Prepends a path to this path.

"other" is the path

Definition at line 87 of file uniconfkey.cc.

References path.

Referenced by UniHashTreeBase::_fullkey(), and UniIniGen::refresh().

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 196 of file uniconfkey.cc.

Referenced by UniRegistryGen::get(), UniPStoreGen::get(), operator WvString(), UniRegistryGen::set(), UniPStoreGen::set(), and UniRegistryGen::UniRegistryGen().

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 154 of file uniconfkey.cc.

References WvString::edit(), path, and WvFastString::setsize().

Referenced by first(), last(), removefirst(), removelast(), segment(), and UniRegistryGen::UniRegistryGen().

UniConfKey UniConfKey::removefirst int  n = 1  )  const
 

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 142 of file uniconfkey.cc.

References range().

Referenced by matches(), and UniMountTree::MountIter::tail().

UniConfKey UniConfKey::removelast int  n = 1  )  const
 

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 148 of file uniconfkey.cc.

References numsegments(), and range().

Referenced by UniSecureGen::exists(), UniPermGen::getgroup(), and UniPermGen::getowner().

UniConfKey UniConfKey::segment int  i  )  const
 

Returns the specified segment of the path.

"i" is the segment index Returns: the segment

Definition at line 124 of file uniconfkey.cc.

References range().

Referenced by UniConfKey::Iter::next().

bool UniConfKey::suborsame const UniConfKey key  )  const
 

Returns true if this key is either the same key as the key specified or a subkey of that key.

Definition at line 253 of file uniconfkey.cc.

References first(), and numsegments().

Referenced by UniMountGen::haschildren(), and UniMountGen::unmount().


Member Data Documentation

UniConfKey UniConfKey::ANY [static]
 

represents "*"

Referenced by matches().

UniConfKey UniConfKey::EMPTY [static]
 

represents "" (root)

Definition at line 13 of file uniconfkey.cc.

UniConfKey UniConfKey::RECURSIVE_ANY [static]
 

represents "..."

Referenced by matches().


The documentation for this class was generated from the following files:
Generated on Sat Mar 13 15:00:15 2004 for WvStreams by doxygen 1.3.6-20040222