AnyCollect  1.1.2
Expression.cc
Go to the documentation of this file.
1 //
2 // Expression.cc
3 //
4 // Created on October 26th 2018
5 //
6 // Copyright 2018 CFM (www.cfm.fr)
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 //
20 
21 #include "Expression.h"
22 
23 
24 namespace AnyCollect {
25  std::cmatch Expression::match{};
26 
27  Expression::Expression(const std::string& pattern) noexcept :
28  regex_(pattern, std::regex_constants::ECMAScript | std::regex_constants::optimize)
29  { }
30 
31 
32  std::vector<std::shared_ptr<Matcher>>& Expression::matchers() noexcept {
33  return this->matchers_;
34  }
35 
36  const std::vector<std::shared_ptr<Matcher>>& Expression::matchers() const noexcept {
37  return this->matchers_;
38  }
39 
40  const std::cmatch& Expression::apply(std::string_view::const_iterator begin, std::string_view::const_iterator end) {
41  std::regex_search(begin, end, match, this->regex_, std::regex_constants::match_default);
42  return match;
43  }
44 }
static std::cmatch match
Object used to store regex matches.
Definition: Expression.h:35
std::vector< std::shared_ptr< Matcher > > & matchers() noexcept
Returns the array of the receiver&#39;s matchers.
Definition: Expression.cc:32
const std::cmatch & apply(std::string_view::const_iterator begin, std::string_view::const_iterator end)
Apply the regex and find matches in the given string.
Definition: Expression.cc:40
Expression(const std::string &pattern) noexcept
Construct a new Expression object.
Definition: Expression.cc:27
std::vector< std::shared_ptr< Matcher > > matchers_
Matchers associated with the receiver.
Definition: Expression.h:37
std::regex regex_
Regex object.
Definition: Expression.h:36