@@ -54,9 +54,9 @@ static size_t const stackLimit_g =
54
54
namespace Json {
55
55
56
56
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
57
- using CharReaderPtr = std::unique_ptr<CharReader>;
57
+ using CharReaderPtr = std::unique_ptr<CharReader::Impl >;
58
58
#else
59
- using CharReaderPtr = std::auto_ptr<CharReader>;
59
+ using CharReaderPtr = std::auto_ptr<CharReader::Impl >;
60
60
#endif
61
61
62
62
// Implementation of class Features
@@ -890,17 +890,12 @@ class OurReader {
890
890
public:
891
891
using Char = char ;
892
892
using Location = const Char*;
893
- struct StructuredError {
894
- ptrdiff_t offset_start;
895
- ptrdiff_t offset_limit;
896
- String message;
897
- };
898
893
899
894
explicit OurReader (OurFeatures const & features);
900
895
bool parse (const char * beginDoc, const char * endDoc, Value& root,
901
896
bool collectComments = true );
902
897
String getFormattedErrorMessages () const ;
903
- std::vector<StructuredError> getStructuredErrors () const ;
898
+ std::vector<CharReader:: StructuredError> getStructuredErrors () const ;
904
899
905
900
private:
906
901
OurReader (OurReader const &); // no impl
@@ -1860,10 +1855,10 @@ String OurReader::getFormattedErrorMessages() const {
1860
1855
return formattedMessage;
1861
1856
}
1862
1857
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;
1865
1860
for (const auto & error : errors_) {
1866
- OurReader ::StructuredError structured;
1861
+ CharReader ::StructuredError structured;
1867
1862
structured.offset_start = error.token_ .start_ - begin_;
1868
1863
structured.offset_limit = error.token_ .end_ - begin_;
1869
1864
structured.message = error.message_ ;
@@ -1872,7 +1867,7 @@ std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
1872
1867
return allErrors;
1873
1868
}
1874
1869
1875
- class OurCharReader : public CharReader {
1870
+ class OurCharReader : public CharReader ::Impl {
1876
1871
bool const collectComments_;
1877
1872
OurReader reader_;
1878
1873
@@ -1887,11 +1882,14 @@ class OurCharReader : public CharReader {
1887
1882
}
1888
1883
return ok;
1889
1884
}
1885
+ std::vector<CharReader::StructuredError> getStructuredErrors () const {
1886
+ return reader_.getStructuredErrors ();
1887
+ }
1890
1888
};
1891
1889
1892
1890
CharReaderBuilder::CharReaderBuilder () { setDefaults (&settings_); }
1893
1891
CharReaderBuilder::~CharReaderBuilder () = default ;
1894
- CharReader* CharReaderBuilder::newCharReader () const {
1892
+ CharReader::Impl * CharReaderBuilder::newCharReader () const {
1895
1893
bool collectComments = settings_[" collectComments" ].asBool ();
1896
1894
OurFeatures features = OurFeatures::all ();
1897
1895
features.allowComments_ = settings_[" allowComments" ].asBool ();
@@ -1976,6 +1974,15 @@ void CharReaderBuilder::setDefaults(Json::Value* settings) {
1976
1974
// ! [CharReaderBuilderDefaults]
1977
1975
}
1978
1976
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
+
1979
1986
// ////////////////////////////////
1980
1987
// global functions
1981
1988
0 commit comments