2
/******************************************************
3
* Presage, an extensible predictive text entry system
4
* ---------------------------------------------------
6
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License along
19
with this program; if not, write to the Free Software Foundation, Inc.,
20
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
#include "tokenizer.h"
29
const std::string blankspaces,
30
const std::string separators
35
// this should be changed to deal with a !good() stream
37
//assert(stream.good());
39
offset = stream.tellg();
40
sstate = stream.rdstate();
42
StreamGuard(stream, offset);
44
stream.seekg(0, std::ios::end);
45
offend = stream.tellg();
46
stream.seekg(0, std::ios::beg);
47
offbeg = stream.tellg();
49
blankspaceChars(blankspaces);
50
separatorChars (separators );
53
Tokenizer::~Tokenizer()
55
// reset stream state to enable repeatability
56
// (see reverseTokenizerTest::testRepeatability())
57
stream.setstate(sstate);
61
void Tokenizer::blankspaceChars(const std::string chars)
66
std::string Tokenizer::blankspaceChars() const
71
void Tokenizer::separatorChars(const std::string chars)
76
std::string Tokenizer::separatorChars() const
81
void Tokenizer::lowercaseMode(const bool value)
86
bool Tokenizer::lowercaseMode() const
91
bool Tokenizer::isBlankspace(const int character) const
93
std::string::size_type ret = blankspaces.find(character);
94
if (ret == std::string::npos) {
101
bool Tokenizer::isSeparator(const int character) const
103
std::string::size_type ret = separators.find(character);
104
if (ret == std::string::npos) {