Avro C++
Layout.hh
Go to the documentation of this file.
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  * https://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_Layout_hh__
20 #define avro_Layout_hh__
21 
22 #include <boost/noncopyable.hpp>
23 #include "Config.hh"
24 
27 
28 namespace avro {
29 
30 class AVRO_DECL Layout : private boost::noncopyable {
31 
32  protected:
33 
34  Layout(size_t offset = 0) :
35  offset_(offset)
36  {}
37 
38  public:
39 
40  size_t offset() const {
41  return offset_;
42  }
43 
44  virtual ~Layout() {}
45 
46  private:
47 
48  const size_t offset_;
49 };
50 
51 class AVRO_DECL PrimitiveLayout : public Layout {
52 
53  public:
54 
55  PrimitiveLayout(size_t offset = 0) :
56  Layout(offset)
57  {}
58 };
59 
60 class AVRO_DECL CompoundLayout : public Layout {
61 
62  public:
63 
64  CompoundLayout(size_t offset = 0) :
65  Layout(offset)
66  {}
67 
68  void add(std::unique_ptr<Layout> &layout) {
69  layouts_.push_back(std::move(layout));
70  }
71 
72  const Layout &at (size_t idx) const {
73  return *layouts_.at(idx);
74  }
75 
76  private:
77 
78  std::vector<std::unique_ptr<Layout> > layouts_;
79 };
80 
81 } // namespace avro
82 
83 #endif
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
Definition: Layout.hh:60
Definition: Layout.hh:30
Definition: Layout.hh:51