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
09530ad8
Commit
09530ad8
authored
May 08, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compilation
parent
490630b7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
schema.h
include/rapidjson/schema.h
+18
-17
schematest.cpp
test/unittest/schematest.cpp
+2
-0
No files found.
include/rapidjson/schema.h
View file @
09530ad8
...
...
@@ -93,10 +93,13 @@ enum PatternValidatorType {
template
<
typename
Encoding
>
struct
SchemaValidationContext
{
SchemaValidationContext
(
const
BaseSchema
<
Encoding
>*
s
)
:
schema
(
s
),
valueSchema
(),
notValidator
(),
objectDependencies
(),
schema
(
s
),
valueSchema
(),
patternPropertiesSchemas
(),
notValidator
(),
patternPropertiesSchemaCount
(),
valuePatternValidatorType
(
kPatternValidatorOnly
),
objectDependencies
(),
inArray
(
false
)
{
}
...
...
@@ -115,10 +118,10 @@ struct SchemaValidationContext {
SchemaValidatorArray
<
Encoding
>
dependencyValidators
;
SchemaValidatorArray
<
Encoding
>
patternPropertiesValidators
;
const
BaseSchema
<
Encoding
>**
patternPropertiesSchemas
;
GenericSchemaValidator
<
Encoding
,
BaseReaderHandler
<>
,
CrtAllocator
>*
notValidator
;
SizeType
patternPropertiesSchemaCount
;
PatternValidatorType
valuePatternValidatorType
;
PatternValidatorType
objectPatternValidatorType
;
GenericSchemaValidator
<
Encoding
,
BaseReaderHandler
<>
,
CrtAllocator
>*
notValidator
;
SizeType
objectRequiredCount
;
SizeType
arrayElementIndex
;
bool
*
objectDependencies
;
...
...
@@ -612,6 +615,12 @@ public:
}
private
:
#if RAPIDJSON_SCHEMA_USE_STDREGEX
typedef
std
::
basic_regex
<
Ch
>*
RegexType
;
#else
typedef
char
RegexType
;
#endif
typedef
GenericSchemaValidator
<
Encoding
,
BaseReaderHandler
<>
,
CrtAllocator
>
SchemaValidatorType
;
static
const
BaseSchema
<
Encoding
>*
GetTypeless
()
{
static
BaseSchema
<
Encoding
>
typeless
(
Value
(
kObjectType
).
Move
());
...
...
@@ -661,25 +670,25 @@ private:
#if RAPIDJSON_SCHEMA_USE_STDREGEX
template
<
typename
ValueType
>
static
std
::
basic_regex
<
Ch
>
*
CreatePattern
(
const
ValueType
&
value
)
{
static
RegexType
*
CreatePattern
(
const
ValueType
&
value
)
{
if
(
value
.
IsString
())
try
{
return
new
std
::
basic_regex
<
Ch
>
(
value
.
GetString
(),
std
::
size_t
(
value
.
GetStringLength
()),
std
::
regex_constants
::
ECMAScript
);
return
new
RegexType
(
value
.
GetString
(),
std
::
size_t
(
value
.
GetStringLength
()),
std
::
regex_constants
::
ECMAScript
);
}
catch
(
const
std
::
regex_error
&
)
{
}
return
0
;
}
static
bool
IsPatternMatch
(
const
std
::
basic_regex
<
Ch
>
*
pattern
,
const
Ch
*
str
,
SizeType
length
)
{
static
bool
IsPatternMatch
(
const
RegexType
*
pattern
,
const
Ch
*
str
,
SizeType
length
)
{
std
::
match_results
<
const
Ch
*>
r
;
return
std
::
regex_search
(
str
,
str
+
length
,
r
,
*
pattern
);
}
#else
template
<
typename
ValueType
>
void
*
CreatePattern
(
const
ValueType
&
)
{
return
0
;
}
RegexType
*
CreatePattern
(
const
ValueType
&
)
{
return
0
;
}
static
bool
IsPatternMatch
(
const
void
*
,
const
Ch
*
,
SizeType
)
{
return
true
;
}
static
bool
IsPatternMatch
(
const
RegexType
*
,
const
Ch
*
,
SizeType
)
{
return
true
;
}
#endif // RAPIDJSON_SCHEMA_USE_STDREGEX
void
AddType
(
const
Value
&
type
)
{
...
...
@@ -781,11 +790,7 @@ private:
}
BaseSchema
<
Encoding
>*
schema
;
#if RAPIDJSON_SCHEMA_USE_STDREGEX
std
::
basic_regex
<
Ch
>*
pattern
;
#else
void
*
pattern
;
#endif
RegexType
*
pattern
;
};
MemoryPoolAllocator
<>
allocator_
;
...
...
@@ -816,11 +821,7 @@ private:
SizeType
maxItems_
;
bool
additionalItems_
;
#if RAPIDJSON_SCHEMA_USE_STDREGEX
std
::
basic_regex
<
Ch
>*
pattern_
;
#else
void
*
pattern_
;
#endif
RegexType
*
pattern_
;
SizeType
minLength_
;
SizeType
maxLength_
;
...
...
test/unittest/schematest.cpp
View file @
09530ad8
...
...
@@ -149,6 +149,7 @@ TEST(SchemaValidator, String_LengthRange) {
VALIDATE
(
s
,
"
\"
ABCD
\"
"
,
false
);
}
#if RAPIDJSON_SCHEMA_HAS_REGEX
TEST
(
SchemaValidator
,
String_Pattern
)
{
Document
sd
;
sd
.
Parse
(
"{
\"
type
\"
:
\"
string
\"
,
\"
pattern
\"
:
\"
^(
\\\\
([0-9]{3}
\\\\
))?[0-9]{3}-[0-9]{4}$
\"
}"
);
...
...
@@ -159,6 +160,7 @@ TEST(SchemaValidator, String_Pattern) {
VALIDATE
(
s
,
"
\"
(888)555-1212 ext. 532
\"
"
,
false
);
VALIDATE
(
s
,
"
\"
(800)FLOWERS
\"
"
,
false
);
}
#endif
TEST
(
SchemaValidator
,
Integer
)
{
Document
sd
;
...
...
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