aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Util/src/RegExpValidator.cpp
blob: 15533406508a2d170b79d05d79a11cf4846a6bca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// RegExpValidator.cpp
//
// 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