HoverRace  2.0
SeqNode.h
Go to the documentation of this file.
1 
2 // SeqNode.h
3 //
4 // Copyright (c) 2008, 2009, 2015-2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "Node.h"
25 
26 #include <vector>
27 
28 namespace HoverRace {
29 namespace Util {
30 namespace yaml {
31 
32 class SeqNode : public Node
33 {
34  using SUPER = Node;
35 
36 public:
37  SeqNode(yaml_document_t *doc, yaml_node_t *node);
38  virtual ~SeqNode();
39 
40 private:
41  void Init() const;
42 
43 public:
44  bool IsEmpty() const { return Size() == 0; }
45  size_t Size() const;
46 
47 private:
48  using children_t = std::vector<Node*>;
49 
50 public:
51  // STL-like iteration, so we can use range-for on the node itself.
52  using iterator = children_t::iterator;
53  using const_iterator = children_t::const_iterator;
54  using value_type = children_t::value_type;
55  const_iterator begin() const;
56  iterator begin();
57  const_iterator end() const;
58  iterator end();
59 
60 private:
61  mutable std::unique_ptr<children_t> children;
62 };
63 
64 } // namespace yaml
65 } // namespace Util
66 } // namespace HoverRace
void Init() const
Lazy initialization of the child nodes.
Definition: SeqNode.cpp:53
Base class for LibYAML document nodes.
Definition: Node.h:31
SeqNode(yaml_document_t *doc, yaml_node_t *node)
Constructor.
Definition: SeqNode.cpp:35
virtual ~SeqNode()
Destructor.
Definition: SeqNode.cpp:41
std::vector< Node * > children_t
Definition: SeqNode.h:48
children_t::iterator iterator
Definition: SeqNode.h:52
children_t::value_type value_type
Definition: SeqNode.h:54
std::unique_ptr< children_t > children
Definition: SeqNode.h:61
yaml_document_t * doc
Definition: Node.h:45
const_iterator end() const
Definition: SeqNode.cpp:92
size_t Size() const
Definition: SeqNode.cpp:74
Node()
Definition: Node.h:34
bool IsEmpty() const
Definition: SeqNode.h:44
Definition: SeqNode.h:32
children_t::const_iterator const_iterator
Definition: SeqNode.h:53
yaml_node_t * node
Definition: Node.h:46
Definition: Announcement.h:24
const_iterator begin() const
Definition: SeqNode.cpp:80