nomlib
Loading...
Searching...
No Matches
ValueIteratorBase.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_SYSTEM_PTREE_VALUE_ITERATOR_BASE_HPP
30#define NOMLIB_SYSTEM_PTREE_VALUE_ITERATOR_BASE_HPP
31
32#include <vector>
33#include <iterator>
34
35#include "export.hpp"
36#include "nomlib/config.hpp"
37#include "nomlib/ptree/ptree_config.hpp"
38#include "nomlib/ptree/ptree_types.hpp"
39#include "nomlib/ptree/ptree_forwards.hpp"
40#include "nomlib/ptree/Value.hpp"
41
42namespace nom {
43
44class NOM_EXPORT ValueIteratorBase
45{
46 public:
47 typedef ValueIteratorBase SelfType;
48 typedef ValueIteratorBase* RawPtr;
49 typedef nom::size_type DifferenceType;
50 typedef Value& ValueTypeReference;
51 typedef Value* ValueTypePointer;
52
53 enum IteratorType
54 {
55 Null = 0, // Type 0 (default)
56 ObjectValues // Type 7
57 };
58
61
64
65 ValueIteratorBase(const ObjectIterator& rhs);
66
71 bool valid() const;
72
77 ArrayIndex index() const;
78
86 const char* key() const;
87
90 bool key(const std::string& member) const;
91
92 bool operator ==(const SelfType& rhs) const;
93
94 bool operator !=(const SelfType& rhs) const;
95
96 DifferenceType operator -(const SelfType& rhs) const;
97
98 protected:
99 void copy(const SelfType& rhs);
100 ValueTypeReference dereference() const;
101 ValueTypePointer pointer() const;
102 void increment();
103 void decrement();
104 DifferenceType distance(const SelfType& rhs) const;
105
106 private:
107 enum IteratorType type() const;
108
110 ObjectIterator object_;
111
112 enum IteratorType type_;
113};
114
115} // namespace nom
116
117#endif // include guard defined
Generic interface for opaque data containers.
Definition Value.hpp:44
ValueIteratorBase()
Default constructor.
virtual ~ValueIteratorBase()
Destructor.
bool valid() const
query validity of the object.
const char * key() const
Obtain the current index or member key value.
bool key(const std::string &member) const
Query if the member key exists at the current position of the iterator object.
ObjectIterator object_
A pointer to the object type iterator.
ArrayIndex index() const
Obtain the index of the referenced value.