Wolframe, 0.0.3

doctypeDetector.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_CMDBIND_DOCTYPE_DETECTOR_HPP_INCLUDED
36 #define _Wolframe_CMDBIND_DOCTYPE_DETECTOR_HPP_INCLUDED
37 #include "types/doctypeinfo.hpp"
38 #include <string>
39 #include <boost/shared_ptr.hpp>
40 
41 namespace _Wolframe {
42 namespace cmdbind {
43 
47 {
48  public:
49 
51  virtual ~DoctypeDetector(){}
52 
57  virtual void putInput( const char* chunk, std::size_t chunksize)=0;
58 
61  virtual bool run()=0;
62 
66  virtual const char* lastError() const=0;
67 
70  virtual const types::DoctypeInfoR& info() const=0;
71 };
72 
74 typedef boost::shared_ptr<DoctypeDetector> DoctypeDetectorR;
75 
77 typedef DoctypeDetector* (*CreateDoctypeDetector)();
78 
79 
83 {
84 public:
87  :m_create(0){}
89  DoctypeDetectorType( const std::string& name_, CreateDoctypeDetector create_)
90  :m_name(name_),m_create(create_){}
91 
94 
97  {
98  return m_create();
99  }
100 
102  const std::string& name() const
103  {
104  return m_name;
105  }
106 
107 private:
108  std::string m_name;
110 };
111 
112 }}//namespace
113 #endif
114 
DoctypeDetector * create() const
Create an instance.
Definition: doctypeDetector.hpp:96
boost::shared_ptr< DoctypeDetector > DoctypeDetectorR
Shared doctype detector reference.
Definition: doctypeDetector.hpp:74
boost::shared_ptr< DoctypeInfo > DoctypeInfoR
Definition: doctypeinfo.hpp:74
DoctypeDetectorType(const std::string &name_, CreateDoctypeDetector create_)
Constructor.
Definition: doctypeDetector.hpp:89
CreateDoctypeDetector m_create
Definition: doctypeDetector.hpp:109
DoctypeDetector *(* CreateDoctypeDetector)()
Constructor function for doctype detector instance.
Definition: doctypeDetector.hpp:77
Structure for document type and format.
DoctypeDetectorType()
Default constructor.
Definition: doctypeDetector.hpp:86
virtual void putInput(const char *chunk, std::size_t chunksize)=0
Feed document type detection with more data.
virtual const char * lastError() const =0
Get the last error occurred.
std::string m_name
Definition: doctypeDetector.hpp:108
virtual const types::DoctypeInfoR & info() const =0
Get the result of document type and format recognition.
const std::string & name() const
Get the doctype detector name (usually docformat name)
Definition: doctypeDetector.hpp:102
virtual ~DoctypeDetector()
Destructor.
Definition: doctypeDetector.hpp:51
Interface to document type and format detection.
Definition: doctypeDetector.hpp:46
Constructor as class.
Definition: doctypeDetector.hpp:82
virtual bool run()=0
Start or continue running the document type and format detection.
DoctypeDetectorType(const DoctypeDetectorType &o)
Definition: doctypeDetector.hpp:92