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
a6571d50
Commit
a6571d50
authored
Apr 19, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Combine objectDependices and objectRequired into propertyExist array
parent
f586edd3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
26 deletions
+13
-26
schema.h
include/rapidjson/schema.h
+13
-26
No files found.
include/rapidjson/schema.h
View file @
a6571d50
...
...
@@ -289,8 +289,7 @@ struct SchemaValidationContext {
patternPropertiesSchemas
(),
patternPropertiesSchemaCount
(),
valuePatternValidatorType
(
kPatternValidatorOnly
),
objectDependencies
(),
objectRequired
(),
propertyExist
(),
inArray
(
false
),
valueUniqueness
(
false
),
arrayUniqueness
(
false
)
...
...
@@ -312,10 +311,8 @@ struct SchemaValidationContext {
}
if
(
patternPropertiesSchemas
)
factory
.
FreeState
(
patternPropertiesSchemas
);
if
(
objectDependencies
)
factory
.
FreeState
(
objectDependencies
);
if
(
objectRequired
)
factory
.
FreeState
(
objectRequired
);
if
(
propertyExist
)
factory
.
FreeState
(
propertyExist
);
}
SchemaValidatorFactoryType
&
factory
;
...
...
@@ -333,8 +330,7 @@ struct SchemaValidationContext {
PatternValidatorType
valuePatternValidatorType
;
PatternValidatorType
objectPatternValidatorType
;
SizeType
arrayElementIndex
;
bool
*
objectDependencies
;
bool
*
objectRequired
;
bool
*
propertyExist
;
bool
inArray
;
bool
valueUniqueness
;
bool
arrayUniqueness
;
...
...
@@ -770,14 +766,9 @@ public:
if
(
!
(
type_
&
(
1
<<
kObjectSchemaType
)))
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetTypeString
());
if
(
hasRequired_
)
{
context
.
objectRequired
=
static_cast
<
bool
*>
(
context
.
factory
.
MallocState
(
sizeof
(
bool
)
*
propertyCount_
));
std
::
memset
(
context
.
objectRequired
,
0
,
sizeof
(
bool
)
*
propertyCount_
);
}
if
(
hasDependencies_
)
{
context
.
objectDependencies
=
static_cast
<
bool
*>
(
context
.
factory
.
MallocState
(
sizeof
(
bool
)
*
propertyCount_
));
std
::
memset
(
context
.
objectDependencies
,
0
,
sizeof
(
bool
)
*
propertyCount_
);
if
(
hasDependencies_
||
hasRequired_
)
{
context
.
propertyExist
=
static_cast
<
bool
*>
(
context
.
factory
.
MallocState
(
sizeof
(
bool
)
*
propertyCount_
));
std
::
memset
(
context
.
propertyExist
,
0
,
sizeof
(
bool
)
*
propertyCount_
);
}
if
(
patternProperties_
)
{
// pre-allocate schema array
...
...
@@ -808,11 +799,8 @@ public:
else
context
.
valueSchema
=
properties_
[
index
].
schema
;
if
(
hasRequired_
)
context
.
objectRequired
[
index
]
=
true
;
if
(
hasDependencies_
)
context
.
objectDependencies
[
index
]
=
true
;
if
(
context
.
propertyExist
)
context
.
propertyExist
[
index
]
=
true
;
return
true
;
}
...
...
@@ -840,11 +828,10 @@ public:
bool
EndObject
(
Context
&
context
,
SizeType
memberCount
)
const
{
if
(
hasRequired_
)
for
(
SizeType
index
=
0
;
index
<
propertyCount_
;
index
++
)
{
for
(
SizeType
index
=
0
;
index
<
propertyCount_
;
index
++
)
if
(
properties_
[
index
].
required
)
if
(
!
context
.
objectRequired
[
index
])
if
(
!
context
.
propertyExist
[
index
])
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetRequiredString
());
}
if
(
memberCount
<
minProperties_
)
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetMinPropertiesString
());
...
...
@@ -854,10 +841,10 @@ public:
if
(
hasDependencies_
)
{
for
(
SizeType
sourceIndex
=
0
;
sourceIndex
<
propertyCount_
;
sourceIndex
++
)
if
(
context
.
objectDependencies
[
sourceIndex
])
{
if
(
context
.
propertyExist
[
sourceIndex
])
{
if
(
properties_
[
sourceIndex
].
dependencies
)
{
for
(
SizeType
targetIndex
=
0
;
targetIndex
<
propertyCount_
;
targetIndex
++
)
if
(
properties_
[
sourceIndex
].
dependencies
[
targetIndex
]
&&
!
context
.
objectDependencies
[
targetIndex
])
if
(
properties_
[
sourceIndex
].
dependencies
[
targetIndex
]
&&
!
context
.
propertyExist
[
targetIndex
])
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetDependenciesString
());
}
else
if
(
properties_
[
sourceIndex
].
dependenciesSchema
)
...
...
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