Wolframe, 0.0.3

tostringfilter.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 
35 #ifndef _Wolframe_FILTER_TOSTRING_FILTER_INTERFACE_HPP_INCLUDED
36 #define _Wolframe_FILTER_TOSTRING_FILTER_INTERFACE_HPP_INCLUDED
37 #include "filter/typedfilter.hpp"
38 #include <string>
39 
40 namespace _Wolframe {
41 namespace langbind {
42 
46 {
47 public:
49  explicit ToStringFilter( const std::string indentstr_="")
50  :TypedOutputFilter("tostring")
51  ,m_contentpos(0)
53  ,m_indentstr(indentstr_)
54  ,m_taglevel(0){}
55 
63  ,m_indent(o.m_indent)
67  virtual ~ToStringFilter(){}
68 
71  virtual TypedOutputFilter* copy() const {return new ToStringFilter(*this);}
72 
74  virtual bool print( ElementType type, const types::VariantConst& element);
75 
76  virtual void getOutput( const void*& buf, std::size_t& bufsize)
77  {
78  buf = (const void*)(m_content.c_str() + m_contentpos);
79  bufsize = m_content.size() - m_contentpos;
80  m_contentpos = m_content.size();
81  }
82 
84  const std::string& content() const {return m_content;}
85 
86 private:
87  std::string m_content;
88  std::size_t m_contentpos;
90  std::string m_indent;
91  std::string m_indentstr;
92  int m_taglevel;
93 };
94 
95 }}//namespace
96 #endif
virtual ~ToStringFilter()
Destructor.
Definition: tostringfilter.hpp:67
const std::string & content() const
Get the content.
Definition: tostringfilter.hpp:84
virtual void getOutput(const void *&buf, std::size_t &bufsize)
Definition: tostringfilter.hpp:76
virtual bool print(ElementType type, const types::VariantConst &element)
Implementation of TypedOutputFilter::print(ElementType,const types::VariantConst&) ...
Output filter for tostring methods in language bindings.
Definition: tostringfilter.hpp:45
Base of input/ouput filter.
Definition: filterbase.hpp:45
FilterBase::ElementType m_lasttype
last parsed element type
Definition: tostringfilter.hpp:89
open new hierarchy level
Definition: filterbase.hpp:68
ToStringFilter(const std::string indentstr_="")
Constructor.
Definition: tostringfilter.hpp:49
virtual TypedOutputFilter * copy() const
Get a self copy.
Definition: tostringfilter.hpp:71
int m_taglevel
count of open tags
Definition: tostringfilter.hpp:92
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
std::string m_indent
indent array
Definition: tostringfilter.hpp:90
ElementType
Content element type that describes the role of the element in the structured input.
Definition: filterbase.hpp:66
Output filter with atomic values having a type.
Definition: typedfilter.hpp:104
std::string m_content
content string
Definition: tostringfilter.hpp:87
std::size_t m_contentpos
position in content string
Definition: tostringfilter.hpp:88
ToStringFilter(const ToStringFilter &o)
Copy constructor.
Definition: tostringfilter.hpp:58
std::string m_indentstr
indentiation string
Definition: tostringfilter.hpp:91
Typed interface for input/output filter.