Wolframe, 0.0.3

typingfilter.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_TYPING_FILTER_HPP_INCLUDED
35 #define _Wolframe_TYPING_FILTER_HPP_INCLUDED
36 #include "filter/typedfilter.hpp"
37 #include <vector>
38 
39 namespace _Wolframe {
40 namespace langbind {
41 
45 {
46 public:
48  explicit TypingInputFilter( const InputFilterR& inp)
49  :TypedInputFilter(inp->name())
50  ,m_inputfilter(inp)
51  {
52  setFlags( inp->flags());
53  }
54 
60  ,m_stack(o.m_stack){}
61 
63  virtual ~TypingInputFilter(){}
64 
67  virtual TypedInputFilter* copy() const {return new TypingInputFilter(*this);}
68 
70  virtual bool getNext( ElementType& type, types::VariantConst& element);
71 
73  virtual bool setFlags( Flags f);
74 
76  virtual bool checkSetFlags( Flags f) const;
77 
79  virtual const char* getError() const;
80 
81 private:
83  struct StackElement
84  {
86  unsigned int cnt;
87 
91  :isArrayElem(false),cnt(0){}
92  };
94  std::vector<StackElement> m_stack;
95 };
96 
97 
101 {
102 public:
104  explicit TypingOutputFilter( const OutputFilterR& outp)
105  :TypedOutputFilter(outp->name())
106  ,m_outputfilter(outp)
107  {
108  setFlags( outp->flags());
109  }
110 
116 
119 
122  virtual TypedOutputFilter* copy() const {return new TypingOutputFilter(*this);}
123 
125  virtual bool print( ElementType type, const types::VariantConst& element);
126 
127 private:
129 };
130 
131 }}//namespace
132 #endif
133 
134 
virtual bool setFlags(Flags f)
Implementation of TypedInputFilter::setFlags(Flags)
StackElement(const StackElement &o)
Definition: typingfilter.hpp:88
virtual const char * getError() const
Get the last error.
StackElement()
Definition: typingfilter.hpp:90
virtual TypedOutputFilter * copy() const
Get a self copy.
Definition: typingfilter.hpp:122
TypingOutputFilter(const TypingOutputFilter &o)
Copy constructor.
Definition: typingfilter.hpp:113
virtual bool print(ElementType type, const types::VariantConst &element)
Implementation of TypedOutputFilter::print( ElementType,const types::VariantConst&) ...
virtual ~TypingInputFilter()
Destructor.
Definition: typingfilter.hpp:63
TypingInputFilter(const TypingInputFilter &o)
Copy constructor.
Definition: typingfilter.hpp:57
Flags
Definition: filterbase.hpp:106
const char * name() const
Get the name of the filter.
Definition: filterbase.hpp:129
unsigned int cnt
Definition: typingfilter.hpp:86
Stack element of the input filter state stack.
Definition: typingfilter.hpp:83
virtual ~TypingOutputFilter()
Destructor.
Definition: typingfilter.hpp:118
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
virtual bool setFlags(Flags f)
Set a flag (or a set of flags)
Definition: filterbase.hpp:124
ElementType
Content element type that describes the role of the element in the structured input.
Definition: filterbase.hpp:66
virtual bool checkSetFlags(Flags f) const
Implements FilterBase::checkSetFlags()const.
TypingOutputFilter(const OutputFilterR &outp)
Constructor.
Definition: typingfilter.hpp:104
Output filter with atomic values having a type.
Definition: typedfilter.hpp:104
OutputFilterR m_outputfilter
Definition: typingfilter.hpp:128
TypingInputFilter(const InputFilterR &inp)
Constructor.
Definition: typingfilter.hpp:48
std::vector< StackElement > m_stack
Definition: typingfilter.hpp:94
virtual bool getNext(ElementType &type, types::VariantConst &element)
Implementation of TypedInputFilter::getNext(ElementType&,types::VariantConst&)
InputFilterR m_inputfilter
Definition: typingfilter.hpp:93
bool isArrayElem
Definition: typingfilter.hpp:85
Typed fascade for input filter.
Definition: typingfilter.hpp:44
Typed fascade for output filter.
Definition: typingfilter.hpp:100
virtual TypedInputFilter * copy() const
Get a self copy.
Definition: typingfilter.hpp:67
Typed interface for input/output filter.
Input filter with atomic values having a type.
Definition: typedfilter.hpp:48