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

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