JPCRE2  10.31.02
C++ wrapper for PCRE2 library
jpcre2::select< Char_T, Map > Struct Template Reference

struct to select the types. More...

#include <jpcre2.hpp>

Classes

struct  callback
 Provides some default static callback functions. More...
 
class  MatchEvaluator
 This class inherits RegexMatch and provides a similar functionality. More...
 
struct  MatchEvaluatorCallback
 This class contains a typedef of a function pointer or a templated function wrapper (std::function) to provide callback function to the MatchEvaluator. More...
 
class  Regex
 Provides public constructors to create Regex object. More...
 
class  RegexMatch
 Provides public constructors to create RegexMatch objects. More...
 
class  RegexReplace
 Provides public constructors to create RegexReplace objects. More...
 

Public Types

typedef Char_T Char
 Typedef for character (char, wchar_t, char16_t, char32_t) More...
 
typedef std::basic_string< Char_T > String
 Typedef for string (std::string, std::wstring, std::u16string, std::u32string). More...
 
typedef class Map< String, StringMapNas
 Map for Named substrings. More...
 
typedef class Map< String, SIZE_TMapNtN
 Substring name to Substring number map. More...
 
typedef MapNtN MapNtn
 Allow spelling mistake of MapNtN as MapNtn. More...
 
typedef std::vector< StringNumSub
 Vector for Numbered substrings (Sub container). More...
 
typedef std::vector< MapNasVecNas
 Vector of matches with named substrings. More...
 
typedef std::vector< MapNtNVecNtN
 Vector of substring name to substring number map. More...
 
typedef VecNtN VecNtn
 Allow spelling mistake of VecNtN as VecNtn. More...
 
typedef std::vector< NumSubVecNum
 Vector of matches with numbered substrings. More...
 

Static Public Member Functions

static String toString (Char a)
 Converts a Char_T to jpcre2::select::String. More...
 
static String toString (Char const *a)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
static String toString (Char *a)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
static String toString (Pcre2Uchar *a)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
static String getPcre2ErrorMessage (int err_num)
 Retruns error message from PCRE2 error number. More...
 
static String getErrorMessage (int err_num, int err_off)
 Returns error message (either JPCRE2 or PCRE2) from error number and error offset. More...
 

Detailed Description

template<typename Char_T, template< typename... > class Map = std::map>
struct jpcre2::select< Char_T, Map >

struct to select the types.

Template Parameters
Char_TCharacter type (char, wchar_t, char16_t, char32_t)
MapOptional parameter (Only >= C++11) to specify a map container (std::map, std::unordered_map etc..). Default is std::map.

The character type (Char_T) must be in accordance with the PCRE2 library you are linking against. If not sure which library you need, link against all 3 PCRE2 libraries and they will be used as needed.

If you want to be specific, then here's the rule:

  1. If Char_T is 8 bit, you need 8 bit PCRE2 library
  2. If Char_T is 16 bit, you need 16 bit PCRE2 library
  3. If Char_T is 32 bit, you need 32 bit PCRE2 library
  4. if Char_T is not 8 or 16 or 32 bit, you will get compile error.

In >= C++11 you get an additional optional template parameter to specify a map container. For example, you can use std::unordered_map instead of the default std::map:

#include <unordered_map>

We will use the following typedef throughout this doc:

Member Typedef Documentation

◆ Char

template<typename Char_T, template< typename... > class Map = std::map>
typedef Char_T jpcre2::select< Char_T, Map >::Char

Typedef for character (char, wchar_t, char16_t, char32_t)

◆ MapNas

template<typename Char_T, template< typename... > class Map = std::map>
typedef class Map< String, String > jpcre2::select< Char_T, Map >::MapNas

Map for Named substrings.

◆ MapNtN

template<typename Char_T, template< typename... > class Map = std::map>
typedef class Map< String, SIZE_T > jpcre2::select< Char_T, Map >::MapNtN

Substring name to Substring number map.

◆ MapNtn

