CodePorting.Translator.Cs2Cpp.Framework

Regular expression that follows C#-like syntax. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument. More...

#include <regex.h>

Inherits System::Object.

Public Member Functions

 Regex ()
 Constructs empty regexp. More...
 
 Regex (const String &pattern)
 Constructor. More...
 
 Regex (const String &pattern, RegexOptions options)
 Constructor. More...
 
 Regex (const String &pattern, RegexOptions options, TimeSpan matchTimeout)
 Constructor. More...
 
TimeSpan get_MatchTimeout ()
 Gets matching timeout. More...
 
RegexOptions get_Options ()
 Gets regex options. More...
 
bool get_RightToLeft ()
 Checks if matching is done in right-to-left mode. More...
 
bool IsMatch (const String &input, int startat=0)
 Matches regex against string. More...
 
MatchPtr Match (const String &input)
 Matches regex against string. More...
 
MatchPtr Match (const String &input, int startat, int length=0)
 Matches regex against string. More...
 
MatchCollectionPtr Matches (const String &input, int startat=0)
 Gets all matches of regex in given string by matching repeatedly. More...
 
String Replace (const String &input, const String &replacement)
 Replaces all matches of regex in string with replacement string. More...
 
String Replace (const String &input, const char_t *replacement)
 Replaces all matches of regex in string with replacement string. More...
 
String Replace (const String &input, const MatchEvaluator &evaluator)
 Replaces all matches in string with delegate-generated replacement strings. More...
 
String Replace (const String &input, const MatchEvaluator &evaluator, int count)
 Replaces all matches in string with delegate-generated replacement strings. More...
 
String Replace (const String &input, const MatchEvaluator &evaluator, int count, int startat)
 Replaces all matches in string with delegate-generated replacement strings. More...
 
String Replace (const String &input, const String &replacement, int count)
 Replaces substrings in string. Not implemented. More...
 
String Replace (const String &input, const String &replacement, int count, int startat)
 Replaces substrings in string. Not implemented. More...
 
ArrayPtr< StringSplit (const String &input)
 Splits string by regex matches. More...
 
ArrayPtr< StringSplit (const String &input, int count)
 Splits string by regex matches. More...
 
ArrayPtr< StringSplit (const String &input, int count, int startat)
 Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression specified in the Regex constructor. The search for the regular expression pattern starts at a specified character position in the input string. More...
 
String ToString () const override
 Converts regex to string. More...
 
- Public Member Functions inherited from System::Object
 Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ~Object ()
 Destroys object. Frees all internal data structures. More...
 
 Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared reference counter. More...
 
void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual int32_t GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual String ToString () const
 Analog of C# Object.ToString() method. Enables converting custom objects to string. More...
 
