Wolframe, 0.0.3

input.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_langbind_INPUT_HPP_INCLUDED
35 #define _Wolframe_langbind_INPUT_HPP_INCLUDED
36 #include "filter/filter.hpp"
37 #include "utils/typeSignature.hpp"
38 #include <cstdlib>
39 #include <string>
40 #include <boost/shared_ptr.hpp>
41 
42 namespace _Wolframe {
43 namespace langbind {
44 
47 class Input
48 {
49 public:
52  :m_used(false)
53  ,m_contentsize(0)
54  ,m_gotEoD(false){}
55 
58  Input( const Input& o);
59 
62  Input( const std::string& docformat_);
63 
67  Input( const std::string& docformat_, const std::string& content_);
68 
70  ~Input(){}
71 
74  const InputFilterR& inputfilter() const {return m_inputfilter;}
75 
79 
82  const std::string& docformat() const {return m_docformat;}
83 
87 
90  bool isDocument() const {return !!m_content.get();}
93  const char* documentptr() const {return m_content.get();}
96  std::size_t documentsize() const {return m_content.get()?m_contentsize:0;}
97 
102  void putInput( const void* data, std::size_t datasize, bool eod);
103 
106  void setInputFilter( const InputFilterR& filter);
107 
109  bool gotEoD() const {return m_gotEoD;}
110 
111 private:
112  bool m_used;
114  std::string m_docformat;
115  boost::shared_ptr<char> m_content;
116  std::size_t m_contentsize;
117  std::string m_unconsumedInput;
118  bool m_gotEoD;
119 };
120 
121 }}//namespace
122 #endif
123 
~Input()
Destructor.
Definition: input.hpp:70
void putInput(const void *data, std::size_t datasize, bool eod)
Put input data to filter or buffer it.
const std::string & docformat() const
Get the document format as recognized by the document type detection as string {"xml","json",...}.
Definition: input.hpp:82
bool gotEoD() const
Find out if the input has reached end of data.
Definition: input.hpp:109
std::size_t m_contentsize
size of content in bytes
Definition: input.hpp:116
bool m_gotEoD
Got end of data.
Definition: input.hpp:118
Interface for signature for structures to detect memory problems.
void setInputFilter(const InputFilterR &filter)
Defined the input filter and attach unconsumed input.
InputFilterR & getIterator()
Get the input filter attached to input and check for duplicate access.
InputFilterR & inputfilter()
Get the input filter attached to input.
Definition: input.hpp:78
std::string m_unconsumedInput
unconsumed network input
Definition: input.hpp:117
const InputFilterR & inputfilter() const
Get the input filter attached to input.
Definition: input.hpp:74
Input as seen from the application processor program.
Definition: input.hpp:47
boost::shared_ptr< char > m_content
content source string is input is not from network
Definition: input.hpp:115
bool m_used
only one iterator can be created from input. This is the guard for checking this. ...
Definition: input.hpp:112
InputFilterR m_inputfilter
input is defined by the associated input filter
Definition: input.hpp:113
Input()
Constructor.
Definition: input.hpp:51
const char * documentptr() const
Get content source string if input is not from network.
Definition: input.hpp:93
std::string m_docformat
document format as recognized by the document type detection as string {"xml","json",...}
Definition: input.hpp:114
bool isDocument() const
Eval if this represents a document.
Definition: input.hpp:90
Interface for filter class.
std::size_t documentsize() const
Get size of the content source string if input is not from network.
Definition: input.hpp:96