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/Util/src/IntValidator.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/Util/src/IntValidator.cpp')
-rw-r--r-- | contrib/libs/poco/Util/src/IntValidator.cpp | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/contrib/libs/poco/Util/src/IntValidator.cpp b/contrib/libs/poco/Util/src/IntValidator.cpp index 347fde30b8..e5372ee098 100644 --- a/contrib/libs/poco/Util/src/IntValidator.cpp +++ b/contrib/libs/poco/Util/src/IntValidator.cpp @@ -1,54 +1,54 @@ -// -// IntValidator.cpp -// -// Library: Util -// Package: Options -// Module: IntValidator -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Util/IntValidator.h" -#include "Poco/Util/Option.h" -#include "Poco/Util/OptionException.h" -#include "Poco/NumberParser.h" -#include "Poco/Format.h" - - -using Poco::NumberParser; -using Poco::format; - - -namespace Poco { -namespace Util { - - -IntValidator::IntValidator(int min, int max): - _min(min), - _max(max) -{ -} - - -IntValidator::~IntValidator() -{ -} - - -void IntValidator::validate(const Option& option, const std::string& value) -{ - int n; - if (NumberParser::tryParse(value, n)) - { - if (n < _min || n > _max) - throw InvalidArgumentException(format("argument for %s must be in range %d to %d", option.fullName(), _min, _max)); - } - else throw InvalidArgumentException(format("argument for %s must be an integer", option.fullName())); -} - - -} } // namespace Poco::Util +// +// IntValidator.cpp +// +// Library: Util +// Package: Options +// Module: IntValidator +// +// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/Util/IntValidator.h" +#include "Poco/Util/Option.h" +#include "Poco/Util/OptionException.h" +#include "Poco/NumberParser.h" +#include "Poco/Format.h" + + +using Poco::NumberParser; +using Poco::format; + + +namespace Poco { +namespace Util { + + +IntValidator::IntValidator(int min, int max): + _min(min), + _max(max) +{ +} + + +IntValidator::~IntValidator() +{ +} + + +void IntValidator::validate(const Option& option, const std::string& value) +{ + int n; + if (NumberParser::tryParse(value, n)) + { + if (n < _min || n > _max) + throw InvalidArgumentException(format("argument for %s must be in range %d to %d", option.fullName(), _min, _max)); + } + else throw InvalidArgumentException(format("argument for %s must be an integer", option.fullName())); +} + + +} } // namespace Poco::Util |