Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
RegularExpression.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
6#include <regex>
7
8#include "Stroika/Foundation/Containers/Sequence.h"
9
10#include "RegularExpression.h"
11
12using namespace Stroika::Foundation;
14
15namespace {
16 regex_constants::syntax_option_type mkOption_ (RegularExpression::SyntaxType st, CompareOptions co)
17 {
18 regex_constants::syntax_option_type f = static_cast<regex_constants::syntax_option_type> (st);
19 if (co == eCaseInsensitive) {
20 f |= regex_constants::icase;
21 }
22 f |= regex_constants::optimize;
23 return f;
24 }
25}
26
27/*
28 ********************************************************************************
29 ********************** Characters::RegularExpression ***************************
30 ********************************************************************************
31 */
32RegularExpression::RegularExpression (SyntaxType syntaxType, const String& re, CompareOptions co)
33 : fCompiledRegExp_{re.As<wstring> (), mkOption_ (syntaxType, co)}
34{
35}
36
37/*
38 ********************************************************************************
39 ***************** Characters::RegularExpressionMatch ***************************
40 ********************************************************************************
41 */
42RegularExpressionMatch::RegularExpressionMatch (const String& fullMatch)
43 : fFullMatch_{fullMatch}
44 , fSubMatches_{Containers::Sequence<String>{}}
45{
46}
47
48RegularExpressionMatch::RegularExpressionMatch (const String& fullMatch, const Containers::Sequence<String>& subMatches)
49 : fFullMatch_{fullMatch}
50 , fSubMatches_{subMatches}
51{
52}
53
54String RegularExpressionMatch::GetFullMatch () const
55{
56 return fFullMatch_;
57}
58
59Containers::Sequence<String> RegularExpressionMatch::GetSubMatches () const
60{
61 return fSubMatches_;
62}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187