File indexing completed on 2025-01-19 09:47:48
0001
0002
0003
0004
0005
0006 #ifndef BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_CONTAINERS_PTR_VECTOR_HPP
0007 #define BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_CONTAINERS_PTR_VECTOR_HPP
0008
0009 #include "../size_t.hpp"
0010 #include <vector>
0011
0012 namespace boost
0013 {
0014 namespace lexer
0015 {
0016 namespace detail
0017 {
0018 template<typename Type>
0019 class ptr_vector
0020 {
0021 public:
0022 typedef std::vector<Type *> vector;
0023
0024 ptr_vector ()
0025 {
0026 }
0027
0028 ~ptr_vector ()
0029 {
0030 clear ();
0031 }
0032
0033 vector *operator -> ()
0034 {
0035 return &_vector;
0036 }
0037
0038 const vector *operator -> () const
0039 {
0040 return &_vector;
0041 }
0042
0043 vector &operator * ()
0044 {
0045 return _vector;
0046 }
0047
0048 const vector &operator * () const
0049 {
0050 return _vector;
0051 }
0052
0053 Type * &operator [] (const std::size_t index_)
0054 {
0055 return _vector[index_];
0056 }
0057
0058 Type * const &operator [] (const std::size_t index_) const
0059 {
0060 return _vector[index_];
0061 }
0062
0063 bool operator == (const ptr_vector &rhs_) const
0064 {
0065 bool equal_ = _vector.size () == rhs_._vector.size ();
0066
0067 if (equal_)
0068 {
0069 typename vector::const_iterator lhs_iter_ = _vector.begin ();
0070 typename vector::const_iterator end_ = _vector.end ();
0071 typename vector::const_iterator rhs_iter_ = rhs_._vector.begin ();
0072
0073 for (; equal_ && lhs_iter_ != end_; ++lhs_iter_, ++rhs_iter_)
0074 {
0075 equal_ = **lhs_iter_ == **rhs_iter_;
0076 }
0077 }
0078
0079 return equal_;
0080 }
0081
0082 void clear ()
0083 {
0084 if (!_vector.empty ())
0085 {
0086 Type **iter_ = &_vector.front ();
0087 Type **end_ = iter_ + _vector.size ();
0088
0089 for (; iter_ != end_; ++iter_)
0090 {
0091 delete *iter_;
0092 }
0093 }
0094
0095 _vector.clear ();
0096 }
0097
0098 private:
0099 vector _vector;
0100
0101 ptr_vector (const ptr_vector &);
0102 ptr_vector &operator = (const ptr_vector &);
0103 };
0104 }
0105 }
0106 }
0107
0108 #endif