Commit dd2076f8 authored by Milo Yip's avatar Milo Yip

Minor refactoring

parent ba7aa979
...@@ -1550,7 +1550,6 @@ public: ...@@ -1550,7 +1550,6 @@ public:
, depth_(0) , depth_(0)
#endif #endif
{ {
CreateOwnAllocator();
} }
//! Constructor with output handler. //! Constructor with output handler.
...@@ -1579,7 +1578,6 @@ public: ...@@ -1579,7 +1578,6 @@ public:
, depth_(0) , depth_(0)
#endif #endif
{ {
CreateOwnAllocator();
} }
//! Destructor. //! Destructor.
...@@ -1592,7 +1590,7 @@ public: ...@@ -1592,7 +1590,7 @@ public:
void Reset() { void Reset() {
while (!schemaStack_.Empty()) while (!schemaStack_.Empty())
PopSchema(); PopSchema();
//documentStack_.Clear(); documentStack_.Clear();
valid_ = true; valid_ = true;
} }
...@@ -1615,10 +1613,6 @@ public: ...@@ -1615,10 +1613,6 @@ public:
return documentStack_.Empty() ? PointerType() : PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() / sizeof(Ch)); return documentStack_.Empty() ? PointerType() : PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() / sizeof(Ch));
} }
StateAllocator& GetStateAllocator() {
return *stateAllocator_;
}
#if RAPIDJSON_SCHEMA_VERBOSE #if RAPIDJSON_SCHEMA_VERBOSE
#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \ #define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \
RAPIDJSON_MULTILINEMACRO_BEGIN\ RAPIDJSON_MULTILINEMACRO_BEGIN\
...@@ -1774,12 +1768,12 @@ private: ...@@ -1774,12 +1768,12 @@ private:
, depth_(depth) , depth_(depth)
#endif #endif
{ {
CreateOwnAllocator();
} }
void CreateOwnAllocator() { StateAllocator& GetStateAllocator() {
if (!stateAllocator_) if (!stateAllocator_)
stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator()); stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator());
return *stateAllocator_;
} }
bool BeginValue() { bool BeginValue() {
......
...@@ -1148,6 +1148,8 @@ TEST(SchemaValidatingWriter, Simple) { ...@@ -1148,6 +1148,8 @@ TEST(SchemaValidatingWriter, Simple) {
d.Parse("\"ABCD\""); d.Parse("\"ABCD\"");
EXPECT_FALSE(d.Accept(validator)); EXPECT_FALSE(d.Accept(validator));
EXPECT_FALSE(validator.IsValid()); EXPECT_FALSE(validator.IsValid());
EXPECT_TRUE(validator.GetInvalidSchemaPointer() == SchemaDocument::PointerType(""));
EXPECT_TRUE(validator.GetInvalidDocumentPointer() == SchemaDocument::PointerType(""));
} }
#ifdef __clang__ #ifdef __clang__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment