mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-28 10:47:10 +02:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
105
vendor/POCO/Foundation/src/StreamTokenizer.cpp
vendored
Normal file
105
vendor/POCO/Foundation/src/StreamTokenizer.cpp
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// StreamTokenizer.cpp
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
// Module: StreamTokenizer
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/StreamTokenizer.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
StreamTokenizer::StreamTokenizer():
|
||||
_pIstr(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
StreamTokenizer::StreamTokenizer(std::istream& istr):
|
||||
_pIstr(&istr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
StreamTokenizer::~StreamTokenizer()
|
||||
{
|
||||
for (auto& t: _tokens)
|
||||
{
|
||||
delete t.pToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StreamTokenizer::attachToStream(std::istream& istr)
|
||||
{
|
||||
_pIstr = &istr;
|
||||
}
|
||||
|
||||
|
||||
void StreamTokenizer::addToken(Token* pToken)
|
||||
{
|
||||
poco_check_ptr (pToken);
|
||||
|
||||
TokenInfo ti;
|
||||
ti.pToken = pToken;
|
||||
ti.ignore = (pToken->tokenClass() == Token::COMMENT_TOKEN || pToken->tokenClass() == Token::WHITESPACE_TOKEN);
|
||||
_tokens.push_back(ti);
|
||||
}
|
||||
|
||||
|
||||
void StreamTokenizer::addToken(Token* pToken, bool ignore)
|
||||
{
|
||||
poco_check_ptr (pToken);
|
||||
|
||||
TokenInfo ti;
|
||||
ti.pToken = pToken;
|
||||
ti.ignore = ignore;
|
||||
_tokens.push_back(ti);
|
||||
}
|
||||
|
||||
|
||||
const Token* StreamTokenizer::next()
|
||||
{
|
||||
poco_check_ptr (_pIstr);
|
||||
|
||||
static const int eof = std::char_traits<char>::eof();
|
||||
|
||||
int first = _pIstr->get();
|
||||
TokenVec::const_iterator it = _tokens.begin();
|
||||
while (first != eof && it != _tokens.end())
|
||||
{
|
||||
const TokenInfo& ti = *it;
|
||||
if (ti.pToken->start((char) first, *_pIstr))
|
||||
{
|
||||
ti.pToken->finish(*_pIstr);
|
||||
if (ti.ignore)
|
||||
{
|
||||
first = _pIstr->get();
|
||||
it = _tokens.begin();
|
||||
}
|
||||
else return ti.pToken;
|
||||
}
|
||||
else ++it;
|
||||
}
|
||||
if (first == eof)
|
||||
{
|
||||
return &_eofToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
_invalidToken.start((char) first, *_pIstr);
|
||||
return &_invalidToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
Reference in New Issue
Block a user