yast2-core
YCPCode.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: YCPCode.h
14 
15  Author: Klaus Kaempf <kkaempf@suse.de>
16  Maintainer: Klaus Kaempf <kkaempf@suse.de>
17 
18  Wrappers for YCode data as YCPValue
19 
20 /-*/
21 // -*- c++ -*-
22 
23 #ifndef YCPCode_h
24 #define YCPCode_h
25 
26 
27 #include "ycp/YCPValue.h"
28 #include "ycp/YCode.h"
29 #include "y2/SymbolEntry.h"
30 
31 //---------------------------------------------------------------------------
32 // YCPCode
33 
34 class YCPBreak;
35 class YCPReturn;
36 
40 class YCPCodeRep : public YCPValueRep
41 {
42  YCodePtr m_code;
43 
44 protected:
45  friend class YCPCode;
46 
50  YCPCodeRep();
51  YCPCodeRep (YCodePtr c);
52 
56  ~YCPCodeRep();
57 
58 public:
59  YCodePtr code() const;
60 
65  YCPOrder compare (const YCPCode &v) const;
66 
70  string toString() const;
71 
75  std::ostream & toStream (std::ostream & str) const;
76  std::ostream & toXml (std::ostream & str, int indent ) const;
77 
81  YCPValueType valuetype() const;
82 
86  YCPValue evaluate (bool cse = false) const;
87 };
88 
89 
96 class YCPCode : public YCPValue
97 {
98  DEF_COMMON(Code, Value);
99 public:
100  YCPCode() : YCPValue (new YCPCodeRep ()) {}
101  YCPCode (YCodePtr code) : YCPValue (new YCPCodeRep (code)) {}
103 };
104 
105 
106 //---------------------------------------------------------------------------
107 // YCPBreak
108 
109 
118 class YCPBreakRep : public YCPValueRep
119 {
120 protected:
121  friend class YCPBreak;
122 
126  YCPBreakRep () {};
127 
132 
133 public:
138  YCPOrder compare (const YCPBreak &) const { return YO_EQUAL; }
139 
144  string toString() const { return "nil"; }
145 
149  std::ostream & toStream (std::ostream & str) const { return str; };
150  std::ostream & toXml (std::ostream & str, int indent ) const;
151 
155  YCPValueType valuetype() const { return YT_BREAK; }
156 
157 };
158 
165 class YCPBreak : public YCPValue
166 {
167  DEF_COMMON(Break, Value);
168 public:
169  YCPBreak() : YCPValue (new YCPBreakRep ()) {}
171 };
172 
173 
174 //---------------------------------------------------------------------------
175 // YCPReturn
176 
187 class YCPReturnRep : public YCPValueRep
188 {
189 protected:
190  friend class YCPReturn;
191 
196 
201 
202 public:
207  YCPOrder compare (const YCPReturn &) const { return YO_EQUAL; }
208 
212  string toString() const { return "nil"; }
213 
217  std::ostream & toStream (std::ostream & str) const { return str; };
218  std::ostream & toXml (std::ostream & str, int indent ) const;
219 
223  YCPValueType valuetype() const { return YT_RETURN; }
224 
225 };
226 
233 class YCPReturn : public YCPValue
234 {
235  DEF_COMMON(Return, Value);
236 public:
239 };
240 
241 
242 //---------------------------------------------------------------------------
243 // YCPEntry
244 
245 
249 class YCPEntryRep : public YCPValueRep
250 {
251  SymbolEntryPtr m_entry;
252 
253 protected:
254  friend class YCPEntry;
255 
259  YCPEntryRep ();
260  YCPEntryRep (SymbolEntryPtr entry);
261 
266 
267 public:
268  SymbolEntryPtr entry() const;
269 
274  YCPOrder compare (const YCPEntry &v) const;
275 
279  string toString() const;
280 
284  std::ostream & toStream (std::ostream & str) const;
285  std::ostream & toXml (std::ostream & str, int indent ) const;
286 
290  YCPValueType valuetype() const;
291 
295  YCPValue evaluate (bool cse = false) const;
296 };
297 
298 
305 class YCPEntry : public YCPValue
306 {
307  DEF_COMMON(Entry, Value);
308 public:
309  YCPEntry (SymbolEntryPtr entry) : YCPValue (new YCPEntryRep (entry)) {}
311 };
312 
313 
314 //---------------------------------------------------------------------------
315 // YCPReference
316 
317 
322 {
323  SymbolEntryPtr m_entry;
324 
325 protected:
326  friend class YCPReference;
327 
331  YCPReferenceRep ();
332  YCPReferenceRep (SymbolEntryPtr entry);
333 
338 
339 public:
340  SymbolEntryPtr entry() const;
341 
346  YCPOrder compare (const YCPReference &v) const;
347 
351  string toString() const;
352 
356  std::ostream & toStream (std::ostream & str) const;
357  std::ostream & toXml (std::ostream & str, int indent ) const;
358 
362  YCPValueType valuetype() const;
363 
367  YCPValue evaluate (bool cse = false) const;
368 };
369 
370 
377 class YCPReference : public YCPValue
378 {
379  DEF_COMMON(Reference, Value);
380 public:
381  YCPReference (SymbolEntryPtr entry) : YCPValue (new YCPReferenceRep (entry)) {}
382 };
383 
384 #endif // YCPCode_h
DEF_COMMON(Entry, Value)
YCodePtr code() const
Definition: YCPCode.cc:48
YCPValueType valuetype() const
Definition: YCPCode.cc:206
~YCPReturnRep()
Definition: YCPCode.h:200
string toString() const
Definition: YCPCode.cc:197
string toString() const
Definition: YCPCode.cc:61
YCPOrder compare(const YCPReturn &) const
Definition: YCPCode.h:207
Wrapper for YCPBreakRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPBreakRep with the arrow operator. See YCPBreakRep.
Definition: YCPCode.h:165
#define str
Definition: scanner.cc:997
SymbolEntryPtr m_entry
Definition: YCPCode.h:323
Wrapper for Return as YCPValue.
Definition: YCPCode.h:187
std::ostream & toStream(std::ostream &str) const
Definition: YCPCode.cc:222
~YCPBreakRep()
Definition: YCPCode.h:131
SymbolEntryPtr entry() const
Definition: YCPCode.cc:121
YCPOrder compare(const YCPEntry &v) const
Definition: YCPCode.cc:128
YCPReturn(bytecodeistream &)
Definition: YCPCode.h:238
SymbolEntryPtr entry() const
Definition: YCPCode.cc:184
DEF_COMMON(Code, Value)
YCPReturnRep()
Definition: YCPCode.h:195
YCPOrder compare(const YCPReference &v) const
Definition: YCPCode.cc:191
YCPValueType
Value Type Defines constants for the Value types. The Value type specifies the class the YCPValueRep ...
Definition: YCPValue.h:36
YCPValueType valuetype() const
Definition: YCPCode.cc:143
std::ostream & toStream(std::ostream &str) const
Definition: YCPCode.h:149
std::ostream & toStream(std::ostream &str) const
Definition: YCPCode.cc:88
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPCode.cc:238
YCPCodeRep()
Definition: YCPCode.cc:31
~YCPReferenceRep()
Definition: YCPCode.h:337
YCPOrder compare(const YCPBreak &) const
Definition: YCPCode.h:138
Wrapper for YCPCodeRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPCodeRep with the arrow operator. See YCPCodeRep.
Definition: YCPCode.h:96
YCPValue evaluate(bool cse=false) const
Definition: YCPCode.cc:213
YCPBreakRep()
Definition: YCPCode.h:126
string toString() const
Definition: YCPCode.h:212
Definition: YCPValue.h:50
Wrapper for YCPReferenceRep This class realizes an automatic memory management via YCPElement...
Definition: YCPCode.h:377
YCPReturn()
Definition: YCPCode.h:237
YCPReference(SymbolEntryPtr entry)
Definition: YCPCode.h:381
~YCPCodeRep()
Definition: YCPCode.cc:43
DEF_COMMON(Reference, Value)
YCPOrder compare(const YCPCode &v) const
Definition: YCPCode.cc:55
Wrapper for YCPEntryRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPEntryRep with the arrow operator. See YCPEntryRep.
Definition: YCPCode.h:305
Definition: YCPValue.h:59
SymbolEntryPtr m_entry
Definition: YCPCode.h:251
YCPValue evaluate(bool cse=false) const
Definition: YCPCode.cc:76
YCPOrder
Definition: YCPValue.h:57
YCPCode(YCodePtr code)
Definition: YCPCode.h:101
Wrapper for YCPReturnRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPReturnRep with the arrow operator. See YCPReturnRep.
Definition: YCPCode.h:233
DEF_COMMON(Break, Value)
std::ostream & toStream(std::ostream &str) const
Definition: YCPCode.cc:159
~YCPEntryRep()
Definition: YCPCode.h:265
YCPCode()
Definition: YCPCode.h:100
YCPBreak()
Definition: YCPCode.h:169
Abstract base class of all YCP values. Abstract base class of all YCP elements that can be used as pr...
Definition: YCPValue.h:71
YCPValueType valuetype() const
Definition: YCPCode.h:223
Wrapper for Break as YCPValue.
Definition: YCPCode.h:118
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPCode.cc:94
YCPBreak(bytecodeistream &)
Definition: YCPCode.h:170
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
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPCode.cc:166
Wrapper for SymbolEntry as YCPValue.
Definition: YCPCode.h:249
YCPEntry(SymbolEntryPtr entry)
Definition: YCPCode.h:309
An istream that remembers some data about the bytecode.
Definition: Bytecode.h:42
Wrapper for YCode as YCPValue.
Definition: YCPCode.h:40
Definition: YCPValue.h:49
string toString() const
Definition: YCPCode.cc:134
std::ostream & toStream(std::ostream &str) const
Definition: YCPCode.h:217
string toString() const
Definition: YCPCode.h:144
Wrapper for a reference to a SymbolEntry as YCPValue.
Definition: YCPCode.h:321
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPCode.cc:229
YCPValue evaluate(bool cse=false) const
Definition: YCPCode.cc:150
DEF_COMMON(Return, Value)
YCPValueType valuetype() const
Definition: YCPCode.h:155
YCodePtr m_code
Definition: YCPCode.h:42
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPCode.cc:244
YCPValueType valuetype() const
Definition: YCPCode.cc:70

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