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
4a0b5912
Commit
4a0b5912
authored
May 09, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move private schema classes into internal namespace
parent
422aebf3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
41 deletions
+33
-41
schema.h
include/rapidjson/schema.h
+33
-41
No files found.
include/rapidjson/schema.h
View file @
4a0b5912
...
@@ -46,10 +46,12 @@ RAPIDJSON_NAMESPACE_BEGIN
...
@@ -46,10 +46,12 @@ RAPIDJSON_NAMESPACE_BEGIN
// Forward declarations
// Forward declarations
template
<
typename
Encoding
,
typename
Allocator
>
template
<
typename
Encoding
,
typename
Allocator
>
class
Schema
;
class
GenericSchemaDocument
;
namespace
internal
{
template
<
typename
Encoding
,
typename
Allocator
>
template
<
typename
Encoding
,
typename
Allocator
>
class
GenericSchemaDocument
;
class
Schema
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// ISchemaValidator
// ISchemaValidator
...
@@ -70,35 +72,6 @@ public:
...
@@ -70,35 +72,6 @@ public:
virtual
ISchemaValidator
*
CreateSchemaValidator
(
const
SchemaType
&
)
const
=
0
;
virtual
ISchemaValidator
*
CreateSchemaValidator
(
const
SchemaType
&
)
const
=
0
;
};
};
///////////////////////////////////////////////////////////////////////////////
// SchemaValidatorArray
struct
SchemaValidatorArray
{
SchemaValidatorArray
()
:
validators
(),
count
()
{}
~
SchemaValidatorArray
()
{
for
(
SizeType
i
=
0
;
i
<
count
;
i
++
)
delete
validators
[
i
];
delete
[]
validators
;
}
ISchemaValidator
**
validators
;
SizeType
count
;
};
///////////////////////////////////////////////////////////////////////////////
// SchemaArray
template
<
typename
Encoding
,
typename
Allocator
>
struct
SchemaArray
{
SchemaArray
()
:
schemas
(),
count
()
{}
~
SchemaArray
()
{
delete
[]
schemas
;
}
const
Schema
<
Encoding
,
Allocator
>**
schemas
;
SizeType
count
;
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// SchemaValidationContext
// SchemaValidationContext
...
@@ -113,6 +86,18 @@ struct SchemaValidationContext {
...
@@ -113,6 +86,18 @@ struct SchemaValidationContext {
kPatternValidatorWithAdditionalProperty
kPatternValidatorWithAdditionalProperty
};
};
struct
SchemaValidatorArray
{
SchemaValidatorArray
()
:
validators
(),
count
()
{}
~
SchemaValidatorArray
()
{
for
(
SizeType
i
=
0
;
i
<
count
;
i
++
)
delete
validators
[
i
];
delete
[]
validators
;
}
ISchemaValidator
**
validators
;
SizeType
count
;
};
SchemaValidationContext
(
const
SchemaValidatorFactoryType
*
f
,
const
SchemaType
*
s
)
:
SchemaValidationContext
(
const
SchemaValidatorFactoryType
*
f
,
const
SchemaType
*
s
)
:
factory
(
f
),
factory
(
f
),
schema
(
s
),
schema
(
s
),
...
@@ -671,7 +656,12 @@ private:
...
@@ -671,7 +656,12 @@ private:
typedef
char
RegexType
;
typedef
char
RegexType
;
#endif
#endif
typedef
SchemaArray
<
Encoding
,
Allocator
>
SchemaArrayType
;
struct
SchemaArray
{
SchemaArray
()
:
schemas
(),
count
()
{}
~
SchemaArray
()
{
delete
[]
schemas
;
}
const
Schema
<
Encoding
,
Allocator
>**
schemas
;
SizeType
count
;
};
static
const
SchemaType
*
GetTypeless
()
{
static
const
SchemaType
*
GetTypeless
()
{
static
SchemaType
typeless
(
0
,
Pointer
(),
Value
(
kObjectType
).
Move
());
static
SchemaType
typeless
(
0
,
Pointer
(),
Value
(
kObjectType
).
Move
());
...
@@ -708,7 +698,7 @@ private:
...
@@ -708,7 +698,7 @@ private:
}
}
template
<
typename
DocumentType
,
typename
ValueType
,
typename
PointerType
>
template
<
typename
DocumentType
,
typename
ValueType
,
typename
PointerType
>
static
void
AssigIfExist
(
SchemaArray
Type
&
out
,
const
DocumentType
&
document
,
const
PointerType
&
p
,
const
ValueType
&
value
,
const
char
*
name
)
{
static
void
AssigIfExist
(
SchemaArray
&
out
,
const
DocumentType
&
document
,
const
PointerType
&
p
,
const
ValueType
&
value
,
const
char
*
name
)
{
if
(
const
ValueType
*
v
=
GetMember
(
value
,
name
))
{
if
(
const
ValueType
*
v
=
GetMember
(
value
,
name
))
{
if
(
v
->
IsArray
()
&&
v
->
Size
()
>
0
)
{
if
(
v
->
IsArray
()
&&
v
->
Size
()
>
0
)
{
PointerType
q
=
p
.
Append
(
name
);
PointerType
q
=
p
.
Append
(
name
);
...
@@ -778,7 +768,7 @@ private:
...
@@ -778,7 +768,7 @@ private:
}
}
}
}
void
CreateSchemaValidators
(
Context
&
context
,
SchemaValidatorArray
&
validators
,
const
SchemaArrayType
&
schemas
)
const
{
void
CreateSchemaValidators
(
Context
&
context
,
typename
Context
::
SchemaValidatorArray
&
validators
,
const
SchemaArray
&
schemas
)
const
{
if
(
!
validators
.
validators
)
{
if
(
!
validators
.
validators
)
{
validators
.
validators
=
new
ISchemaValidator
*
[
schemas
.
count
];
validators
.
validators
=
new
ISchemaValidator
*
[
schemas
.
count
];
validators
.
count
=
schemas
.
count
;
validators
.
count
=
schemas
.
count
;
...
@@ -841,9 +831,9 @@ private:
...
@@ -841,9 +831,9 @@ private:
Allocator
allocator_
;
Allocator
allocator_
;
GenericValue
<
Encoding
>
enum_
;
GenericValue
<
Encoding
>
enum_
;
SchemaArray
Type
allOf_
;
SchemaArray
allOf_
;
SchemaArray
Type
anyOf_
;
SchemaArray
anyOf_
;
SchemaArray
Type
oneOf_
;
SchemaArray
oneOf_
;
const
SchemaType
*
not_
;
const
SchemaType
*
not_
;
const
SchemaType
*
ref_
;
const
SchemaType
*
ref_
;
unsigned
type_
;
// bitmask of kSchemaType
unsigned
type_
;
// bitmask of kSchemaType
...
@@ -880,14 +870,16 @@ private:
...
@@ -880,14 +870,16 @@ private:
bool
exclusiveMaximum_
;
bool
exclusiveMaximum_
;
};
};
}
// namespace internal
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// GenericSchemaDocument
// GenericSchemaDocument
template
<
typename
Encoding
,
typename
Allocator
=
MemoryPoolAllocator
<>
>
template
<
typename
Encoding
,
typename
Allocator
=
MemoryPoolAllocator
<>
>
class
GenericSchemaDocument
{
class
GenericSchemaDocument
{
public
:
public
:
typedef
Schema
<
Encoding
,
Allocator
>
SchemaType
;
typedef
internal
::
Schema
<
Encoding
,
Allocator
>
SchemaType
;
friend
class
Schema
<
Encoding
,
Allocator
>
;
friend
class
internal
::
Schema
<
Encoding
,
Allocator
>
;
template
<
typename
DocumentType
>
template
<
typename
DocumentType
>
GenericSchemaDocument
(
const
DocumentType
&
document
,
Allocator
*
allocator
=
0
)
:
root_
(),
schemas_
(),
schemaCount_
(),
schemaMap_
(
allocator
,
kInitialSchemaMapSize
),
schemaRef_
(
allocator
,
kInitialSchemaRefSize
)
{
GenericSchemaDocument
(
const
DocumentType
&
document
,
Allocator
*
allocator
=
0
)
:
root_
(),
schemas_
(),
schemaCount_
(),
schemaMap_
(
allocator
,
kInitialSchemaMapSize
),
schemaRef_
(
allocator
,
kInitialSchemaRefSize
)
{
...
@@ -981,7 +973,7 @@ typedef GenericSchemaDocument<UTF8<> > SchemaDocument;
...
@@ -981,7 +973,7 @@ typedef GenericSchemaDocument<UTF8<> > SchemaDocument;
// GenericSchemaValidator
// GenericSchemaValidator
template
<
typename
SchemaType
,
typename
OutputHandler
=
BaseReaderHandler
<
typename
SchemaType
::
EncodingType
>
,
typename
StateAllocator
=
CrtAllocator
>
template
<
typename
SchemaType
,
typename
OutputHandler
=
BaseReaderHandler
<
typename
SchemaType
::
EncodingType
>
,
typename
StateAllocator
=
CrtAllocator
>
class
GenericSchemaValidator
:
public
ISchemaValidatorFactory
<
SchemaType
>
,
public
ISchemaValidator
{
class
GenericSchemaValidator
:
public
internal
::
ISchemaValidatorFactory
<
SchemaType
>
,
public
internal
::
ISchemaValidator
{
public
:
public
:
typedef
typename
SchemaType
::
EncodingType
EncodingType
;
typedef
typename
SchemaType
::
EncodingType
EncodingType
;
typedef
typename
EncodingType
::
Ch
Ch
;
typedef
typename
EncodingType
::
Ch
Ch
;
...
@@ -1152,7 +1144,7 @@ private:
...
@@ -1152,7 +1144,7 @@ private:
if
(
count
>
0
)
{
if
(
count
>
0
)
{
CurrentContext
().
objectPatternValidatorType
=
patternValidatorType
;
CurrentContext
().
objectPatternValidatorType
=
patternValidatorType
;
SchemaValidatorArray
&
va
=
CurrentContext
().
patternPropertiesValidators
;
typename
Context
::
SchemaValidatorArray
&
va
=
CurrentContext
().
patternPropertiesValidators
;
va
.
validators
=
new
ISchemaValidator
*
[
count
];
va
.
validators
=
new
ISchemaValidator
*
[
count
];
for
(
SizeType
i
=
0
;
i
<
count
;
i
++
)
for
(
SizeType
i
=
0
;
i
<
count
;
i
++
)
va
.
validators
[
va
.
count
++
]
=
CreateSchemaValidator
(
*
sa
[
i
]);
va
.
validators
[
va
.
count
++
]
=
CreateSchemaValidator
(
*
sa
[
i
]);
...
...
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