Wolframe, 0.0.3

singlefilter.hpp
Go to the documentation of this file.
1 /************************************************************************
2 Copyright (C) 2011 - 2014 Project Wolframe.
3 All rights reserved.
4 
5 This file is part of Project Wolframe.
6 
7 Commercial Usage
8 Licensees holding valid Project Wolframe Commercial licenses may
9 use this file in accordance with the Project Wolframe
10 Commercial License Agreement provided with the Software or,
11 alternatively, in accordance with the terms contained
12 in a written agreement between the licensee and Project Wolframe.
13 
14 GNU General Public License Usage
15 Alternatively, you can redistribute this file and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19 
20 Wolframe is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24 
25 You should have received a copy of the GNU General Public License
26 along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
27 
28 If you have questions regarding the use of this file, please contact
29 Project Wolframe.
30 
31 ************************************************************************/
34 #ifndef _Wolframe_SINGLE_FILTER_HPP_INCLUDED
35 #define _Wolframe_SINGLE_FILTER_HPP_INCLUDED
36 #include "filter/typedfilter.hpp"
37 
38 namespace _Wolframe {
39 namespace langbind {
40 
44 {
45 public:
48  :TypedInputFilter("single")
49  ,m_element(e)
50  ,m_consumed(false){}
51 
58 
61 
64  virtual SingleElementInputFilter* copy() const
65  {
66  return new SingleElementInputFilter(*this);
67  }
68 
70  virtual bool getNext( ElementType& type, types::VariantConst& element)
71  {
72  if (m_consumed)
73  {
74  return false;
75  }
76  else
77  {
79  element = m_element;
80  return m_consumed=true;
81  }
82  }
83 
84 private:
86  bool m_consumed;
87 };
88 
89 }}//namespace
90 #endif
91 
92 
virtual bool getNext(ElementType &type, types::VariantConst &element)
Implementation of TypedInputFilter::getNext(ElementType&,Element&)
Definition: singlefilter.hpp:70
Input filter returning one content element only.
Definition: singlefilter.hpp:43
SingleElementInputFilter(const types::VariantConst &e)
Constructor.
Definition: singlefilter.hpp:47
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
bool m_consumed
Definition: singlefilter.hpp:86
ElementType
Content element type that describes the role of the element in the structured input.
Definition: filterbase.hpp:66
virtual ~SingleElementInputFilter()
Destructor.
Definition: singlefilter.hpp:60
content or attribute value
Definition: filterbase.hpp:70
types::VariantConst m_element
Definition: singlefilter.hpp:85
Typed interface for input/output filter.
SingleElementInputFilter(const SingleElementInputFilter &o)
Copy constructor.
Definition: singlefilter.hpp:54
virtual SingleElementInputFilter * copy() const
Get a self copy.
Definition: singlefilter.hpp:64
Input filter with atomic values having a type.
Definition: typedfilter.hpp:48