Minor refactoring

This commit is contained in:
Milo Yip 2016-02-02 12:56:53 +08:00
parent ba7aa979a5
commit dd2076f8d8
2 changed files with 5 additions and 9 deletions

View File

@ -1550,7 +1550,6 @@ public:
, depth_(0)
#endif
{
CreateOwnAllocator();
}
//! Constructor with output handler.
@ -1579,7 +1578,6 @@ public:
, depth_(0)
#endif
{
CreateOwnAllocator();
}
//! Destructor.
@ -1592,7 +1590,7 @@ public:
void Reset() {
while (!schemaStack_.Empty())
PopSchema();
//documentStack_.Clear();
documentStack_.Clear();
valid_ = true;
}
@ -1615,10 +1613,6 @@ public:
return documentStack_.Empty() ? PointerType() : PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() / sizeof(Ch));
}
StateAllocator& GetStateAllocator() {
return *stateAllocator_;
}
#if RAPIDJSON_SCHEMA_VERBOSE
#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \
RAPIDJSON_MULTILINEMACRO_BEGIN\
@ -1774,12 +1768,12 @@ private:
, depth_(depth)
#endif
{
CreateOwnAllocator();
}
void CreateOwnAllocator() {
StateAllocator& GetStateAllocator() {
if (!stateAllocator_)
stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator());
return *stateAllocator_;
}
bool BeginValue() {

View File

@ -1148,6 +1148,8 @@ TEST(SchemaValidatingWriter, Simple) {
d.Parse("\"ABCD\"");
EXPECT_FALSE(d.Accept(validator));
EXPECT_FALSE(validator.IsValid());
EXPECT_TRUE(validator.GetInvalidSchemaPointer() == SchemaDocument::PointerType(""));
EXPECT_TRUE(validator.GetInvalidDocumentPointer() == SchemaDocument::PointerType(""));
}
#ifdef __clang__