yast2-core
YCPTerm.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: YCPTerm.h
14 
15  Author: Klaus Kaempf <kkaempf@suse.de>
16  Mathias Kettner <kettner@suse.de>
17  Maintainer: Klaus Kaempf <kkaempf@suse.de>
18 
19 /-*/
20 // -*- c++ -*-
21 
22 #ifndef YCPTerm_h
23 #define YCPTerm_h
24 
25 
26 #include <ycp/YCPSymbol.h>
27 #include <ycp/YCPList.h>
28 #include <y2util/Ustring.h>
29 
35 class YCPTermRep : public YCPValueRep
36 {
37 #define GLOBALNAME "_"
38 
42 
47 
51  void setName (string name);
52 
53 protected:
54  friend class YCPTerm;
55 
59  YCPTermRep(const string& s);
60 
64  YCPTermRep(const string& s, const YCPList& l);
65 
70 
71 public:
75  string name() const;
76 
81  YCPList args() const;
82 
102  YCPOrder compare(const YCPTerm &v) const;
103 
110  virtual const YCPElementRep* shallowCopy() const;
111 
116  YCPTerm functionalAdd(const YCPValue& value) const;
117 
124  string toString() const;
125 
129  std::ostream & toStream (std::ostream & str) const;
130  std::ostream & toXml (std::ostream & str, int indent ) const;
131 
135  bool isEmpty() const;
136 
140  int size() const;
141 
145  void reserve (int size);
146 
150  YCPValue value(int n) const;
151 
155  void set(const int n, const YCPValue& value);
156 
160  void add(const YCPValue& value);
161 
165  YCPValueType valuetype() const;
166 };
167 
168 #define CONST_ELEMENT (static_cast<const YCPTermRep*>(element))
169 #define ELEMENT (const_cast<YCPTermRep*>(static_cast<const YCPTermRep*>(this->writeCopy ())))
170 
177 class YCPTerm : public YCPValue
178 {
179  DEF_COW_COMMON(Term, Value);
180 public:
181  YCPTerm(const string& s) : YCPValue(new YCPTermRep(s)) {}
182  YCPTerm(const string& s, const YCPList& l) : YCPValue(new YCPTermRep(s, l)) {}
184 
185  string name() const { return CONST_ELEMENT->name (); }
186  YCPList args() const { return CONST_ELEMENT->args (); }
187  YCPTerm functionalAdd(const YCPValue& value) const { return CONST_ELEMENT->functionalAdd (value); }
188  bool isEmpty() const { return CONST_ELEMENT->isEmpty (); }
189  int size() const { return CONST_ELEMENT->size (); }
190  void reserve (int size) { ELEMENT->reserve (size); }
191  YCPValue value(int n) const { return CONST_ELEMENT->value (n); }
192  void set(const int n, const YCPValue& value) { ELEMENT->set (n, value); }
193  void add(const YCPValue& value) { ELEMENT->add (value); }
194 };
195 
196 #undef CONST_ELEMENT
197 #undef ELEMENT
198 
199 #endif // YCPTerm_h
#define DEF_COW_COMMON(name, base)
Definition: YCPElement.h:104
string name() const
Definition: YCPTerm.cc:43
void add(const YCPValue &value)
Definition: YCPTerm.cc:142
#define str
Definition: scanner.cc:1003
bool isEmpty() const
Definition: YCPTerm.cc:102
void add(const YCPValue &value)
Definition: YCPTerm.h:193
YCPValueType valuetype() const
Definition: YCPTerm.cc:149
YCPOrder compare(const YCPTerm &v) const
Definition: YCPTerm.cc:67
YCPList args() const
Definition: YCPTerm.cc:59
bool isEmpty() const
Definition: YCPTerm.h:188
Ustring s
Definition: YCPTerm.h:41
YCPTerm(const string &s, const YCPList &l)
Definition: YCPTerm.h:182
YCPValue value(int n) const
Definition: YCPTerm.cc:126
YCPValueType
Value Type Defines constants for the Value types. The Value type specifies the class the YCPValueRep ...
Definition: YCPValue.h:36
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPTerm.cc:168
~YCPTermRep()
Definition: YCPTerm.h:69
#define ELEMENT
Definition: YCPTerm.h:169
YCPValue value(int n) const
Definition: YCPTerm.h:191
int size() const
Definition: YCPTerm.h:189
std::ostream & toStream(std::ostream &str) const
Definition: YCPTerm.cc:160
Unique strings.
Definition: Ustring.h:124
string name() const
Definition: YCPTerm.h:185
YCPOrder
Definition: YCPValue.h:57
YCPTerm functionalAdd(const YCPValue &value) const
Definition: YCPTerm.cc:86
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
void reserve(int size)
Definition: YCPTerm.cc:118
YCPTerm functionalAdd(const YCPValue &value) const
Definition: YCPTerm.h:187
virtual const YCPElementRep * shallowCopy() const
Definition: YCPTerm.cc:78
Abstract base class of all YCP values. Abstract base class of all YCP elements that can be used as pr...
Definition: YCPValue.h:71
void setName(string name)
Definition: YCPTerm.cc:51
Abstract base class of all YCP elements.
Definition: YCPElement.h:222
Wrapper for YCPTermRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPTermRep with the arrow operator. See YCPTermRep.
Definition: YCPTerm.h:177
YCPList args() const
Definition: YCPTerm.h:186
int size() const
Definition: YCPTerm.cc:110
YCPValueRep representing a term. A YCPTermRep is a YCPValue containing a list plus a string represent...
Definition: YCPTerm.h:35
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
void reserve(int size)
Definition: YCPTerm.h:190
#define CONST_ELEMENT
Definition: YCPTerm.h:168
An istream that remembers some data about the bytecode.
Definition: Bytecode.h:42
YCPTerm(const string &s)
Definition: YCPTerm.h:181
YCPTermRep(const string &s)
Definition: YCPTerm.cc:28
string toString() const
Definition: YCPTerm.cc:94
friend class YCPTerm
Definition: YCPTerm.h:54
YCPList l
Definition: YCPTerm.h:46

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