virtual ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual void SetTemplateWeakPtr (uint32_t argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 
virtual bool FastCast (const Details::FastRttiBase &helper, void **out_ptr) const
 For internal purposes only. More...
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 Specialization of Object::ReferenceEquals for case of string and nullptr. More...
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 Specialization of Object::ReferenceEquals for case of strings. More...
 

Static Public Member Functions

static String Replace (const String &input, const char_t *pattern, const char_t *replacement)
 Replaces all matches of regex in string with replacement string. More...
 
static String Replace (const String &input, const String &pattern, const char_t *replacement)
 Replaces all matches of regex in string with replacement string. More...
 
static String Replace (const String &input, const String &pattern, const MatchEvaluator &evaluator, RegexOptions options)
 Replaces all matches in string with delegate-generated replacement strings (static function). More...
 
static String Replace (const String &input, const String &pattern, const String &replacement, RegexOptions options)
 Replaces all matches of regex in string with replacement string. More...
 
static bool IsMatch (const String &input, const String &pattern, RegexOptions options=RegexOptions::None, TimeSpan matchTimeout=InfiniteMatchTimeout, int startat=0)
 Checks if string matches pattern. More...
 
static MatchPtr Match (const String &input, const String &pattern, RegexOptions options=RegexOptions::None, TimeSpan matchTimeout=InfiniteMatchTimeout, int startat=0, int length=0)
 Matches string and pattern. More...
 
static MatchCollectionPtr Matches (const String &input, const String &pattern, RegexOptions options=RegexOptions::None, TimeSpan matchTimeout=InfiniteMatchTimeout, int startat=0, int length=0)
 Gets all matches between string and pattern. More...
 
static String Replace (const String &input, const String &pattern, const String &replacement)
 Replaces regex matches. More...
 
static String Replace (const String &input, const String &pattern, const MatchEvaluator &evaluator)
 Replaces regex matches. More...
 
static ArrayPtr< StringSplit (const String &input, const String &pattern, RegexOptions options=RegexOptions::None, TimeSpan matchTimeout=InfiniteMatchTimeout)
 Splits string by regexp. More...
 
static ArrayPtr< StringSplit (const String &input, const String &pattern, int count, RegexOptions options=RegexOptions::None, TimeSpan matchTimeout=InfiniteMatchTimeout)
 Splits string by regexp. More...
 
static String Escape (const String &str)
 Escapes special characters to use string as part of the pattern. More...
 
static String Unescape (const String &str)
 Unescapes special characters in string used as part of the pattern. More...
 
- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Implements C# typeof(System.Object) construct. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. More...
 
template<>
bool Equals (double const &objA, double const &objB)
 Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. More...
 

Static Public Attributes

static TimeSpan InfiniteMatchTimeout
 Special timeout value to disable match break by timeout. More...
 

Protected Member Functions

 ~Regex () override
 Destructor. More...
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 

Detailed Description

Regular expression that follows C#-like syntax. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

Constructor & Destructor Documentation

◆ Regex() [1/4]

System::Text::RegularExpressions::Regex::Regex ( )

Constructs empty regexp.

◆ Regex() [2/4]

System::Text::RegularExpressions::Regex::Regex ( const String pattern)

Constructor.

Parameters
patternC#-syntaxed pattern.

◆ Regex() [3/4]

System::Text::RegularExpressions::Regex::Regex ( const String pattern,
RegexOptions  options 
)

Constructor.

Parameters
patternC#-syntaxed pattern.
optionsRegex matching options.

◆ Regex() [4/4]

System::Text::RegularExpressions::Regex::Regex ( const String pattern,
RegexOptions  options,
TimeSpan  matchTimeout 
)

Constructor.

Parameters
patternC#-syntaxed pattern.
optionsRegex matching options.
matchTimeoutTimeout to break matching.

◆ ~Regex()

System::Text::RegularExpressions::Regex::~Regex ( )
overrideprotected

Destructor.

Member Function Documentation

◆ Escape()

static String System::Text::RegularExpressions::Regex::Escape ( const String str)
static

Escapes special characters to use string as part of the pattern.

Parameters
strString to escape special characters in.
Returns
String with escaped special characters.

◆ get_MatchTimeout()

TimeSpan System::Text::RegularExpressions::Regex::get_MatchTimeout ( )
inline

Gets matching timeout.

Returns
Matching timeout set to regex.

◆ get_Options()

RegexOptions System::Text::RegularExpressions::Regex::get_Options ( )
inline

Gets regex options.

Returns
Options regex is created with.

◆ get_RightToLeft()

bool System::Text::RegularExpressions::Regex::get_RightToLeft ( )
inline

Checks if matching is done in right-to-left mode.

Returns
True if matching is done right-to-left, false if it is done left-to-right.

◆ IsMatch() [1/2]

static bool System::Text::RegularExpressions::Regex::IsMatch ( const String input,
const String pattern,
RegexOptions  options = RegexOptions::None,
TimeSpan  matchTimeout = InfiniteMatchTimeout,
int  startat = 0 
)
static

Checks if string matches pattern.

Parameters
inputInput string.
patternRegexp pattern.
optionsMatching options.
matchTimeoutTimeout.
startatMatch beginning position.
Returns
True if match is found, false otherwise.

◆ IsMatch() [2/2]

bool System::Text::RegularExpressions::Regex::IsMatch ( const String input,
int  startat = 0 
)

Matches regex against string.

Parameters
inputTarget string.
startatBeginning index.
Returns
True if string matches regex, false otherwise.

◆ Match() [1/3]

MatchPtr System::Text::RegularExpressions::Regex::Match ( const String input)

Matches regex against string.

Parameters
inputTarget string.
Returns
Match value containing match status and submatches.

◆ Match() [2/3]

static MatchPtr System::Text::RegularExpressions::Regex::Match ( const String input,
const String pattern,
RegexOptions  options = RegexOptions::None,
TimeSpan  matchTimeout = InfiniteMatchTimeout,
int  startat = 0,
int  length = 0 
)
static

Matches string and pattern.

Parameters
inputInput string.
patternRegexp pattern.
optionsMatching options.
matchTimeoutTimeout.
startatMatch beginning position.
lengthNumber of characters to look through (0 diables limit).
Returns
First match found.

◆ Match() [3/3]

MatchPtr System::Text::RegularExpressions::Regex::Match ( const String input,
int  startat,
int  length = 0 
)

Matches regex against string.

Parameters
inputTarget string.
startatBeginning index.
lengthNumber of characters to look through (0 to look through the whole string).
Returns
Match value containing match status and submatches.

◆ Matches() [1/2]

static MatchCollectionPtr System::Text::RegularExpressions::Regex::Matches ( const String input,
const String pattern,
RegexOptions  options = RegexOptions::None,
TimeSpan  matchTimeout = InfiniteMatchTimeout,
int  startat = 0,
int  length = 0 
)
static

Gets all matches between string and pattern.

Parameters
inputInput string.
patternRegexp pattern.
optionsMatching options.
matchTimeoutTimeout.
startatMatch beginning position.
lengthNumber of characters to look through (0 diables limit).
Returns
All matches found by matching repeatedly.

◆ Matches() [2/2]

MatchCollectionPtr System::Text::RegularExpressions::Regex::Matches ( const String input,
int  startat = 0 
)

Gets all matches of regex in given string by matching repeatedly.

Parameters
inputInput string.
startatIndex to start matching at.
Returns
Collection of all matches found.

◆ Replace() [1/13]

static String System::Text::RegularExpressions::Regex::Replace ( const String input,
const char_t *  pattern,
const char_t *  replacement 
)
static

Replaces all matches of regex in string with replacement string.

Parameters
inputInput string.
patternRegex pattern.
replacementReplacement string.
Returns
Input string with all regex matches replaced with replacement string.

◆ Replace() [2/13]

String System::Text::RegularExpressions::Regex::Replace ( const String input,
const char_t *  replacement 
)

Replaces all matches of regex in string with replacement string.

Parameters
inputInput string.
replacementReplacement string.
Returns
Input string with all regex matches replaced with replacement string.

◆ Replace() [3/13]

String System::Text::RegularExpressions::Regex::Replace ( const String input,
const MatchEvaluator evaluator 
)

Replaces all matches in string with delegate-generated replacement strings.

Parameters
inputInput string.
evaluatorDelegate to generate replacement strings based on matches.
Returns
Input strings with all matches replaced.

◆ Replace() [4/13]

String System::Text::RegularExpressions::Regex::Replace ( const String input,
const MatchEvaluator evaluator,
int  count 
)

Replaces all matches in string with delegate-generated replacement strings.

Parameters
inputInput string.
evaluatorDelegate to generate replacement strings based on matches.
countNumber of replacements limit.
Returns
Input strings with all matches replaced.

◆ Replace() [5/13]

String System::Text::RegularExpressions::Regex::Replace ( const String input,
const MatchEvaluator evaluator,
int  count,
int  startat 
)

Replaces all matches in string with delegate-generated replacement strings.

Parameters
inputInput string.
evaluatorDelegate to generate replacement strings based on matches.
countNumber of replacements limit.
startatIndex in input string to start replacement at.
Returns
Input strings with all matches replaced.

◆ Replace() [6/13]

static String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String pattern,
const char_t *  replacement 
)
static

