[-]
[+]
|
Changed |
lfc.changes
|
|
[-]
[+]
|
Changed |
lfc.spec
^
|
|
[-]
[+]
|
Changed |
lfc-1.3.0.tar.bz2/README
^
|
@@ -4,7 +4,7 @@
------------------------------
A collection of basic c++ classes
- Version 1.2.0
+ Version 1.3.0
(C)opyright 2005, 2006, 2007, 2008, 2009, 2010, 2011,2012 Bjoern Lemke
|
[-]
[+]
|
Changed |
lfc-1.3.0.tar.bz2/samples/TokenTest.cc
^
|
@@ -27,19 +27,22 @@
if ( 1 )
{
- Tokenizer t("HHHHH", "%");
+ Tokenizer t("HHHHH", "%", '\'', '!');
}
cout << "ok" << endl;
- cout << " Member methods...";
+ cout << " Member methods..." << endl;
- Chain s1("hurga%xxx%tokenizer%test stream");
- Tokenizer t(s1, "%");
+ Chain s1("AAA@BB!!@CC");
+ Tokenizer t(s1, "@", '\'', '!');
Chain token;
- while (t.nextToken(token) == true)
- cout << token << endl;
-
+ while (t.nextToken(token) == true)
+ {
+
+ cout << "t=" << token << endl;
+ cout << "Ahead=" << t.numAhead() << endl;
+ }
cout << "ok" << endl;
cout << "------------------------" << endl;
|
[-]
[+]
|
Changed |
lfc-1.3.0.tar.bz2/src/Tokenizer.cc
^
|
@@ -36,12 +36,14 @@
// BASE INCLUDES
#include "Chain.h"
#include "Tokenizer.h"
+#include "Exception.h"
-Tokenizer::Tokenizer(const Chain& tokenStream, const Chain& sep, char esc)
+Tokenizer::Tokenizer(const Chain& tokenStream, const Chain& sep, char quote, char esc)
{
_tokenStream = tokenStream;
_sep = sep;
_esc = esc;
+ _quote = quote;
_lower = 0;
_upper = 0;
}
@@ -58,7 +60,7 @@
int si;
bool sepFound = true;
- bool isEscaped=false;
+ bool isQuoted=false;
// skip through sep
@@ -88,34 +90,44 @@
while (sepFound == false && _tokenStream[_upper])
{
- si=0;
-
- if ( isEscaped )
+ if ( _tokenStream[_upper] == _esc )
{
+ _upper++;
+ if ( _tokenStream[_upper] )
+ _upper++;
+ else
+ throw Exception(EXLOC, Chain("Unexpected end of token steam"));
- if (_tokenStream[_upper] == _esc)
- isEscaped = false;
}
- else if ( _tokenStream[_upper] == _esc)
+ else if ( _tokenStream[_upper] )
{
- isEscaped = true;
- }
- else
- {
- while ( sepFound == false && si<_sep.length()-1)
- {
- char c;
- c = _sep[si];
- if (_tokenStream[_upper] == c)
- {
- sepFound = true;
+ if ( isQuoted )
+ {
+ if (_tokenStream[_upper] == _quote)
+ isQuoted = false;
+ }
+ else if ( _tokenStream[_upper] == _quote)
+ {
+ isQuoted = true;
+ }
+ else
+ {
+ si=0;
+ while ( sepFound == false && si<_sep.length()-1)
+ {
+ char c;
+ c = _sep[si];
+ if (_tokenStream[_upper] == c)
+ {
+ sepFound = true;
+ }
+ si++;
}
- si++;
}
- }
- if (sepFound == false)
- {
- _upper++;
+ if (sepFound == false)
+ {
+ _upper++;
+ }
}
}
@@ -143,10 +155,18 @@
}
+int Tokenizer::numAhead() const
+{
+ return _tokenStream.length() - _lower - 1;
+}
+
+
Tokenizer& Tokenizer::operator = (const Tokenizer& t)
{
_tokenStream = t._tokenStream;
_sep = t._sep;
+ _esc = t._esc;
+ _quote = t._quote;
_lower = t._lower;
_upper = t._upper;
return (*this);
|
[-]
[+]
|
Changed |
lfc-1.3.0.tar.bz2/src/Tokenizer.h
^
|
@@ -39,25 +39,27 @@
#include "Chain.h"
-
// CLASS DEFINITION
class Tokenizer {
public:
- Tokenizer(const Chain& tokenStream, const Chain& sep, char esc = '\'');
+ Tokenizer(const Chain& tokenStream, const Chain& sep, char quote = '\'', char esc = '\\');
~Tokenizer();
bool nextToken(Chain& token);
bool getTail(Chain& token);
-
+
+ int numAhead() const;
+
Tokenizer& operator = (const Tokenizer& t);
private:
Chain _tokenStream;
Chain _sep;
+ char _quote;
char _esc;
int _lower;
|
[-]
[+]
|
Changed |
lfc-1.3.0.tar.bz2/src/Version.cc
^
|
@@ -6,7 +6,7 @@
//
// Design and Implementation by Bjoern Lemke
//
-// (C)opyright 2000-2010 Bjoern Lemke
+// (C)opyright 2000-2012 Bjoern Lemke
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
// Status: IMPLEMENTED
///////////////////////////////////////////////////////////////////////////////
-char __lfcVersionString[] = "1.2.0";
+char __lfcVersionString[] = "1.3.0";
|