Wolframe, 0.0.3

asciiCharParser.hpp
Go to the documentation of this file.
1 /************************************************************************
2 
3  Copyright (C) 2011 - 2014 Project Wolframe.
4  All rights reserved.
5 
6  This file is part of Project Wolframe.
7 
8  Commercial Usage
9  Licensees holding valid Project Wolframe Commercial licenses may
10  use this file in accordance with the Project Wolframe
11  Commercial License Agreement provided with the Software or,
12  alternatively, in accordance with the terms contained
13  in a written agreement between the licensee and Project Wolframe.
14 
15  GNU General Public License Usage
16  Alternatively, you can redistribute this file and/or modify it
17  under the terms of the GNU General Public License as published by
18  the Free Software Foundation, either version 3 of the License, or
19  (at your option) any later version.
20 
21  Wolframe is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  GNU General Public License for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
28 
29  If you have questions regarding the use of this file, please contact
30  Project Wolframe.
31 
32 ************************************************************************/
36 
37 #ifndef _WOLFRAME_UTILS_ASCII_CHAR_PARSER_HPP_INCLUDED
38 #define _WOLFRAME_UTILS_ASCII_CHAR_PARSER_HPP_INCLUDED
39 #include <cstddef>
40 
41 namespace _Wolframe {
42 namespace utils {
43 
47 {
48 public:
49  enum Encoding
50  {
52  };
56 
59  void putInput( const char* src, std::size_t srcsize);
60 
62  unsigned char getNext();
63 
65  const char* lastError() const {return m_lastError;}
66 
67 private:
68  bool prepareChar( unsigned int chrsize);
69  void consumeChar( unsigned int chrsize);
70 
71 private:
72  const char* m_src;
73  std::size_t m_itr;
74  std::size_t m_end;
75  const char* m_lastError;
77  enum {BufSize=8};
78  unsigned char m_buf[ BufSize];
79  std::size_t m_bufsize;
80 };
81 
82 }}
83 #endif
84 
const char * lastError() const
Get the last error occurred.
Definition: asciiCharParser.hpp:65
std::size_t m_bufsize
Definition: asciiCharParser.hpp:79
Definition: asciiCharParser.hpp:51
Encoding m_encoding
Definition: asciiCharParser.hpp:76
Class for parsing ascii character by character from a source in an unicode based encoding.
Definition: asciiCharParser.hpp:46
const char * m_src
Definition: asciiCharParser.hpp:72
AsciiCharParser()
Constructor.
Definition: asciiCharParser.hpp:54
unsigned char getNext()
Get the next ASCII character or 0, if at the end of the current input block or an error occurred (to ...
Definition: asciiCharParser.hpp:51
std::size_t m_itr
Definition: asciiCharParser.hpp:73
bool prepareChar(unsigned int chrsize)
const char * m_lastError
Definition: asciiCharParser.hpp:75
Encoding
Definition: asciiCharParser.hpp:49
std::size_t m_end
Definition: asciiCharParser.hpp:74
Definition: asciiCharParser.hpp:77
void consumeChar(unsigned int chrsize)
unsigned char m_buf[BufSize]
Definition: asciiCharParser.hpp:78
Definition: asciiCharParser.hpp:51
Definition: asciiCharParser.hpp:51
void putInput(const char *src, std::size_t srcsize)
Feed next input block.
Definition: asciiCharParser.hpp:51
Definition: asciiCharParser.hpp:51