AnyCollect  1.1.2
Expression.h
Go to the documentation of this file.
1 //
2 // Expression.h
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 #pragma once
22 
23 #include <memory>
24 #include <regex>
25 
26 #include "Matcher.h"
27 
28 
29 namespace AnyCollect {
33  class Expression {
34  protected:
35  static std::cmatch match;
36  std::regex regex_;
37  std::vector<std::shared_ptr<Matcher>> matchers_;
38 
39  public:
45  Expression(const std::string& pattern) noexcept;
46 
50  std::vector<std::shared_ptr<Matcher>>& matchers() noexcept;
51 
55  const std::vector<std::shared_ptr<Matcher>>& matchers() const noexcept;
56 
57 
65  const std::cmatch& apply(std::string_view::const_iterator begin, std::string_view::const_iterator end);
66  };
67 }
static std::cmatch match
Object used to store regex matches.
Definition: Expression.h:35
Class used to represent an expression (regex)
Definition: Expression.h:33
STL namespace.
Class used to represent a matcher, that is a way to convert expressions matches into a metric...
Definition: Matcher.h:40
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