yast2-core
YCPList.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | |
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
8 | |
9 | core system |
10 | (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12 
13  File: YCPList.h
14 
15  Authors: Mathias Kettner <kettner@suse.de>
16  Arvin Schnell <aschnell@suse.de>
17  Maintainer: Thomas Roelz <tom@suse.de>
18 
19 /-*/
20 // -*- c++ -*-
21 
22 #ifndef YCPList_h
23 #define YCPList_h
24 
25 
26 #include "YCPValue.h"
27 
28 
29 class YCPCodeCompare;
30 
31 
44 class YCPListRep : public YCPValueRep
45 {
46 private:
47 
48  typedef vector<YCPValue> YCPValueList;
49 
51 
52 protected:
53 
54  typedef YCPValueList::iterator iterator;
55  typedef YCPValueList::const_iterator const_iterator;
56  typedef YCPValueList::value_type value_type;
57  typedef YCPValueList::const_reference const_reference;
58 
59  friend class YCPList;
60 
64  YCPListRep();
65 
70 
71 public:
72 
76  int size() const;
77 
81  void reserve (int size);
82 
86  bool isEmpty() const;
87 
93  void add(const YCPValue& value);
94 
100  void push_back(const YCPValue& value);
101 
107  void set(const int n, const YCPValue& value);
108 
112  void remove(const int n);
113 
118  void reverse();
119 
124  void swap(int x, int y);
125 
129  bool contains (const YCPValue& value) const;
130 
134  void sortlist();
135 
139  void lsortlist();
140 
145  void fsortlist(const YCPCodeCompare& cmp);
146 
152  virtual const YCPElementRep* shallowCopy() const;
153 
161  YCPList functionalAdd(const YCPValue& value, bool prepend = false) const;
162 
166  YCPValue value(int n) const;
167 
172  const_iterator begin() const;
173 
178  const_iterator end() const;
179 
198  YCPOrder compare(const YCPList &v) const;
199 
205  string toString() const;
206 
210  std::ostream & toStream (std::ostream & str) const;
211  std::ostream & toXml (std::ostream & str, int indent ) const;
212 
216  YCPValueType valuetype() const;
217 
223  string commaList() const;
224 };
225 
226 
227 #define CONST_ELEMENT (static_cast<const YCPListRep*>(element))
228 #define ELEMENT (const_cast<YCPListRep*>(static_cast<const YCPListRep*>(this->writeCopy())))
229 
236 class YCPList : public YCPValue
237 {
238  DEF_COW_COMMON(List, Value);
239 
240 public:
241 
246 
249 
250  int size() const { return CONST_ELEMENT->size (); }
251  void reserve (int size) { ELEMENT->reserve (size); }
252  bool isEmpty() const { return CONST_ELEMENT->isEmpty (); }
253  void add(const YCPValue& value) { ELEMENT->add (value); }
254  void push_back(const YCPValue& value) { ELEMENT->push_back(value); }
255  void set(const int n, const YCPValue& value) { ELEMENT->set (n, value); }
256  void remove(const int n) { ELEMENT->remove (n); }
257  void reverse() { ELEMENT->reverse(); }
258  void swap(int x, int y) { ELEMENT->swap (x, y); }
259  bool contains (const YCPValue& value) const { return CONST_ELEMENT->contains (value); }
260  void sortlist() { ELEMENT->sortlist (); }
261  void lsortlist() { ELEMENT->lsortlist (); }
262  void fsortlist(const YCPCodeCompare& cmp) { ELEMENT->fsortlist (cmp); }
263 
264  YCPList functionalAdd(const YCPValue& value, bool prepend = false) const
265  { return CONST_ELEMENT->functionalAdd (value, prepend); }
266  YCPValue value(int n) const { return CONST_ELEMENT->value (n); }
267  const_iterator begin() const { return CONST_ELEMENT->begin(); }
268  const_iterator end() const { return CONST_ELEMENT->end(); }
269  string commaList() const { return CONST_ELEMENT->commaList (); }
270 };
271 
272 #undef CONST_ELEMENT
273 #undef ELEMENT
274 
275 #endif // YCPList_h
bool isEmpty() const
Definition: YCPList.h:252
#define CONST_ELEMENT
Definition: YCPList.h:227
string commaList() const
Definition: YCPList.h:269
YCPListRep::iterator iterator
Definition: YCPList.h:242
#define str
Definition: scanner.cc:997
std::ostream & toStream(std::ostream &str) const
Definition: YCPList.cc:276
const_iterator end() const
Definition: YCPList.h:268
YCPList functionalAdd(const YCPValue &value, bool prepend=false) const
Definition: YCPList.cc:158
void swap(int x, int y)
Definition: YCPList.h:258
void lsortlist()
Definition: YCPList.h:261
int size() const
Definition: YCPList.cc:42
YCPListRep()
Definition: YCPList.cc:34
YCPListRep::const_reference const_reference
Definition: YCPList.h:245
YCPValueList::const_reference const_reference
Definition: YCPList.h:57
YCPList functionalAdd(const YCPValue &value, bool prepend=false) const
Definition: YCPList.h:264
void fsortlist(const YCPCodeCompare &cmp)
Definition: YCPList.h:262
YCPValue value(int n) const
Definition: YCPList.cc:179
void push_back(const YCPValue &value)
Definition: YCPList.cc:70
YCPList()
Definition: YCPList.h:247
bool contains(const YCPValue &value) const
Definition: YCPList.cc:116
Definition: YCPCodeCompare.h:31
void sortlist()
Definition: YCPList.h:260
YCPValueType
Value Type Defines constants for the Value types. The Value type specifies the class the YCPValueRep ...
Definition: YCPValue.h:36
YCPValueList::iterator iterator
Definition: YCPList.h:54
void fsortlist(const YCPCodeCompare &cmp)
Definition: YCPList.cc:137
virtual const YCPElementRep * shallowCopy() const
Definition: YCPList.cc:143
YCPValue value(int n) const
Definition: YCPList.h:266
void lsortlist()
Definition: YCPList.cc:130
void sortlist()
Definition: YCPList.cc:123
bool contains(const YCPValue &value) const
Definition: YCPList.h:259
YCPValueList elements
Definition: YCPList.h:50
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPList.cc:292
void add(const YCPValue &value)
Definition: YCPList.h:253
bool isEmpty() const
Definition: YCPList.cc:56
void set(const int n, const YCPValue &value)
Definition: YCPList.cc:77
void set(const int n, const YCPValue &value)
Definition: YCPList.h:255
DEF_COW_COMMON(List, Value)
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.
Definition: YCPList.h:44
YCPOrder
Definition: YCPValue.h:57
void reserve(int size)
Definition: YCPList.cc:49
Wrapper for YCPListRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPListRep with the arrow operator. See YCPListRep.
Definition: YCPList.h:236
~YCPListRep()
Definition: YCPList.h:69
void reverse()
Definition: YCPList.h:257
void push_back(const YCPValue &value)
Definition: YCPList.h:254
YCPValueList::const_iterator const_iterator
Definition: YCPList.h:55
#define ELEMENT
Definition: YCPList.h:228
string commaList() const
Definition: YCPList.cc:259
Abstract base class of all YCP values. Abstract base class of all YCP elements that can be used as pr...
Definition: YCPValue.h:71
Abstract base class of all YCP elements.
Definition: YCPElement.h:222
void reserve(int size)
Definition: YCPList.h:251
YCPOrder compare(const YCPList &v) const
Definition: YCPList.cc:206
void reverse()
Definition: YCPList.cc:100
Wrapper for YCPValueRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPValueRep with the arrow operator. See YCPValueRep.
Definition: YCPValue.h:275
YCPListRep::value_type value_type
Definition: YCPList.h:244
YCPValueList::value_type value_type
Definition: YCPList.h:56
void add(const YCPValue &value)
Definition: YCPList.cc:63
An istream that remembers some data about the bytecode.
Definition: Bytecode.h:42
YCPListRep::const_iterator const_iterator
Definition: YCPList.h:243
const_iterator begin() const
Definition: YCPList.cc:192
YCPValueType valuetype() const
Definition: YCPList.cc:252
void swap(int x, int y)
Definition: YCPList.cc:106
const_iterator begin() const
Definition: YCPList.h:267
string toString() const
Definition: YCPList.cc:245
int size() const
Definition: YCPList.h:250
const_iterator end() const
Definition: YCPList.cc:199
vector< YCPValue > YCPValueList
Definition: YCPList.h:48

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