[-]
[+]
|
Changed |
lfc.changes
|
|
[-]
[+]
|
Changed |
lfc.spec
^
|
|
[-]
[+]
|
Changed |
lfc-1.3.2.tar.bz2/README
^
|
@@ -4,7 +4,7 @@
------------------------------
A collection of basic c++ classes
- Version 1.3.1
+ Version 1.3.2
(C)opyright 2005,2006,2007,2008,2009,2010,2011,2012 Bjoern Lemke
|
[-]
[+]
|
Changed |
lfc-1.3.2.tar.bz2/samples/TokenTest.cc
^
|
@@ -33,7 +33,7 @@
cout << "ok" << endl;
cout << " Member methods..." << endl;
- Chain s1("AAA@BB!!@CC");
+ Chain s1("AAA@BB!@CC");
Tokenizer t(s1, "@", '\'', '!');
Chain token;
|
[-]
[+]
|
Changed |
lfc-1.3.2.tar.bz2/src/NetHandler.cc
^
|
@@ -67,6 +67,7 @@
_msgSize=0;
_msgBufSize = msgBufSize;
_sizeInfoLen = sizeInfoLen;
+ _concatPos = 0;
_msgBuf = new char[_msgBufSize + _sizeInfoLen];
}
@@ -338,7 +339,6 @@
return _msgSize;
}
-
void NetHandler::setMsg(char* msg, int size)
{
if ( size > _msgBufSize )
@@ -355,6 +355,41 @@
_msgSize=size;
}
+int NetHandler::concatPos()
+{
+ return _concatPos;
+}
+
+void NetHandler::concatReset()
+{
+ _concatPos = 0;
+}
+
+void NetHandler::concatAdd(const Chain& s)
+{
+ concatAdd((char*)s, s.length()-1);
+}
+
+void NetHandler::concatAdd(char* msg, int size)
+{
+ if ( size + _concatPos > _msgBufSize )
+ {
+ int newSize = size + _concatPos + 1;
+ char *newBuf = new char[newSize + _sizeInfoLen];
+
+ memcpy(newBuf, _msgBuf, _msgBufSize + _sizeInfoLen);
+
+ delete _msgBuf;
+
+ _msgBufSize = newSize;
+ _msgBuf = newBuf;
+ }
+ if ( size > 0 )
+ memcpy((char*)((long)_msgBuf + _concatPos + _sizeInfoLen), msg, size);
+
+ _msgSize = size + _concatPos;
+ _concatPos += size;
+}
void NetHandler::disconnect()
{
@@ -372,7 +407,8 @@
memcpy(_msgBuf, nh._msgBuf, _msgBufSize + _sizeInfoLen);
_msgSize = nh._msgSize;
_msgBufSize = nh._msgBufSize;
-
+ _concatPos = nh._concatPos;
+
return (*this);
}
|
[-]
[+]
|
Changed |
lfc-1.3.2.tar.bz2/src/NetHandler.h
^
|
@@ -72,6 +72,11 @@
void setMsg(char* msg, int size);
+ int concatPos();
+ void concatReset();
+ void concatAdd(const Chain& s);
+ void concatAdd(char* msg, int size);
+
void disconnect();
NetHandler& operator = ( const NetHandler& nh);
@@ -84,7 +89,9 @@
int _msgSize;
int _sizeInfoLen;
int _socket;
-
+
+ int _concatPos;
+
};
#endif
|
[-]
[+]
|
Changed |
lfc-1.3.2.tar.bz2/src/Tokenizer.cc
^
|
@@ -41,6 +41,21 @@
Tokenizer::Tokenizer(const Chain& tokenStream, const Chain& sep, char quote, char esc)
{
_tokenStream = tokenStream;
+ _streamBuf = (char*)_tokenStream;
+ _bufLen = _tokenStream.length();
+ _isLocal = true;
+ _sep = sep;
+ _esc = esc;
+ _quote = quote;
+ _lower = 0;
+ _upper = 0;
+}
+
+Tokenizer::Tokenizer(char* buf, int len, const Chain& sep, char quote, char esc)
+{
+ _streamBuf = buf;
+ _bufLen = len;
+ _isLocal = false;
_sep = sep;
_esc = esc;
_quote = quote;
@@ -54,7 +69,8 @@
bool Tokenizer::nextToken(Chain& token)
{
- if ( _tokenStream.length() <= _upper)
+
+ if ( _bufLen <= _upper)
return false;
int si;
@@ -74,7 +90,7 @@
char c;
c = _sep[si];
- if (_tokenStream[_upper] == c)
+ if (_streamBuf[_upper] == c)
{
sepFound = true;
}
@@ -88,41 +104,36 @@
_lower = _upper;
- while (sepFound == false && _tokenStream[_upper])
+ while (sepFound == false && _streamBuf[_upper])
{
- if ( _tokenStream[_upper] == _esc )
+ if ( _streamBuf[_upper] == _esc )
{
_upper++;
- if ( _tokenStream[_upper] )
- _upper++;
+ if ( _streamBuf[_upper] )
+ {
+ if ( checkSeparator() )
+ {
+ _upper++;
+ }
+ }
else
throw Exception(EXLOC, Chain("Unexpected end of token steam"));
}
- else if ( _tokenStream[_upper] )
+ else if ( _streamBuf[_upper] )
{
if ( isQuoted )
{
- if (_tokenStream[_upper] == _quote)
+ if (_streamBuf[_upper] == _quote)
isQuoted = false;
}
- else if ( _tokenStream[_upper] == _quote)
+ else if ( _streamBuf[_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++;
- }
+ sepFound = checkSeparator();
}
if (sepFound == false)
{
@@ -135,20 +146,40 @@
{
return false;
}
-
- token = _tokenStream.subChain(_lower+1, _upper);
+
+ token = Chain(_streamBuf + _lower, _upper - _lower);
+
+ // token = _tokenStream.subChain(_lower+1, _upper);
_lower = _upper;
return true;
}
+bool Tokenizer::checkSeparator()
+{
+ bool sepFound=false;
+ int si=0;
+ while ( sepFound == false && si<_sep.length()-1)
+ {
+ char c;
+ c = _sep[si];
+ if (_streamBuf[_upper] == c)
+ {
+ sepFound = true;
+ }
+ si++;
+ }
+ return sepFound;
+}
+
bool Tokenizer::getTail(Chain& token)
{
- if (_tokenStream.length() > _lower+1)
+ if ( _bufLen > _lower+1 )
{
- token = _tokenStream.subChain(_lower+1, _tokenStream.length());
+ token = Chain(_streamBuf + _lower, _bufLen - _lower);
+ //token = _tokenStream.subChain(_lower+1, _tokenStream.length());
return true;
}
return false;
@@ -157,13 +188,23 @@
int Tokenizer::numAhead() const
{
- return _tokenStream.length() - _lower - 1;
+ return _bufLen - _lower - 1;
}
+void Tokenizer::reset(char* buf, int len)
+{
+ _streamBuf = buf;
+ _bufLen = len;
+ _isLocal = false;
+ _lower = 0;
+ _upper = 0;
+}
Tokenizer& Tokenizer::operator = (const Tokenizer& t)
{
_tokenStream = t._tokenStream;
+ _streamBuf = t._streamBuf;
+ _bufLen = t._bufLen;
_sep = t._sep;
_esc = t._esc;
_quote = t._quote;
|
[-]
[+]
|
Changed |
lfc-1.3.2.tar.bz2/src/Tokenizer.h
^
|
@@ -46,6 +46,7 @@
public:
Tokenizer(const Chain& tokenStream, const Chain& sep, char quote = '\'', char esc = '\\');
+ Tokenizer(char* buf, int len, const Chain& sep, char quote = '\'', char esc = '\\');
~Tokenizer();
bool nextToken(Chain& token);
@@ -53,10 +54,18 @@
int numAhead() const;
+ void reset(char* buf, int len);
+
Tokenizer& operator = (const Tokenizer& t);
private:
+ bool checkSeparator();
+
+ bool _isLocal;
+ char *_streamBuf;
+ int _bufLen;
+
Chain _tokenStream;
Chain _sep;
char _quote;
|
[-]
[+]
|
Changed |
lfc-1.3.2.tar.bz2/src/Version.cc
^
|
@@ -32,7 +32,7 @@
// Status: IMPLEMENTED
///////////////////////////////////////////////////////////////////////////////
-char __lfcVersionString[] = "1.3.1";
+char __lfcVersionString[] = "1.3.2";
|