YCPList.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:       YCPList.h
00014 
00015    Author:     Mathias Kettner <kettner@suse.de>
00016    Maintainer: Thomas Roelz <tom@suse.de>
00017 
00018 /-*/
00019 // -*- c++ -*-
00020 
00021 #ifndef YCPList_h
00022 #define YCPList_h
00023 
00024 
00025 #include "YCPValue.h"
00026 
00027 
00028 
00029 class YCPCodeCompare;
00030 
00043 class YCPListRep : public YCPValueRep
00044 {
00045     vector<YCPValue> elements;
00046 
00047 protected:
00048     friend class YCPList;
00049 
00053     YCPListRep();
00054 
00058     ~YCPListRep() {}
00059 
00060 public:
00064     int size() const;
00065 
00069     void reserve (int size);
00070 
00074     bool isEmpty() const;
00075 
00081     void add(const YCPValue& value);
00082 
00088     void set(const int n, const YCPValue& value);
00089 
00093     void remove(const int n);
00094 
00099     void swap(int x, int y);
00100 
00104     bool contains (const YCPValue& value) const;
00105 
00109     void sortlist();
00110 
00114     void lsortlist();
00115 
00120     void fsortlist(const YCPCodeCompare& cmp);
00121 
00127     virtual const YCPElementRep* shallowCopy() const;
00128 
00136     YCPList functionalAdd(const YCPValue& value, bool prepend = false) const;
00137 
00141     YCPValue value(int n) const;
00142 
00161     YCPOrder compare(const YCPList &v) const;
00162 
00168     string toString() const;
00169 
00173     std::ostream & toStream (std::ostream & str) const;
00174 
00178     YCPValueType valuetype() const;
00179 
00185     string commaList() const;
00186 };
00187 
00188 #define CONST_ELEMENT (static_cast<const YCPListRep*>(element))
00189 #define ELEMENT (const_cast<YCPListRep*>(static_cast<const YCPListRep*>(this->writeCopy())))
00190 
00197 class YCPList : public YCPValue
00198 {
00199     DEF_COW_COMMON(List, Value);
00200 public:
00201     YCPList() : YCPValue(new YCPListRep()) {}
00202     YCPList(bytecodeistream & str);
00203 
00204     int size() const { return CONST_ELEMENT->size (); }
00205     void reserve (int size) { ELEMENT->reserve (size); }
00206     bool isEmpty() const { return CONST_ELEMENT->isEmpty (); }
00207     void add(const YCPValue& value) { ELEMENT->add (value);  }
00208     void set(const int n, const YCPValue& value) { ELEMENT->set (n, value); }
00209     void remove(const int n) { ELEMENT->remove (n); }
00210     void swap(int x, int y) { ELEMENT->swap (x, y); }
00211     bool contains (const YCPValue& value) const { return CONST_ELEMENT->contains (value); }
00212     void sortlist() { ELEMENT->sortlist (); }
00213     void lsortlist() { ELEMENT->lsortlist (); }
00214     void fsortlist(const YCPCodeCompare& cmp) { ELEMENT->fsortlist (cmp); }
00215 
00216     YCPList functionalAdd(const YCPValue& value, bool prepend = false) const
00217         { return CONST_ELEMENT->functionalAdd (value, prepend); }
00218     YCPValue value(int n) const { return CONST_ELEMENT->value (n); }
00219     string commaList() const { return CONST_ELEMENT->commaList (); }
00220 };
00221 
00222 #undef CONST_ELEMENT
00223 #undef ELEMENT
00224 
00225 #endif   // YCPList_h

Generated on Fri Jun 16 18:07:45 2006 for yast2-core by  doxygen 1.4.6