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/HexBinaryDecoder.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/HexBinaryDecoder.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp | 188 |
1 files changed, 94 insertions, 94 deletions
diff --git a/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp b/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp index 15cdbeb43b..7c80ac8338 100644 --- a/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp +++ b/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp @@ -1,94 +1,94 @@ -// -// HexBinaryDecoder.cpp -// -// Library: Foundation -// Package: Streams -// Module: HexBinary -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/HexBinaryDecoder.h" -#include "Poco/Exception.h" - - -namespace Poco { - - -HexBinaryDecoderBuf::HexBinaryDecoderBuf(std::istream& istr): - _buf(*istr.rdbuf()) -{ -} - - -HexBinaryDecoderBuf::~HexBinaryDecoderBuf() -{ -} - - -int HexBinaryDecoderBuf::readFromDevice() -{ - int c; - int n; - if ((n = readOne()) == -1) return -1; - if (n >= '0' && n <= '9') - c = n - '0'; - else if (n >= 'A' && n <= 'F') - c = n - 'A' + 10; - else if (n >= 'a' && n <= 'f') - c = n - 'a' + 10; - else throw DataFormatException(); - c <<= 4; - if ((n = readOne()) == -1) throw DataFormatException(); - if (n >= '0' && n <= '9') - c |= n - '0'; - else if (n >= 'A' && n <= 'F') - c |= n - 'A' + 10; - else if (n >= 'a' && n <= 'f') - c |= n - 'a' + 10; - else throw DataFormatException(); - return c; -} - - -int HexBinaryDecoderBuf::readOne() -{ - int ch = _buf.sbumpc(); - while (ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n') - ch = _buf.sbumpc(); - return ch; -} - - -HexBinaryDecoderIOS::HexBinaryDecoderIOS(std::istream& istr): _buf(istr) -{ - poco_ios_init(&_buf); -} - - -HexBinaryDecoderIOS::~HexBinaryDecoderIOS() -{ -} - - -HexBinaryDecoderBuf* HexBinaryDecoderIOS::rdbuf() -{ - return &_buf; -} - - -HexBinaryDecoder::HexBinaryDecoder(std::istream& istr): HexBinaryDecoderIOS(istr), std::istream(&_buf) -{ -} - - -HexBinaryDecoder::~HexBinaryDecoder() -{ -} - - -} // namespace Poco +// +// HexBinaryDecoder.cpp +// +// Library: Foundation +// Package: Streams +// Module: HexBinary +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/HexBinaryDecoder.h" +#include "Poco/Exception.h" + + +namespace Poco { + + +HexBinaryDecoderBuf::HexBinaryDecoderBuf(std::istream& istr): + _buf(*istr.rdbuf()) +{ +} + + +HexBinaryDecoderBuf::~HexBinaryDecoderBuf() +{ +} + + +int HexBinaryDecoderBuf::readFromDevice() +{ + int c; + int n; + if ((n = readOne()) == -1) return -1; + if (n >= '0' && n <= '9') + c = n - '0'; + else if (n >= 'A' && n <= 'F') + c = n - 'A' + 10; + else if (n >= 'a' && n <= 'f') + c = n - 'a' + 10; + else throw DataFormatException(); + c <<= 4; + if ((n = readOne()) == -1) throw DataFormatException(); + if (n >= '0' && n <= '9') + c |= n - '0'; + else if (n >= 'A' && n <= 'F') + c |= n - 'A' + 10; + else if (n >= 'a' && n <= 'f') + c |= n - 'a' + 10; + else throw DataFormatException(); + return c; +} + + +int HexBinaryDecoderBuf::readOne() +{ + int ch = _buf.sbumpc(); + while (ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n') + ch = _buf.sbumpc(); + return ch; +} + + +HexBinaryDecoderIOS::HexBinaryDecoderIOS(std::istream& istr): _buf(istr) +{ + poco_ios_init(&_buf); +} + + +HexBinaryDecoderIOS::~HexBinaryDecoderIOS() +{ +} + + +HexBinaryDecoderBuf* HexBinaryDecoderIOS::rdbuf() +{ + return &_buf; +} + + +HexBinaryDecoder::HexBinaryDecoder(std::istream& istr): HexBinaryDecoderIOS(istr), std::istream(&_buf) +{ +} + + +HexBinaryDecoder::~HexBinaryDecoder() +{ +} + + +} // namespace Poco |