YCPTerm.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |  
00003 |                      __   __    ____ _____ ____                      |  
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |  
00005 |                       \ V / _` \___ \ | |   __) |                    |  
00006 |                        | | (_| |___) || |  / __/                     |  
00007 |                        |_|\__,_|____/ |_| |_____|                    |  
00008 |                                                                      |  
00009 |                               core system                            | 
00010 |                                                        (C) SuSE GmbH |  
00011 \----------------------------------------------------------------------/ 
00012 
00013    File:       YCPTerm.h
00014 
00015    Author:      Klaus Kaempf <kkaempf@suse.de>
00016                 Mathias Kettner <kettner@suse.de>
00017    Maintainer:  Klaus Kaempf <kkaempf@suse.de>
00018 
00019 /-*/
00020 // -*- c++ -*-
00021 
00022 #ifndef YCPTerm_h
00023 #define YCPTerm_h
00024 
00025 
00026 #include <ycp/YCPSymbol.h>
00027 #include <ycp/YCPList.h>
00028 #include <y2util/Ustring.h>
00029 
00035 class YCPTermRep : public YCPValueRep
00036 {
00037 #define GLOBALNAME "_"
00038 
00041     Ustring s;
00042 
00046     YCPList l;
00047 
00051     void setName (string name);
00052 
00053 protected:
00054     friend class YCPTerm;
00055 
00059     YCPTermRep(const string& s);
00060 
00064     YCPTermRep(const string& s, const YCPList& l);
00065     
00069     ~YCPTermRep() {}
00070 
00071 public:
00075     string name() const;
00076     
00081     YCPList args() const;
00082     
00102     YCPOrder compare(const YCPTerm &v) const;
00103     
00110     virtual const YCPElementRep* shallowCopy() const;
00111 
00116     YCPTerm functionalAdd(const YCPValue& value) const;
00117 
00124     string toString() const;
00125     
00129     std::ostream & toStream (std::ostream & str) const;
00130     std::ostream & toXml (std::ostream & str, int indent ) const;
00131 
00135     bool isEmpty() const;
00136     
00140     int size() const;
00141     
00145     void reserve (int size);
00146     
00150     YCPValue value(int n) const;
00151     
00155     void set(const int n, const YCPValue& value);
00156 
00160     void add(const YCPValue& value);
00161     
00165     YCPValueType valuetype() const;
00166 };
00167 
00168 #define CONST_ELEMENT (static_cast<const YCPTermRep*>(element))
00169 #define ELEMENT (const_cast<YCPTermRep*>(static_cast<const YCPTermRep*>(this->writeCopy ())))
00170 
00177 class YCPTerm : public YCPValue
00178 {
00179     DEF_COW_COMMON(Term, Value);
00180 public:
00181     YCPTerm(const string& s) : YCPValue(new YCPTermRep(s)) {}
00182     YCPTerm(const string& s, const YCPList& l) : YCPValue(new YCPTermRep(s, l)) {}
00183     YCPTerm(bytecodeistream & str);
00184 
00185     string name() const { return CONST_ELEMENT->name (); }
00186     YCPList args() const { return CONST_ELEMENT->args (); }
00187     YCPTerm functionalAdd(const YCPValue& value) const { return CONST_ELEMENT->functionalAdd (value); }
00188     bool isEmpty() const { return CONST_ELEMENT->isEmpty (); }
00189     int size() const { return CONST_ELEMENT->size (); }
00190     void reserve (int size) { ELEMENT->reserve (size); }
00191     YCPValue value(int n) const { return CONST_ELEMENT->value (n); }
00192     void set(const int n, const YCPValue& value) { ELEMENT->set (n, value); }
00193     void add(const YCPValue& value) { ELEMENT->add (value); }
00194 };
00195 
00196 #undef CONST_ELEMENT
00197 #undef ELEMENT
00198 
00199 #endif   // YCPTerm_h

Generated on Tue Nov 6 01:27:46 2007 for yast2-core by  doxygen 1.5.3