Keyple Util C++ Library 2.0.0
Reference Terminal Reader API for C++
Matcher.h
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#pragma once
14
15#include <regex>
16#include <string>
17#include <vector>
18
19#include "KeypleUtilExport.h"
20
21namespace keyple {
22namespace core {
23namespace util {
24namespace cpp {
25
26class Pattern;
27
29public:
33 Matcher(const Pattern* parent, const std::string& text);
34
40 bool match(const int from, const int anchor) const;
41
51 bool matches();
52
80 std::string replaceAll(const std::string& replacement) const;
81
95 bool find();
96
110 bool find(const int start);
111
129 const std::string group(const int group) const;
130
138 const std::string group() const;
139
150 bool search(const int from);
151
157 int getTextLength() const;
158
167 Matcher* reset();
168
169private:
173 const Pattern* mParentPattern;
174
178 const std::string mText;
179
184 int mFrom;
185 int mTo;
186
191 int ENDANCHOR = 1;
192
198 int mFirst = -1, mLast = 0;
199
203 int mOldLast = -1;
204
212 std::string mSubs;
213
218 std::smatch mGroups;
219
223 int mLastAppendPosition = 0;
224
230 std::vector<int> mLocals;
231};
232
233}
234}
235}
236}
#define KEYPLEUTIL_API