JPCRE2  10.31.02
C++ wrapper for PCRE2 library
jpcre2.hpp File Reference

Main header file for JPCRE2 library to be included by programs that uses its functionalities. More...

#include <pcre2.h>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <utility>
#include <functional>
+ Include dependency graph for jpcre2.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  jpcre2::Modifier
 Class to take a std::string modifier value with null safety. More...
 
class  jpcre2::ModifierTable
 Lets you create custom modifier tables. More...
 
struct  jpcre2::select< Char_T, Map >
 struct to select the types. More...
 
class  jpcre2::select< Char_T, Map >::RegexMatch
 Provides public constructors to create RegexMatch objects. More...
 
struct  jpcre2::select< Char_T, Map >::MatchEvaluatorCallback< T1, T2, T3 >
 This class contains a typedef of a function pointer or a templated function wrapper (std::function) to provide callback function to the MatchEvaluator. More...
 
struct  jpcre2::select< Char_T, Map >::callback
 Provides some default static callback functions. More...
 
class  jpcre2::select< Char_T, Map >::MatchEvaluator
 This class inherits RegexMatch and provides a similar functionality. More...
 
class  jpcre2::select< Char_T, Map >::RegexReplace
 Provides public constructors to create RegexReplace objects. More...
 
class  jpcre2::select< Char_T, Map >::Regex
 Provides public constructors to create Regex object. More...
 

Namespaces

 jpcre2
 Top level namespace of JPCRE2.
 
 jpcre2::INFO
 Namespace to provide information about JPCRE2 library itself.
 
 jpcre2::ERROR
 Namespace for error codes.
 

Macros

#define PCRE2_CODE_UNIT_WIDTH   0
 This macro does not have any significance in JPCRE2 context. More...
 
#define JPCRE2_ASSERT(cond, msg)   jpcre2::jassert(cond, msg, __FILE__, __LINE__)
 Macro to call jpcre2::jassert() with file path and line number. More...
 
#define JPCRE2_VERSION   103102L
 Define for JPCRE2 version. More...
 
#define JPCRE2_USE_FUNCTION_POINTER_CALLBACK
 Use function pointer in all cases for MatchEvaluatorCallback function. More...
 
#define JPCRE2_NDEBUG
 Macro to remove debug codes. More...
 

Typedefs

typedef PCRE2_SIZE jpcre2::SIZE_T
 Used for match count and vector size. More...
 
typedef uint32_t jpcre2::Uint
 Used for options (bitwise operation) More...
 
typedef uint8_t jpcre2::Ush
 8 bit unsigned integer. More...
 
typedef std::vector< SIZE_T > jpcre2::VecOff
 vector of size_t. More...
 
typedef std::vector< Uint > jpcre2::VecOpt
 vector for Uint option values. More...
 

Enumerations

enum  {
  jpcre2::ERROR::INVALID_MODIFIER = 2,
  jpcre2::ERROR::INSUFFICIENT_OVECTOR = 3
}
 Error numbers for JPCRE2. More...
 
enum  {
  jpcre2::NONE = 0x0000000u,
  jpcre2::FIND_ALL = 0x0000002u,
  jpcre2::JIT_COMPILE = 0x0000004u
}
 These constants provide JPCRE2 options. More...
 

Functions

static void jpcre2::jassert (bool cond, const char *msg, const char *f, size_t line)
 JPCRE2 assert function. More...
 

Variables

static const char jpcre2::INFO::NAME [] = "JPCRE2"
 Name of the project. More...
 
static const char jpcre2::INFO::FULL_VERSION [] = "10.31.02"
 Full version string. More...
 
static const char jpcre2::INFO::VERSION_GENRE [] = "10"
 Generation, depends on original PCRE2 version. More...
 
static const char jpcre2::INFO::VERSION_MAJOR [] = "31"
 Major version, updated when API change is made. More...
 
static const char jpcre2::INFO::VERSION_MINOR [] = "02"
 Minor version, includes bug fix or minor feature upgrade. More...
 
static const char jpcre2::INFO::VERSION_PRE_RELEASE [] = ""
 Alpha or beta (testing) release version. More...
 

Detailed Description

Main header file for JPCRE2 library to be included by programs that uses its functionalities.

It includes the pcre2.h header, therefore you shouldn't include pcre2.h, neither should you define PCRE2_CODE_UNIT_WIDTH before including jpcre2.hpp. If your pcre2.h header is not in standard include paths, you may include pcre2.h with correct path before including jpcre2.hpp manually. In this case you will have to define PCRE2_CODE_UNIT_WIDTH before including pcre2.h. Make sure to link required PCRE2 libraries when compiling.

Author
Md Jahidul Hamid

Macro Definition Documentation

◆ JPCRE2_ASSERT

#define JPCRE2_ASSERT (   cond,
  msg 
)    jpcre2::jassert(cond, msg, __FILE__, __LINE__)

Macro to call jpcre2::jassert() with file path and line number.

When NDEBUG or JPCRE2_NDEBUG is defined before including this header, this macro will be defined as ((void)0) thus eliminating this assertion.

Parameters
condcondtion (boolean)
msgmessage

Referenced by jpcre2::select< Char_T, Map >::Regex::preplace().

◆ JPCRE2_NDEBUG

#define JPCRE2_NDEBUG

Macro to remove debug codes.

Using this macro is discouraged even in production mode but provided for completeness. You should not use this macro to bypass any error in your program. Define this macro before including this header if you want to remove debug codes included in this library.

Using the standard NDEBUG macro will have the same effect, but it is recommended that you use JPCRE2_NDEBUG to strip out debug codes specifically for this library.

◆ JPCRE2_USE_FUNCTION_POINTER_CALLBACK

#define JPCRE2_USE_FUNCTION_POINTER_CALLBACK

Use function pointer in all cases for MatchEvaluatorCallback function.

By default function pointer is used for callback in MatchEvaluator when using <C++11 compiler, but for >=C++11 compiler std::function instead of function pointer is used. If this macro is defined before including jpcre2.hpp, function pointer will be used in all cases. It you are using lambda function with captures, stick with std::function, on the other hand, if you are using older compilers, you might want to use function pointer instead.

For example, with gcc-4.7, std::function will give compile error in C++11 mode, in such cases where full C++11 support is not available, use function pointer.

◆ JPCRE2_VERSION

#define JPCRE2_VERSION   103102L

Define for JPCRE2 version.

It can be used to support changes in different versions of the lib.

◆ PCRE2_CODE_UNIT_WIDTH

#define PCRE2_CODE_UNIT_WIDTH   0

This macro does not have any significance in JPCRE2 context.

It is defined as 0 by default. Defining it before including jpcre2.hpp will override the default (discouraged as it will make it harder for you to detect problems), but still it will have no effect in a JPCRE2 perspective. Defining it with an invalid value will yield to compile error.