template<typename Char_T, template< typename... > class Map = std::map>
typedef MapNtN jpcre2::select< Char_T, Map >::MapNtn

Allow spelling mistake of MapNtN as MapNtn.

◆ NumSub

template<typename Char_T, template< typename... > class Map = std::map>
typedef std::vector<String> jpcre2::select< Char_T, Map >::NumSub

Vector for Numbered substrings (Sub container).

◆ String

template<typename Char_T, template< typename... > class Map = std::map>
typedef std::basic_string<Char_T> jpcre2::select< Char_T, Map >::String

Typedef for string (std::string, std::wstring, std::u16string, std::u32string).

Defined as std::basic_string<Char_T>. May be this list will make more sense:

Character String
char std::string
wchar_t std::wstring
char16_t std::u16string (>=C++11)
char32_t std::u32string (>=C++11)

◆ VecNas

template<typename Char_T, template< typename... > class Map = std::map>
typedef std::vector<MapNas> jpcre2::select< Char_T, Map >::VecNas

Vector of matches with named substrings.

◆ VecNtN

template<typename Char_T, template< typename... > class Map = std::map>
typedef std::vector<MapNtN> jpcre2::select< Char_T, Map >::VecNtN

Vector of substring name to substring number map.

◆ VecNtn

template<typename Char_T, template< typename... > class Map = std::map>
typedef VecNtN jpcre2::select< Char_T, Map >::VecNtn

Allow spelling mistake of VecNtN as VecNtn.

◆ VecNum

template<typename Char_T, template< typename... > class Map = std::map>
typedef std::vector<NumSub> jpcre2::select< Char_T, Map >::VecNum

Vector of matches with numbered substrings.

Member Function Documentation

◆ getErrorMessage()

template<typename Char_T, template< typename... > class Map = std::map>
static String jpcre2::select< Char_T, Map >::getErrorMessage ( int  err_num,
int  err_off 
)
inlinestatic

Returns error message (either JPCRE2 or PCRE2) from error number and error offset.

Parameters
err_numerror number (negative for PCRE2, positive for JPCRE2)
err_offerror offset
Returns
message as jpcre2::select::String.

References jpcre2::ERROR::INVALID_MODIFIER.

Referenced by jpcre2::select< Char_T, Map >::RegexMatch::getErrorMessage(), jpcre2::select< Char_T, Map >::RegexReplace::getErrorMessage(), and jpcre2::select< Char_T, Map >::Regex::getErrorMessage().

+ Here is the caller graph for this function:

◆ getPcre2ErrorMessage()

template<typename Char_T, template< typename... > class Map = std::map>
static String jpcre2::select< Char_T, Map >::getPcre2ErrorMessage ( int  err_num)
inlinestatic

Retruns error message from PCRE2 error number.

Parameters
err_numerror number (negative)
Returns
message as jpcre2::select::String.

◆ toString() [1/4]

template<typename Char_T, template< typename... > class Map = std::map>
static String jpcre2::select< Char_T, Map >::toString ( Char  a)
inlinestatic

Converts a Char_T to jpcre2::select::String.

Parameters
aChar_T
Returns
jpcre2::select::String

◆ toString() [2/4]

template<typename Char_T, template< typename... > class Map = std::map>
static String jpcre2::select< Char_T, Map >::toString ( Char const *  a)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Converts a Char_T const * to jpcre2::select::String

Parameters
aChar_T const *
Returns
jpcre2::select::String

◆ toString() [3/4]

template<typename Char_T, template< typename... > class Map = std::map>
static String jpcre2::select< Char_T, Map >::toString ( Char a)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Converts a Char_T* to jpcre2::select::String

Parameters
aChar_T const *
Returns
jpcre2::select::String

◆ toString() [4/4]

template<typename Char_T, template< typename... > class Map = std::map>
static String jpcre2::select< Char_T, Map >::toString ( Pcre2Uchar *  a)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Converts a PCRE2_UCHAR to String

Parameters
aPCRE2_UCHAR
Returns
jpcre2::select::String