mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 00:46:03 +01:00
b0581433a7
fix: remove executable flag and change back to 100644 (was 100755) Signed-off-by: Roger Meier <r.meier@siemens.com>
50 lines
990 B
C++
50 lines
990 B
C++
//
|
|
// RegExpValidator.cpp
|
|
//
|
|
// $Id: //poco/1.4/Util/src/RegExpValidator.cpp#1 $
|
|
//
|
|
// Library: Util
|
|
// Package: Options
|
|
// Module: RegExpValidator
|
|
//
|
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/Util/RegExpValidator.h"
|
|
#include "Poco/Util/Option.h"
|
|
#include "Poco/Util/OptionException.h"
|
|
#include "Poco/RegularExpression.h"
|
|
#include "Poco/Format.h"
|
|
|
|
|
|
using Poco::format;
|
|
|
|
|
|
namespace Poco {
|
|
namespace Util {
|
|
|
|
|
|
RegExpValidator::RegExpValidator(const std::string& regexp):
|
|
_regexp(regexp)
|
|
{
|
|
}
|
|
|
|
|
|
RegExpValidator::~RegExpValidator()
|
|
{
|
|
}
|
|
|
|
|
|
void RegExpValidator::validate(const Option& option, const std::string& value)
|
|
{
|
|
if (!RegularExpression::match(value, _regexp, RegularExpression::RE_ANCHORED | RegularExpression::RE_UTF8))
|
|
throw InvalidArgumentException(format("argument for %s does not match regular expression %s", option.fullName(), _regexp));
|
|
}
|
|
|
|
|
|
} } // namespace Poco::Util
|