Boost.hh
00001
00019 #ifndef avro_Boost_hh__
00020 #define avro_Boost_hh__
00021
00022 #include <boost/version.hpp>
00023
00024 #define BOOST_MINOR_VERSION ( BOOST_VERSION / 100 % 1000 )
00025
00026 #if (BOOST_MINOR_VERSION < 33)
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #define AVRO_BOOST_NO_ANYREF
00038 #define AVRO_BOOST_NO_TRAIT
00039 #define AVRO_BOOST_NO_PTRVECTOR
00040
00041 #else
00042 #endif
00043
00044 #include <boost/any.hpp>
00045
00046 #ifdef AVRO_BOOST_NO_TRAIT
00047
00048 namespace boost {
00049 template <class T, T val>
00050 struct integral_constant {
00051 typedef integral_constant<T, val> type;
00052 typedef T value_type;
00053 static const T value = val;
00054 };
00055
00056 typedef integral_constant<bool, true> true_type;
00057 typedef integral_constant<bool, false> false_type;
00058 }
00059 #else
00060 #include <boost/type_traits.hpp>
00061 #endif // AVRO_BOOST_NO_TRAIT
00062
00063 #ifdef AVRO_BOOST_NO_PTRVECTOR
00064 #include <vector>
00065
00066 namespace boost {
00067 template <class T>
00068 class ptr_vector {
00069 public:
00070 ptr_vector() : ptrs_() {}
00071 ~ptr_vector() {
00072 for(size_t i=0; i < ptrs_.size(); ++i) {
00073 delete ptrs_[i];
00074 }
00075 }
00076 void push_back(T *v) {
00077 ptrs_.push_back(v);
00078 }
00079 void pop_back() {
00080 T *toDelete = ptrs_.back();
00081 ptrs_.pop_back();
00082 delete toDelete;
00083 }
00084 const T& back() const {
00085 return *ptrs_.back();
00086 };
00087 T& back() {
00088 return *ptrs_.back();
00089 };
00090 bool empty() const {
00091 return ptrs_.empty();
00092 }
00093 const T& at(size_t index) const {
00094 return *(ptrs_.at(index));
00095 }
00096 const T& operator[](size_t index) const {
00097 return *(ptrs_[index]);
00098 }
00099 size_t size() const {
00100 return ptrs_.size();
00101 }
00102 void reserve(size_t elems) {
00103 ptrs_.reserve(elems);
00104 }
00105 private:
00106 std::vector<T *> ptrs_;
00107 };
00108 }
00109 #else
00110 #include <boost/ptr_container/ptr_vector.hpp>
00111 #endif // AVRO_BOOST_NO_PTRVECTOR
00112
00113 #endif // avro_Boost_hh__