YCPListRep Class Reference

List of YCPValues that is a value itself In YCP there is no distinction between lists, tuples and structs. All these kind of complex data is represented by YCPListRep. The type of a list is constructed by the valuetype list, which has a list of types as arguments. The list's type is implicitely given through the fact that its valuetype is list and trough the types of its elements. There is no restriction about the types of a list's elements. If you want to declare a variable or parameter to be a list of a certain signature, you can use the RangeRestrictor YCP_RRList or YCP_RRTyple. object. More...

#include <YCPList.h>

Inheritance diagram for YCPListRep:

YCPValueRep YCPElementRep

List of all members.

Public Member Functions

int size () const
void reserve (int size)
bool isEmpty () const
void add (const YCPValue &value)
void set (const int n, const YCPValue &value)
void remove (const int n)
void swap (int x, int y)
bool contains (const YCPValue &value) const
void sortlist ()
void lsortlist ()
void fsortlist (const YCPCodeCompare &cmp)
virtual const YCPElementRepshallowCopy () const
YCPList functionalAdd (const YCPValue &value, bool prepend=false) const
YCPValue value (int n) const
YCPListIterator begin () const
YCPListIterator end () const
YCPOrder compare (const YCPList &v) const
string toString () const
std::ostream & toStream (std::ostream &str) const
std::ostream & toXml (std::ostream &str, int indent) const
YCPValueType valuetype () const
string commaList () const

Protected Member Functions

 YCPListRep ()
 ~YCPListRep ()

Private Attributes

YCPValueList elements

Friends

class YCPList


Detailed Description

List of YCPValues that is a value itself In YCP there is no distinction between lists, tuples and structs. All these kind of complex data is represented by YCPListRep. The type of a list is constructed by the valuetype list, which has a list of types as arguments. The list's type is implicitely given through the fact that its valuetype is list and trough the types of its elements. There is no restriction about the types of a list's elements. If you want to declare a variable or parameter to be a list of a certain signature, you can use the RangeRestrictor YCP_RRList or YCP_RRTyple. object.

Constructor & Destructor Documentation

YCPListRep::YCPListRep (  )  [protected]

Creates a new and empty list of type [ value ]

Referenced by shallowCopy().

YCPListRep::~YCPListRep (  )  [inline, protected]

Cleans up.


Member Function Documentation

int YCPListRep::size (  )  const

Returns the number of elements in the list.

References elements.

Referenced by compare(), functionalAdd(), remove(), set(), shallowCopy(), swap(), and value().

void YCPListRep::reserve ( int  size  ) 

Reserves a number of elements in the list.

References elements.

Referenced by shallowCopy().

bool YCPListRep::isEmpty (  )  const

Returns true, if this list is empty.

References elements.

void YCPListRep::add ( const YCPValue value  ) 

Appends a value to the list. Takes over the memory management of that value. Use YCPElementRep, if you need it yourself.

References elements.

Referenced by shallowCopy().

void YCPListRep::set ( const int  n,
const YCPValue value 
)

Sets a value in the list. Takes over the memory management of that value. Use YCPElementRep, if you need it yourself.

References elements, and size().

void YCPListRep::remove ( const int  n  ) 

Remove an element from the list.

References elements, size(), and ycp2error.

void YCPListRep::swap ( int  x,
int  y 
)

Exchanges the elements at the indices x and y. This function changes the list.

References elements, and size().

bool YCPListRep::contains ( const YCPValue value  )  const

Returns true if the list contains the value, otherwise false.

References elements.

void YCPListRep::sortlist (  ) 

Sorts the list. This function changes the list.

References compareYCP(), and elements.

void YCPListRep::lsortlist (  ) 

Sorts the list according to the locale. This function changes the list.

References elements, and lcompareYCP().

void YCPListRep::fsortlist ( const YCPCodeCompare cmp  ) 

Sorts the list according to a comparison function. This function changes the list.

References elements.

const YCPElementRep * YCPListRep::shallowCopy (  )  const [virtual]

Creates a copy of this list, i.e. creates a new list with the same elements as this one. The elements themselves are not copied, but only cloned!

Reimplemented from YCPElementRep.

References add(), reserve(), size(), toString(), value(), y2debug, and YCPListRep().

YCPList YCPListRep::functionalAdd ( const YCPValue value,
bool  prepend = false 
) const

Creates a new list, that is identical to this one with but one new value appended. Doesn't change this list.

Parameters:
value the value to add
append determinates whether append to the end of the list or prepend.

References YCPList::add(), YCPList::reserve(), size(), and value().

YCPValue YCPListRep::value ( int  n  )  const

Returns the n'th value of the list whereas 0 <= n < size().

References elements, size(), and ycp2error.

Referenced by compare(), functionalAdd(), and shallowCopy().

YCPListIterator YCPListRep::begin (  )  const

Returns a bidirectional STL iterator for the YCPList that is positioned at the first value pair in the list. (suitable for iterating over all entries)

References elements.

YCPListIterator YCPListRep::end (  )  const

Returns a bidirectional STL iterator for the YCPList that is positioned BEHIND the last value pair in the list. (suitable for iterating over all entries)

References elements.

YCPOrder YCPListRep::compare ( const YCPList v  )  const

Compares two YCPLists for equality, greaterness or smallerness. The relation is lexicographically with respect to the list elements, i.e. elementwise comparison up to the shorter length.

(( [ ] == [ ] ) == true ) (( [ 1, 2, 3 ] > [ 1, 2 ] ) == true ) (( [ 1, 2 ] > [ 1, 1, 1 ] ) == true ) (( [ 1, "string" ] > [ 1, 1, 1 ] ) == true ) (( [ 1, "string_long" ] > [ 1, "string", 1 ] ) == true ) (( [ 1 ] < [ { integer number = 2; return number; } ] ) == true ) int/int (( [ 1 ] > [ { integer number = 2; } ] ) == true ) int/nil

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 YCPList::size(), size(), YCPList::value(), value(), YO_EQUAL, YO_GREATER, and YO_LESS.

string YCPListRep::toString ( void   )  const [virtual]

Returns an ASCII representation of the list. Lists are denoted by comma separated values enclosed by square brackets.

Implements YCPElementRep.

References commaList().

Referenced by shallowCopy().

std::ostream & YCPListRep::toStream ( std::ostream &  str  )  const [virtual]

Output value as bytecode to stream

Implements YCPElementRep.

References elements, Bytecode::writeInt32(), Bytecode::writeValue(), and y2error.

std::ostream & YCPListRep::toXml ( std::ostream &  str,
int  indent 
) const [virtual]

Implements YCPValueRep.

References elements.

YCPValueType YCPListRep::valuetype (  )  const [virtual]

Returns YT_LIST. See YCPValueRep::type.

Implements YCPValueRep.

References YT_LIST.

string YCPListRep::commaList (  )  const

Helper function used by this class and by YCPTermRep that creates a comma separated string representation of the members string representations.

References elements.

Referenced by toString().


Friends And Related Function Documentation

friend class YCPList [friend]


Member Data Documentation


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

Generated on Wed Dec 3 07:24:56 2008 for yast2-core by  doxygen 1.5.6