diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Foundation/src/StreamTokenizer.cpp | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src/StreamTokenizer.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/StreamTokenizer.cpp | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp b/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp index 15f554ca90..1b6e936274 100644 --- a/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp +++ b/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp @@ -1,105 +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 (TokenVec::iterator it = _tokens.begin(); it != _tokens.end(); ++it) - { - delete it->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 +// +// 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 (TokenVec::iterator it = _tokens.begin(); it != _tokens.end(); ++it) + { + delete it->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 |