00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00043 #ifndef HDFAttributes_h_
00044 #define HDFAttributes_h_ 1
00045
00046 #include <iterator>
00047 #include <boost/operators.hpp>
00048 #include <boost/shared_ptr.hpp>
00049 #include "Nodes.h"
00050
00051 class _attr;
00052
00053 namespace ClearSilver
00054 {
00065 class HDFAttributes : boost::equality_comparable<HDFAttributes>
00066 {
00067 public:
00069
00070 typedef size_t size_type;
00071 typedef char* key_type;
00072
00073 class mapped_type
00074 {
00075 public:
00076 mapped_type ();
00077 mapped_type (const char*);
00078 mapped_type (std::string);
00079 mapped_type (char**);
00080 mapped_type (const mapped_type&);
00081 ~mapped_type () throw();
00082 mapped_type& operator = (const mapped_type&);
00083 mapped_type& operator = (const char*);
00084 void swap (mapped_type&) throw();
00085 operator char* ();
00086 operator const char* () const;
00087
00088 private:
00089 char * value_;
00090 char** valuep_;
00091 };
00092
00093 typedef std::pair<const key_type, mapped_type> value_type;
00094 typedef value_type& reference;
00095 typedef const value_type& const_reference;
00096
00097 class iterator : boost::equality_comparable<HDFAttributes::iterator>
00098 {
00099 friend class HDFAttributes;
00100 public:
00101 struct forward_iterator_tag;
00102 typedef forward_iterator_tag iterator_category;
00103
00104 public:
00105 iterator ();
00106 explicit iterator (_attr*);
00107 iterator (const iterator&);
00108 ~iterator () throw();
00109 iterator& operator = (const iterator&);
00110 void swap (iterator&) throw ();
00111
00112 operator bool () const;
00113 value_type operator * ();
00114 value_type* operator -> ();
00115 iterator& operator ++ ();
00116 iterator operator ++ (int);
00117
00118 friend bool operator == (const iterator&, const iterator&);
00119
00120 private:
00121 _attr* node_;
00122 boost::shared_ptr<value_type> value_;
00123 };
00124
00125 class const_iterator
00126 : boost::equality_comparable<HDFAttributes::const_iterator>
00127 {
00128 friend class HDFAttributes;
00129 public:
00130 struct forward_iterator_tag;
00131 typedef forward_iterator_tag iterator_category;
00132
00133 public:
00134 const_iterator ();
00135 explicit const_iterator (_attr*);
00136 const_iterator (const const_iterator&);
00137 ~const_iterator () throw();
00138 const_iterator& operator = (const const_iterator&);
00139 void swap (const_iterator&) throw ();
00140
00141 operator bool () const;
00142 value_type operator * ();
00143 value_type* operator -> ();
00144 const_iterator& operator ++ ();
00145 const_iterator operator ++ (int);
00146
00147 friend bool operator == (const const_iterator&, const const_iterator&);
00148
00149 private:
00150 _attr* node_;
00151 boost::shared_ptr<value_type> value_;
00152 };
00153
00154
00155 public:
00157
00159 HDFAttributes ();
00161 explicit HDFAttributes (const Nodes& path, _attr* head);
00163 HDFAttributes (const HDFAttributes&);
00165 ~HDFAttributes () throw();
00166
00168 HDFAttributes& operator = (const HDFAttributes&);
00169
00171 void swap (HDFAttributes&) throw();
00172
00173
00175
00177 size_type size () const;
00179 bool empty () const;
00193 size_type count (const key_type& key);
00207 iterator find (const key_type& key);
00221 const_iterator find (const key_type& key) const;
00222
00223
00225 mapped_type operator [] (const key_type&);
00226
00228
00229 iterator begin ();
00230 iterator end ();
00231 const_iterator begin () const;
00232 const_iterator end () const;
00233
00234
00236
00238 std::pair<iterator,bool> insert (const value_type&);
00240 iterator insert (iterator, const value_type&);
00242 size_type erase (const key_type&) throw();
00244 void erase (iterator);
00246 void erase (iterator begin, iterator end);
00248 void clear () throw();
00249
00250
00252 friend bool operator == (const HDFAttributes&, const HDFAttributes&);
00253
00260 static bool& debug ();
00261
00262 private:
00263 Nodes path_;
00264 _attr* head_;
00265 };
00266
00267 };
00268
00269 #endif