@@ -54,9 +54,9 @@ static size_t const stackLimit_g =
5454namespace Json {
5555
5656#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
57- using CharReaderPtr = std::unique_ptr<CharReader>;
57+ using CharReaderPtr = std::unique_ptr<CharReader::Impl >;
5858#else
59- using CharReaderPtr = std::auto_ptr<CharReader>;
59+ using CharReaderPtr = std::auto_ptr<CharReader::Impl >;
6060#endif
6161
6262// Implementation of class Features
@@ -890,17 +890,12 @@ class OurReader {
890890public:
891891 using Char = char ;
892892 using Location = const Char*;
893- struct StructuredError {
894- ptrdiff_t offset_start;
895- ptrdiff_t offset_limit;
896- String message;
897- };
898893
899894 explicit OurReader (OurFeatures const & features);
900895 bool parse (const char * beginDoc, const char * endDoc, Value& root,
901896 bool collectComments = true );
902897 String getFormattedErrorMessages () const ;
903- std::vector<StructuredError> getStructuredErrors () const ;
898+ std::vector<CharReader:: StructuredError> getStructuredErrors () const ;
904899
905900private:
906901 OurReader (OurReader const &); // no impl
@@ -1860,10 +1855,10 @@ String OurReader::getFormattedErrorMessages() const {
18601855 return formattedMessage;
18611856}
18621857
1863- std::vector<OurReader ::StructuredError> OurReader::getStructuredErrors () const {
1864- std::vector<OurReader ::StructuredError> allErrors;
1858+ std::vector<CharReader ::StructuredError> OurReader::getStructuredErrors () const {
1859+ std::vector<CharReader ::StructuredError> allErrors;
18651860 for (const auto & error : errors_) {
1866- OurReader ::StructuredError structured;
1861+ CharReader ::StructuredError structured;
18671862 structured.offset_start = error.token_ .start_ - begin_;
18681863 structured.offset_limit = error.token_ .end_ - begin_;
18691864 structured.message = error.message_ ;
@@ -1872,7 +1867,7 @@ std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
18721867 return allErrors;
18731868}
18741869
1875- class OurCharReader : public CharReader {
1870+ class OurCharReader : public CharReader ::Impl {
18761871 bool const collectComments_;
18771872 OurReader reader_;
18781873
@@ -1887,11 +1882,14 @@ class OurCharReader : public CharReader {
18871882 }
18881883 return ok;
18891884 }
1885+ std::vector<CharReader::StructuredError> getStructuredErrors () const {
1886+ return reader_.getStructuredErrors ();
1887+ }
18901888};
18911889
18921890CharReaderBuilder::CharReaderBuilder () { setDefaults (&settings_); }
18931891CharReaderBuilder::~CharReaderBuilder () = default ;
1894- CharReader* CharReaderBuilder::newCharReader () const {
1892+ CharReader::Impl * CharReaderBuilder::newCharReader () const {
18951893 bool collectComments = settings_[" collectComments" ].asBool ();
18961894 OurFeatures features = OurFeatures::all ();
18971895 features.allowComments_ = settings_[" allowComments" ].asBool ();
@@ -1976,6 +1974,15 @@ void CharReaderBuilder::setDefaults(Json::Value* settings) {
19761974 // ! [CharReaderBuilderDefaults]
19771975}
19781976
1977+ auto CharReader::getStructuredErrors () const -> std::vector<CharReader::StructuredError> {
1978+ return _impl->getStructuredErrors ();
1979+ }
1980+
1981+ bool CharReader::parse (char const * beginDoc, char const * endDoc, Value* root,
1982+ String* errs) {
1983+ return _impl->parse (beginDoc, endDoc, root, errs);
1984+ }
1985+
19791986// ////////////////////////////////
19801987// global functions
19811988
0 commit comments