#include <YCPPath.h>
Classes | |
struct | Component |
Public Member Functions | |
bool | isRoot () const |
YCPValue | select (const YCPValue &val) |
void | append (const YCPPath &p) |
void | append (string c) |
long | length () const |
bool | isPrefixOf (const YCPPath &p) const |
YCPPath | at (long index) const |
YCPPath | prefix (long index) const |
string | component_str (long index) const |
YCPOrder | compare (const YCPPath &v) const |
string | toString () const |
std::ostream & | toStream (std::ostream &str) const |
std::ostream & | toXml (std::ostream &str, int indent) const |
YCPValueType | valuetype () const |
Protected Member Functions | |
YCPPathRep () | |
YCPPathRep (const char *r) | |
void | append (const Component &c) |
Private Attributes | |
vector< Component > | components |
Friends | |
class | YCPPath |
YCPSyntax: A single dot or any sequence of dot-symbol pairs. The symbols may consist of digits, letters and underscores.
. .etc .1.2.127 .etc.fstab.7
YCPPathRep::YCPPathRep | ( | ) | [protected] |
Creates a new root path. The ASCII representation of the root path is a single dot.
YCPPathRep::YCPPathRep | ( | const char * | r | ) | [protected] |
Creates a new path from its ASCII representation.
References components, and ycp2error.
void YCPPathRep::append | ( | string | c | ) |
Appends a component to the path.
References SymbolEntry::_nameHash, YCPPathRep::Component::complex, YCPPathRep::Component::component, and components.
void YCPPathRep::append | ( | const YCPPath & | p | ) |
Append path to this
References components.
void YCPPathRep::append | ( | const Component & | c | ) | [protected] |
YCPPath YCPPathRep::at | ( | long | index | ) | const |
Returns a postfix of the path. You must check, that the index you give is 0 <= i < length.
References components, and length().
Compares two YCPPaths for equality, greaterness or smallerness.
v | value to compare against |
References components, YO_EQUAL, YO_GREATER, and YO_LESS.
string YCPPathRep::component_str | ( | long | index | ) | const |
Returns one component of the path as string. No error check is done for index. You must check yourself that 0 < index < length.
References components.
Referenced by isPrefixOf().
bool YCPPathRep::isPrefixOf | ( | const YCPPath & | p | ) | const |
Checks if this path is a prefix of path p. This holds, if this path has size n and the first n components of p are exactly those of this path. The root path is prefix of any path. That path .a.b is a prefix of .a.b.c but not of the path .a.bc
References component_str(), and length().
bool YCPPathRep::isRoot | ( | ) | const |
Returns true, if this is a root path.
References components.
long YCPPathRep::length | ( | ) | const |
Returns the length of the path, i.e. the number of components. The root path has length 0.
References components.
Referenced by at(), and isPrefixOf().
YCPPath YCPPathRep::prefix | ( | long | index | ) | const |
Returns a prefix of the path. You must check, that the index you give is 0 <= i < length. Informally, p == p.prefix(i) + p.at(i);
References components.
Selects the subtree of a YCPValueRep, that is denoted by this path. If this is the root path, select(v) simply returns v. If v is a list or a term, the first component of the path selects an element of the list and evalutes recursivly remainingpath->select(list_element). Returns a 0 pointer, if the path was incorrect.
std::ostream & YCPPathRep::toStream | ( | std::ostream & | str | ) | const [virtual] |
Output value as bytecode to stream
Implements YCPElementRep.
References components, toString(), Bytecode::writeInt32(), and Bytecode::writeString().
Referenced by toXml().
string YCPPathRep::toString | ( | void | ) | const [virtual] |
Returns a string representation of this object, that may be parsed by the YCP parser. A path is denoted by a list symbols or number separated by dots, e.g. . or .12 or .eth0.12
Implements YCPElementRep.
References components.
Referenced by toStream(), and toXml().
std::ostream & YCPPathRep::toXml | ( | std::ostream & | str, | |
int | indent | |||
) | const [virtual] |
YCPValueType YCPPathRep::valuetype | ( | ) | const [virtual] |
friend class YCPPath [friend] |
vector<Component> YCPPathRep::components [private] |
Referenced by append(), at(), compare(), component_str(), isRoot(), length(), prefix(), toStream(), toString(), toXml(), and YCPPathRep().