YCPPathRep Class Reference

YCPValueRep representing a data path A YCP path describes a subtree in a YCP data structure. Non-leaf-nodes are values of type list and term. A path is a list of path components. A path component is a symbol or a number. More...

#include <YCPPath.h>

Inheritance diagram for YCPPathRep:
YCPValueRep YCPElementRep

List of all members.

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< Componentcomponents

Friends

class YCPPath

Detailed Description

YCPValueRep representing a data path A YCP path describes a subtree in a YCP data structure. Non-leaf-nodes are values of type list and term. A path is a list of path components. A path component is a symbol or a number.

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

Constructor & Destructor Documentation

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.


Member Function Documentation

void YCPPathRep::append ( string  c  ) 
void YCPPathRep::append ( const YCPPath p  ) 

Append path to this

References components.

void YCPPathRep::append ( const Component c  )  [protected]

Appends component to path.

References components.

Referenced by YCPPath::YCPPath().

YCPPath YCPPathRep::at ( long  index  )  const

Returns a postfix of the path. You must check, that the index you give is 0 <= i < length.

Returns:
Postfix path.

References components, and length().

YCPOrder YCPPathRep::compare ( const YCPPath v  )  const

Compares two YCPPaths for equality, greaterness or smallerness.

Parameters:
v value to compare against
Returns:
YO_LESS, if this is smaller than v, YO_EQUAL, if this is equal to v, YO_GREATER, if this is greater to v

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);

Returns:
Prefix path.

References components.

YCPValue YCPPathRep::select ( const YCPValue val  ) 

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]

Returns YT_PATH. See YCPValueRep::valuetype.

Implements YCPValueRep.

References YT_PATH.


Friends And Related Function Documentation

friend class YCPPath [friend]

Member Data Documentation

vector<Component> YCPPathRep::components [private]

The documentation for this class was generated from the following files:

Generated on a sunny day for yast2-core by doxygen 1.6.3