00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __libutilxx__sella__variant__Vector_H__
00010 #define __libutilxx__sella__variant__Vector_H__
00011
00012 #include "../../common.h"
00013 #include "TypeCastException.h"
00014 #include "Nullable.h"
00015
00016 #include <memory>
00017 #include <vector>
00018
00019 #include <boost/regex.hpp>
00020
00021 namespace sella {
00022 namespace variant {
00023 class Vector;
00024 class Variant;
00025 }
00026 }
00027
00028 class sella::variant::Vector : public Nullable {
00029 public:
00030 typedef std::vector<Variant>::iterator iterator;
00031 typedef std::vector<Variant>::const_iterator const_iterator;
00032
00033 static const boost::regex Pattern;
00034 static const int Type = 0x50;
00035
00036 public:
00037
00038 Vector() throw ();
00039 Vector(const std::string &value) throw (TypeCastException);
00040 Vector(const std::vector<std::string> &token) throw (TypeCastException);
00041 Vector(const std::vector<Variant> &value) throw ();
00042
00043 Vector(const Vector &other) throw ();
00044 virtual ~Vector() throw ();
00045
00046
00047 bool operator==(const Vector &other) const throw ();
00048 bool operator!=(const Vector &other) const throw ();
00049 Vector& operator=(const Vector &other) throw ();
00050 Vector& operator+=(const Variant &other) throw ();
00051 const Variant& operator[](int index) const throw (std::out_of_range);
00052 Variant& operator[](int index) throw (std::out_of_range);
00053
00054
00055 iterator begin() throw ();
00056 iterator end() throw ();
00057 const_iterator cbegin() const throw ();
00058 const_iterator cend() const throw ();
00059
00060 const std::vector<Variant>* getVector() const throw (UnsupportedOperatorException);
00061 size_t size() const throw ();
00062 bool empty() const throw ();
00063 bool erase(const std::string &key, int type = 0) throw ();
00064 bool erase(const Variant &value) throw ();
00065 bool erase(int index) throw ();
00066
00067 virtual void shrink_to_fit() throw ();
00068 virtual const std::string& str() const throw ();
00069
00070 private:
00071 std::vector<Variant>& getRef() throw ();
00072 const std::vector<Variant>& getRef() const throw ();
00073 void parse(const std::vector<std::string> &token) throw (TypeCastException);
00074
00075 std::vector<Variant>::iterator it;
00076 };
00077
00078 #endif
00079
00080
00081
00082