19 #ifndef avro_NodeConcepts_hh__ 20 #define avro_NodeConcepts_hh__ 26 #include "Exception.hh" 50 template <
typename Attribute>
53 static const bool hasAttribute =
false;
59 void add(
const Attribute &attr) {
63 throw Exception(
"This type does not have attribute");
66 const Attribute &
get(
size_t index = 0)
const {
70 throw Exception(
"This type does not have attribute");
72 static const Attribute empty = Attribute();
76 Attribute &
get(
size_t index = 0) {
80 throw Exception(
"This type does not have attribute");
85 template<
typename Attribute>
88 static const bool hasAttribute =
true;
104 size_t size()
const {
108 void add(
const Attribute &attr) {
112 const Attribute &
get(
size_t index = 0)
const {
114 throw Exception(
"SingleAttribute has only 1 value");
119 Attribute &
get(
size_t index = 0) {
121 throw Exception(
"SingleAttribute has only 1 value");
131 template<
typename Attribute>
134 static const bool hasAttribute =
true;
146 attrs_.push_back(rhs.attr_);
156 size_t size()
const {
157 return attrs_.size();
160 void add(
const Attribute &attr) {
161 attrs_.push_back(attr);
164 const Attribute &
get(
size_t index = 0)
const {
165 return attrs_.at(index);
168 Attribute &
get(
size_t index) {
169 return attrs_.at(index);
174 std::vector<Attribute> attrs_;
181 bool lookup(
const std::string &name,
size_t &index)
const {
182 throw Exception(
"Name index does not exist");
186 bool add(const::std::string &name,
size_t index) {
187 throw Exception(
"Name index does not exist");
195 typedef std::map<std::string, size_t> IndexMap;
197 bool lookup(
const std::string &name,
size_t &index)
const {
198 IndexMap::const_iterator iter = map_.find(name);
199 if(iter == map_.end()) {
202 index = iter->second;
206 bool add(const::std::string &name,
size_t index) {
208 IndexMap::iterator lb = map_.lower_bound(name);
209 if(lb == map_.end() || map_.key_comp()(name, lb->first)) {
210 map_.insert(lb, IndexMap::value_type(name, index));
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
Definition: NodeConcepts.hh:132
Definition: NodeConcepts.hh:86
Definition: NodeConcepts.hh:179
Wrapper for std::runtime_error that provides convenience constructor for boost::format objects...
Definition: Exception.hh:31
Definition: NodeConcepts.hh:51