Keyple Util C++ Library 2.0.0
Reference Terminal Reader API for C++
Pattern.cpp
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional information regarding *
5 * copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the terms of the Eclipse *
8 * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 *
9 * *
10 * SPDX-License-Identifier: EPL-2.0 *
11 **************************************************************************************************/
12
13#include "Pattern.h"
14
15/* Keyple Core Utils */
17
18namespace keyple {
19namespace core {
20namespace util {
21namespace cpp {
22
24
25Pattern::Pattern(const std::string& pattern, const int flags) : mPattern(pattern), mFlags(flags) {}
26
27std::unique_ptr<Pattern> Pattern::compile(const std::string& regularExpression, const int flags)
28 const
29{
30 /* Compiler hack */
31 (void)mFlags;
32
33 try {
34 return std::unique_ptr<Pattern>(new Pattern(regularExpression, flags));
35 } catch (const std::exception& e) {
36 throw PatternSyntaxException(e.what());
37 }
38}
39
40std::unique_ptr<Pattern> Pattern::compile(const std::string& pattern)
41{
42 try {
43 return std::unique_ptr<Pattern>(new Pattern(pattern, 0));
44 } catch (const std::exception& e) {
45 throw PatternSyntaxException(e.what());
46 }
47}
48
49std::unique_ptr<Matcher> Pattern::matcher(const std::string& input) const
50{
51 return std::unique_ptr<Matcher>(new Matcher(this, input));
52}
53
54}
55}
56}
57}
std::unique_ptr< Pattern > compile(const std::string &regularExpression, const int flags) const
Definition: Pattern.cpp:27
Pattern(const std::string &pattern, const int flags)
Definition: Pattern.cpp:25
std::unique_ptr< Matcher > matcher(const std::string &input) const
Definition: Pattern.cpp:49