yast2-core
|
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>
Public Member Functions | |
int | size () const |
void | reserve (int size) |
bool | isEmpty () const |
void | add (const YCPValue &value) |
void | push_back (const YCPValue &value) |
void | set (const int n, const YCPValue &value) |
void | remove (const int n) |
void | reverse () |
void | swap (int x, int y) |
bool | contains (const YCPValue &value) const |
void | sortlist () |
void | lsortlist () |
void | fsortlist (const YCPCodeCompare &cmp) |
virtual const YCPElementRep * | shallowCopy () const |
YCPList | functionalAdd (const YCPValue &value, bool prepend=false) const |
YCPValue | value (int n) const |
const_iterator | begin () const |
const_iterator | 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 |
![]() | |
const char * | valuetype_str () const |
bool | isVoid () const |
bool | isBoolean () const |
bool | isInteger () const |
bool | isFloat () const |
bool | isString () const |
bool | isByteblock () const |
bool | isPath () const |
bool | isSymbol () const |
bool | isList () const |
bool | isTerm () const |
bool | isMap () const |
bool | isCode () const |
bool | isBreak () const |
bool | isReturn () const |
bool | isEntry () const |
bool | isReference () const |
bool | isExternal () const |
YCPVoid | asVoid () const |
YCPBoolean | asBoolean () const |
YCPInteger | asInteger () const |
YCPFloat | asFloat () const |
YCPString | asString () const |
YCPByteblock | asByteblock () const |
YCPPath | asPath () const |
YCPSymbol | asSymbol () const |
YCPList | asList () const |
YCPTerm | asTerm () const |
YCPMap | asMap () const |
YCPCode | asCode () const |
YCPEntry | asEntry () const |
YCPReference | asReference () const |
YCPExternal | asExternal () const |
bool | equal (const YCPValue &) const |
YCPOrder | compare (const YCPValue &v, bool rl=false) const |
![]() | |
YCPValue | asValue () const |
Protected Types | |
typedef YCPValueList::iterator | iterator |
typedef YCPValueList::const_iterator | const_iterator |
typedef YCPValueList::value_type | value_type |
typedef YCPValueList::const_reference | const_reference |
Protected Member Functions | |
YCPListRep () | |
~YCPListRep () | |
![]() | |
YCPElementRep () | |
virtual | ~YCPElementRep () |
Private Types | |
typedef vector< YCPValue > | YCPValueList |
Private Attributes | |
YCPValueList | elements |
Friends | |
class | YCPList |
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.
|
protected |
|
protected |
|
protected |
|
protected |
|
private |
|
protected |
Creates a new and empty list of type [ value ]
Referenced by shallowCopy().
|
inlineprotected |
Cleans up.
References add(), begin(), commaList(), compare(), contains(), end(), fsortlist(), functionalAdd(), isEmpty(), lsortlist(), push_back(), reserve(), reverse(), shallowCopy(), size(), sortlist(), str, swap(), toStream(), toString(), toXml(), value(), and valuetype().
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(), and ~YCPListRep().
YCPListRep::const_iterator YCPListRep::begin | ( | ) | const |
Returns a random access iterator for the YCPList that is positioned at the first value in the list.
References elements.
Referenced by contains(), and ~YCPListRep().
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(), and ~YCPListRep().
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
v | value to compare against |
References order, size(), YCPList::size(), value(), YCPList::value(), YO_EQUAL, YO_GREATER, and YO_LESS.
Referenced by ~YCPListRep().
bool YCPListRep::contains | ( | const YCPValue & | value | ) | const |
Returns true if the list contains the value, otherwise false.
References begin(), and end().
Referenced by ~YCPListRep().
YCPListRep::const_iterator YCPListRep::end | ( | ) | const |
Returns a random access iterator for the YCPList that is positioned behind the last value in the list.
References elements.
Referenced by contains(), and ~YCPListRep().
void YCPListRep::fsortlist | ( | const YCPCodeCompare & | cmp | ) |
Sorts the list according to a comparison function. This function changes the list.
References elements.
Referenced by ~YCPListRep().
Creates a new list, that is identical to this one with but one new value appended. Doesn't change this list.
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().
Referenced by ~YCPListRep().
bool YCPListRep::isEmpty | ( | ) | const |
void YCPListRep::lsortlist | ( | ) |
Sorts the list according to the locale. This function changes the list.
References elements.
Referenced by ~YCPListRep().
void YCPListRep::push_back | ( | 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 ~YCPListRep().
void YCPListRep::remove | ( | const int | n | ) |
void YCPListRep::reserve | ( | int | size | ) |
Reserves a number of elements in the list.
References elements.
Referenced by shallowCopy(), and ~YCPListRep().
void YCPListRep::reverse | ( | ) |
Reverses the elements in the list. This function changes the list.
References elements.
Referenced by ~YCPListRep().
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.
|
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().
Referenced by ~YCPListRep().
int YCPListRep::size | ( | ) | const |
Returns the number of elements in the list.
References elements.
Referenced by compare(), functionalAdd(), remove(), set(), shallowCopy(), swap(), value(), and ~YCPListRep().
void YCPListRep::sortlist | ( | ) |
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().
Referenced by ~YCPListRep().
|
virtual |
Output value as bytecode to stream
Implements YCPElementRep.
References elements, str, Bytecode::writeInt32(), Bytecode::writeValue(), and y2error.
Referenced by ~YCPListRep().
|
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(), and ~YCPListRep().
|
virtual |
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(), set(), YCPList::set(), shallowCopy(), and ~YCPListRep().
|
virtual |
Returns YT_LIST. See YCPValueRep::type.
Implements YCPValueRep.
References YT_LIST.
Referenced by ~YCPListRep().
|
friend |
Referenced by YCPList::YCPList().
|
private |
Referenced by add(), begin(), commaList(), end(), fsortlist(), isEmpty(), lsortlist(), push_back(), remove(), reserve(), reverse(), set(), size(), sortlist(), swap(), toStream(), toXml(), and value().