Avro C++
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
api
Boost.hh
1
/*
2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the
7
* "License"); you may not use this file except in compliance
8
* with the License. You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
#ifndef avro_Boost_hh__
20
#define avro_Boost_hh__
21
22
#include <boost/version.hpp>
23
24
#define BOOST_MINOR_VERSION ( BOOST_VERSION / 100 % 1000 )
25
26
#if (BOOST_MINOR_VERSION < 33)
27
28
/*
29
* In boost 1.33, boost introduced the type trait definitions for true_type and
30
* false_type, the pointer containers, and allow any objects to return
31
* references.
32
*
33
* In order to support earlier versions of boost, if these do not exist we just
34
* create them here.
35
*/
36
37
#define AVRO_BOOST_NO_ANYREF
38
#define AVRO_BOOST_NO_TRAIT
39
#define AVRO_BOOST_NO_PTRVECTOR
40
41
#else
42
#endif
43
44
#include <boost/any.hpp>
45
46
#ifdef AVRO_BOOST_NO_TRAIT
47
// this is copied directly from boost documentation
48
namespace
boost
{
49
template
<
class
T, T val>
50
struct
integral_constant
{
51
typedef
integral_constant<T, val>
type
;
52
typedef
T value_type;
53
static
const
T value = val;
54
};
55
56
typedef
integral_constant<bool, true>
true_type
;
57
typedef
integral_constant<bool, false>
false_type
;
58
}
// namespace boost
59
#else
60
#include <boost/type_traits.hpp>
61
#endif // AVRO_BOOST_NO_TRAIT
62
63
#ifdef AVRO_BOOST_NO_PTRVECTOR
64
#include <vector>
65
// this implements a minimal subset of ptr_vector (the parts of the API used by avro)
66
namespace
boost
{
67
template
<
class
T>
68
class
ptr_vector
{
69
public
:
70
ptr_vector
() : ptrs_() {}
71
~
ptr_vector
() {
72
for
(
size_t
i=0; i < ptrs_.size(); ++i) {
73
delete
ptrs_[i];
74
}
75
}
76
void
push_back(T *v) {
77
ptrs_.push_back(v);
78
}
79
void
pop_back() {
80
T *toDelete = ptrs_.back();
81
ptrs_.pop_back();
82
delete
toDelete;
83
}
84
const
T& back()
const
{
85
return
*ptrs_.back();
86
};
87
T& back() {
88
return
*ptrs_.back();
89
};
90
bool
empty()
const
{
91
return
ptrs_.empty();
92
}
93
const
T& at(
size_t
index)
const
{
94
return
*(ptrs_.at(index));
95
}
96
const
T& operator[](
size_t
index)
const
{
97
return
*(ptrs_[index]);
98
}
99
size_t
size()
const
{
100
return
ptrs_.size();
101
}
102
void
reserve(
size_t
elems) {
103
ptrs_.reserve(elems);
104
}
105
private
:
106
std::vector<T *> ptrs_;
107
};
108
}
// namespace boost
109
#else
110
#include <boost/ptr_container/ptr_vector.hpp>
111
#endif // AVRO_BOOST_NO_PTRVECTOR
112
113
#endif // avro_Boost_hh__
boost
Definition:
Boost.hh:48
boost::ptr_vector
Definition:
Boost.hh:68
boost::integral_constant
Definition:
Boost.hh:50
Generated on Wed Aug 2 2017 04:54:19 for Avro C++ by
1.8.8