Replaces all matches of regex in string with replacement string.

Parameters
inputInput string.
patternRegex pattern.
replacementReplacement string.
Returns
Input string with all regex matches replaced with replacement string.

◆ Replace() [7/13]

static String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String pattern,
const MatchEvaluator evaluator 
)
static

Replaces regex matches.

Parameters
inputInput string.
patternRegexp pattern.
evaluatorDelegate to generate replacement string for each match.
Returns
String with all matches replaced.

◆ Replace() [8/13]

static String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String pattern,
const MatchEvaluator evaluator,
RegexOptions  options 
)
static

Replaces all matches in string with delegate-generated replacement strings (static function).

Parameters
inputInput string.
patternRegex pattern.
evaluatorDelegate to generate replacement strings based on matches.
optionsRegex options.
Returns
Input strings with all matches replaced.

◆ Replace() [9/13]

static String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String pattern,
const String replacement 
)
static

Replaces regex matches.

Parameters
inputInput string.
patternRegexp pattern.
replacementReplacement string.
Returns
String with all matches replaced.

◆ Replace() [10/13]

static String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String pattern,
const String replacement,
RegexOptions  options 
)
static

Replaces all matches of regex in string with replacement string.

Parameters
inputInput string.
patternRegex pattern.
replacementReplacement string.
optionsRegex options.
Returns
Input string with all regex matches replaced with replacement string.

