Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
d4d03cab
Commit
d4d03cab
authored
May 29, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use internal regex as default in schema validator
parent
b8d2f7e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
10 deletions
+37
-10
regex.h
include/rapidjson/internal/regex.h
+4
-4
schema.h
include/rapidjson/schema.h
+33
-6
No files found.
include/rapidjson/internal/regex.h
View file @
d4d03cab
...
...
@@ -65,8 +65,8 @@ public:
typedef
typename
Encoding
::
Ch
Ch
;
GenericRegex
(
const
Ch
*
source
,
Allocator
*
allocator
=
0
)
:
states_
(
allocator
,
256
),
ranges_
(
allocator
,
256
),
root_
(
kRegexInvalidState
),
stateCount_
(),
rangeCount_
(),
anchorBegin_
(),
anchorEnd_
()
{
StringStream
ss
(
source
);
DecodedStream
<
StringStream
>
ds
(
ss
);
GenericStringStream
<
Encoding
>
ss
(
source
);
DecodedStream
<
GenericStringStream
<
Encoding
>
>
ds
(
ss
);
Parse
(
ds
);
}
...
...
@@ -83,7 +83,7 @@ public:
}
bool
Match
(
const
Ch
*
s
)
const
{
StringStream
is
(
s
);
GenericStringStream
<
Encoding
>
is
(
s
);
return
Match
(
is
);
}
...
...
@@ -93,7 +93,7 @@ public:
}
bool
Search
(
const
Ch
*
s
)
const
{
StringStream
is
(
s
);
GenericStringStream
<
Encoding
>
is
(
s
);
return
Search
(
is
);
}
...
...
include/rapidjson/schema.h
View file @
d4d03cab
...
...
@@ -19,17 +19,25 @@
#include "pointer.h"
#include <cmath> // HUGE_VAL, abs, floor
#if !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
#if !defined(RAPIDJSON_SCHEMA_USE_INTERNALREGEX)
#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 1
#else
#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 0
#endif
#if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
#define RAPIDJSON_SCHEMA_USE_STDREGEX 1
#else
#define RAPIDJSON_SCHEMA_USE_STDREGEX 0
#endif
#if RAPIDJSON_SCHEMA_USE_STDREGEX
#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
#include "internal/regex.h"
#elif RAPIDJSON_SCHEMA_USE_STDREGEX
#include <regex>
#endif
#if RAPIDJSON_SCHEMA_USE_STDREGEX
#if RAPIDJSON_SCHEMA_USE_
INTERNALREGEX || RAPIDJSON_SCHEMA_USE_
STDREGEX
#define RAPIDJSON_SCHEMA_HAS_REGEX 1
#else
#define RAPIDJSON_SCHEMA_HAS_REGEX 0
...
...
@@ -560,7 +568,7 @@ public:
AllocatorType
::
Free
(
patternProperties_
);
}
AllocatorType
::
Free
(
itemsTuple_
);
#if RAPIDJSON_SCHEMA_
USE_STD
REGEX
#if RAPIDJSON_SCHEMA_
HAS_
REGEX
if
(
pattern_
)
{
pattern_
->~
RegexType
();
allocator_
->
Free
(
pattern_
);
...
...
@@ -905,7 +913,9 @@ private:
kTotalSchemaType
};
#if RAPIDJSON_SCHEMA_USE_STDREGEX
#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
typedef
internal
::
GenericRegex
<
EncodingType
>
RegexType
;
#elif RAPIDJSON_SCHEMA_USE_STDREGEX
typedef
std
::
basic_regex
<
Ch
>
RegexType
;
#else
typedef
char
RegexType
;
...
...
@@ -969,7 +979,24 @@ private:
}
}
#if RAPIDJSON_SCHEMA_USE_STDREGEX
#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
template
<
typename
ValueType
>
RegexType
*
CreatePattern
(
const
ValueType
&
value
)
{
if
(
value
.
IsString
())
{
RegexType
*
r
=
new
(
allocator_
->
Malloc
(
sizeof
(
RegexType
)))
RegexType
(
value
.
GetString
());
if
(
!
r
->
IsValid
())
{
r
->~
RegexType
();
r
=
0
;
}
return
r
;
}
return
0
;
}
static
bool
IsPatternMatch
(
const
RegexType
*
pattern
,
const
Ch
*
str
,
SizeType
)
{
return
pattern
->
Search
(
str
);
}
#elif RAPIDJSON_SCHEMA_USE_STDREGEX
template
<
typename
ValueType
>
RegexType
*
CreatePattern
(
const
ValueType
&
value
)
{
if
(
value
.
IsString
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment