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/CountingStream.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/CountingStream.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/CountingStream.cpp | 398 |
1 files changed, 199 insertions, 199 deletions
diff --git a/contrib/libs/poco/Foundation/src/CountingStream.cpp b/contrib/libs/poco/Foundation/src/CountingStream.cpp index bce4629656..b3f56b345b 100644 --- a/contrib/libs/poco/Foundation/src/CountingStream.cpp +++ b/contrib/libs/poco/Foundation/src/CountingStream.cpp @@ -1,199 +1,199 @@ -// -// CountingStream.cpp -// -// Library: Foundation -// Package: Streams -// Module: CountingStream -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/CountingStream.h" - - -namespace Poco { - - -CountingStreamBuf::CountingStreamBuf(): - _pIstr(0), - _pOstr(0), - _chars(0), - _lines(0), - _pos(0) -{ -} - - -CountingStreamBuf::CountingStreamBuf(std::istream& istr): - _pIstr(&istr), - _pOstr(0), - _chars(0), - _lines(0), - _pos(0) -{ -} - - -CountingStreamBuf::CountingStreamBuf(std::ostream& ostr): - _pIstr(0), - _pOstr(&ostr), - _chars(0), - _lines(0), - _pos(0) -{ -} - - -CountingStreamBuf::~CountingStreamBuf() -{ -} - - -int CountingStreamBuf::readFromDevice() -{ - if (_pIstr) - { - int c = _pIstr->get(); - if (c != -1) - { - ++_chars; - if (_pos++ == 0) ++_lines; - if (c == '\n') _pos = 0; - } - return c; - } - return -1; -} - - -int CountingStreamBuf::writeToDevice(char c) -{ - ++_chars; - if (_pos++ == 0) ++_lines; - if (c == '\n') _pos = 0; - if (_pOstr) _pOstr->put(c); - return charToInt(c); -} - - -void CountingStreamBuf::reset() -{ - _chars = 0; - _lines = 0; - _pos = 0; -} - - -void CountingStreamBuf::setCurrentLineNumber(int line) -{ - _lines = line; -} - - -void CountingStreamBuf::addChars(int charsToAdd) -{ - _chars += charsToAdd; -} - - -void CountingStreamBuf::addLines(int linesToAdd) -{ - _lines += linesToAdd; -} - - -void CountingStreamBuf::addPos(int posToAdd) -{ - _pos += posToAdd; -} - - -CountingIOS::CountingIOS() -{ - poco_ios_init(&_buf); -} - - -CountingIOS::CountingIOS(std::istream& istr): _buf(istr) -{ - poco_ios_init(&_buf); -} - - -CountingIOS::CountingIOS(std::ostream& ostr): _buf(ostr) -{ - poco_ios_init(&_buf); -} - - -CountingIOS::~CountingIOS() -{ -} - - -void CountingIOS::reset() -{ - _buf.reset(); -} - - -void CountingIOS::setCurrentLineNumber(int line) -{ - _buf.setCurrentLineNumber(line); -} - - -void CountingIOS::addChars(int charsToAdd) -{ - _buf.addChars(charsToAdd); -} - - -void CountingIOS::addLines(int linesToAdd) -{ - _buf.addLines(linesToAdd); -} - - -void CountingIOS::addPos(int posToAdd) -{ - _buf.addPos(posToAdd); -} - - -CountingStreamBuf* CountingIOS::rdbuf() -{ - return &_buf; -} - - -CountingInputStream::CountingInputStream(std::istream& istr): CountingIOS(istr), std::istream(&_buf) -{ -} - - -CountingInputStream::~CountingInputStream() -{ -} - - -CountingOutputStream::CountingOutputStream(): std::ostream(&_buf) -{ -} - - -CountingOutputStream::CountingOutputStream(std::ostream& ostr): CountingIOS(ostr), std::ostream(&_buf) -{ -} - - -CountingOutputStream::~CountingOutputStream() -{ -} - - -} // namespace Poco +// +// CountingStream.cpp +// +// Library: Foundation +// Package: Streams +// Module: CountingStream +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/CountingStream.h" + + +namespace Poco { + + +CountingStreamBuf::CountingStreamBuf(): + _pIstr(0), + _pOstr(0), + _chars(0), + _lines(0), + _pos(0) +{ +} + + +CountingStreamBuf::CountingStreamBuf(std::istream& istr): + _pIstr(&istr), + _pOstr(0), + _chars(0), + _lines(0), + _pos(0) +{ +} + + +CountingStreamBuf::CountingStreamBuf(std::ostream& ostr): + _pIstr(0), + _pOstr(&ostr), + _chars(0), + _lines(0), + _pos(0) +{ +} + + +CountingStreamBuf::~CountingStreamBuf() +{ +} + + +int CountingStreamBuf::readFromDevice() +{ + if (_pIstr) + { + int c = _pIstr->get(); + if (c != -1) + { + ++_chars; + if (_pos++ == 0) ++_lines; + if (c == '\n') _pos = 0; + } + return c; + } + return -1; +} + + +int CountingStreamBuf::writeToDevice(char c) +{ + ++_chars; + if (_pos++ == 0) ++_lines; + if (c == '\n') _pos = 0; + if (_pOstr) _pOstr->put(c); + return charToInt(c); +} + + +void CountingStreamBuf::reset() +{ + _chars = 0; + _lines = 0; + _pos = 0; +} + + +void CountingStreamBuf::setCurrentLineNumber(int line) +{ + _lines = line; +} + + +void CountingStreamBuf::addChars(int charsToAdd) +{ + _chars += charsToAdd; +} + + +void CountingStreamBuf::addLines(int linesToAdd) +{ + _lines += linesToAdd; +} + + +void CountingStreamBuf::addPos(int posToAdd) +{ + _pos += posToAdd; +} + + +CountingIOS::CountingIOS() +{ + poco_ios_init(&_buf); +} + + +CountingIOS::CountingIOS(std::istream& istr): _buf(istr) +{ + poco_ios_init(&_buf); +} + + +CountingIOS::CountingIOS(std::ostream& ostr): _buf(ostr) +{ + poco_ios_init(&_buf); +} + + +CountingIOS::~CountingIOS() +{ +} + + +void CountingIOS::reset() +{ + _buf.reset(); +} + + +void CountingIOS::setCurrentLineNumber(int line) +{ + _buf.setCurrentLineNumber(line); +} + + +void CountingIOS::addChars(int charsToAdd) +{ + _buf.addChars(charsToAdd); +} + + +void CountingIOS::addLines(int linesToAdd) +{ + _buf.addLines(linesToAdd); +} + + +void CountingIOS::addPos(int posToAdd) +{ + _buf.addPos(posToAdd); +} + + +CountingStreamBuf* CountingIOS::rdbuf() +{ + return &_buf; +} + + +CountingInputStream::CountingInputStream(std::istream& istr): CountingIOS(istr), std::istream(&_buf) +{ +} + + +CountingInputStream::~CountingInputStream() +{ +} + + +CountingOutputStream::CountingOutputStream(): std::ostream(&_buf) +{ +} + + +CountingOutputStream::CountingOutputStream(std::ostream& ostr): CountingIOS(ostr), std::ostream(&_buf) +{ +} + + +CountingOutputStream::~CountingOutputStream() +{ +} + + +} // namespace Poco |