yast2-core
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
libycp
src
include
ycp
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
50
YCPValueList
elements
;
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
69
~YCPListRep
() {}
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
swap
(
int
x,
int
y);
119
123
bool
contains
(
const
YCPValue
&
value
)
const
;
124
128
void
sortlist
();
129
133
void
lsortlist
();
134
139
void
fsortlist
(
const
YCPCodeCompare
& cmp);
140
146
virtual
const
YCPElementRep
*
shallowCopy
()
const
;
147
155
YCPList
functionalAdd
(
const
YCPValue
&
value
,
bool
prepend =
false
)
const
;
156
160
YCPValue
value
(
int
n)
const
;
161
166
const_iterator
begin
()
const
;
167
172
const_iterator
end
()
const
;
173
192
YCPOrder
compare
(
const
YCPList
&v)
const
;
193
199
string
toString
()
const
;
200
204
std::ostream &
toStream
(std::ostream &
str
)
const
;
205
std::ostream &
toXml
(std::ostream &
str
,
int
indent )
const
;
206
210
YCPValueType
valuetype
()
const
;
211
217
string
commaList
()
const
;
218
};
219
220
221
#define CONST_ELEMENT (static_cast<const YCPListRep*>(element))
222
#define ELEMENT (const_cast<YCPListRep*>(static_cast<const YCPListRep*>(this->writeCopy())))
223
230
class
YCPList
:
public
YCPValue
231
{
232
DEF_COW_COMMON
(List, Value);
233
234
public
:
235
236
typedef
YCPListRep::iterator
iterator
;
237
typedef
YCPListRep::const_iterator
const_iterator
;
238
typedef
YCPListRep::value_type
value_type
;
239
typedef
YCPListRep::const_reference
const_reference
;
240
241
YCPList
() :
YCPValue
(new
YCPListRep
()) {}
242
YCPList
(
bytecodeistream
&
str
);
243
244
int
size
()
const
{
return
CONST_ELEMENT
->size (); }
245
void
reserve
(
int
size
) {
ELEMENT
->reserve (size); }
246
bool
isEmpty
()
const
{
return
CONST_ELEMENT
->isEmpty (); }
247
void
add
(
const
YCPValue
&
value
) {
ELEMENT
->add (value); }
248
void
push_back
(
const
YCPValue
&
value
) {
ELEMENT
->push_back(value); }
249
void
set
(
const
int
n,
const
YCPValue
&
value
) {
ELEMENT
->set (n,
value
); }
250
void
remove
(
const
int
n) {
ELEMENT
->remove (n); }
251
void
swap
(
int
x,
int
y) {
ELEMENT
->swap (x, y); }
252
bool
contains
(
const
YCPValue
&
value
)
const
{
return
CONST_ELEMENT
->contains (value); }
253
void
sortlist
() {
ELEMENT
->sortlist (); }
254
void
lsortlist
() {
ELEMENT
->lsortlist (); }
255
void
fsortlist
(
const
YCPCodeCompare
& cmp) {
ELEMENT
->fsortlist (cmp); }
256
257
YCPList
functionalAdd
(
const
YCPValue
&
value
,
bool
prepend =
false
)
const
258
{
return
CONST_ELEMENT
->functionalAdd (value, prepend); }
259
YCPValue
value
(
int
n)
const
{
return
CONST_ELEMENT
->value (n); }
260
const_iterator
begin
()
const
{
return
CONST_ELEMENT
->begin(); }
261
const_iterator
end
()
const
{
return
CONST_ELEMENT
->end(); }
262
string
commaList
()
const
{
return
CONST_ELEMENT
->commaList (); }
263
};
264
265
#undef CONST_ELEMENT
266
#undef ELEMENT
267
268
#endif // YCPList_h
Generated on a sunny day for yast2-core by
1.8.2