◆ Replace() [11/13]

String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String replacement 
)

Replaces all matches of regex in string with replacement string.

Parameters
inputInput string.
replacementReplacement string.
Returns
Input string with all regex matches replaced with replacement string.

◆ Replace() [12/13]

String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String replacement,
int  count 
)

Replaces substrings in string. Not implemented.

◆ Replace() [13/13]

String System::Text::RegularExpressions::Regex::Replace ( const String input,
const String replacement,
int  count,
int  startat 
)

Replaces substrings in string. Not implemented.

◆ Split() [1/5]

ArrayPtr< String > System::Text::RegularExpressions::Regex::Split ( const String input)

Splits string by regex matches.

Parameters
inputString to split.
Returns
Array of substrings between matches.

◆ Split() [2/5]

static ArrayPtr< String > System::Text::RegularExpressions::Regex::Split ( const String input,
const String pattern,
int  count,
RegexOptions  options = RegexOptions::None,
TimeSpan  matchTimeout = InfiniteMatchTimeout 
)
static

Splits string by regexp.

Parameters
inputInput string.
patternRegexp pattern.
countMatch number limit.
optionsMatching options.
matchTimeoutTimeout.
Returns
Array of strings between matchse.

◆ Split() [3/5]

static ArrayPtr< String > System::Text::RegularExpressions::Regex::Split ( const String input,
const String pattern,
RegexOptions  options = RegexOptions::None,
TimeSpan  matchTimeout = InfiniteMatchTimeout 
)
static

Splits string by regexp.

Parameters
inputInput string.
patternRegexp pattern.
optionsMatching options.
matchTimeoutTimeout.
Returns
Array of strings between matchse.

◆ Split() [4/5]

ArrayPtr< String > System::Text::RegularExpressions::Regex::Split ( const String input,
int  count 
)

Splits string by regex matches.

Parameters
inputString to split.
countNumber of substrings limit.
Returns
Array of substrings between matches.

◆ Split() [5/5]

ArrayPtr< String > System::Text::RegularExpressions::Regex::Split ( const String input,
int  count,
int  startat 
)

Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression specified in the Regex constructor. The search for the regular expression pattern starts at a specified character position in the input string.

Parameters
inputThe string to be split.
countThe maximum number of times the split can occur.
startatThe character position in the input string where the search will begin.
Returns
An array of strings.

◆ ToString()

String System::Text::RegularExpressions::Regex::ToString ( ) const
inlineoverridevirtual

Converts regex to string.

Returns
Regex pattern.

Reimplemented from System::Object.

◆ Unescape()

static String System::Text::RegularExpressions::Regex::Unescape ( const String str)
static

Unescapes special characters in string used as part of the pattern.

Parameters
strString to unescape special characters in.
Returns
String with unescaped special characters.

Member Data Documentation

◆ InfiniteMatchTimeout

TimeSpan System::Text::RegularExpressions::Regex::InfiniteMatchTimeout
static

Special timeout value to disable match break by timeout.