Skip to content

Commit 052050d

Browse files
committed
copy Features to OldFeatures
1 parent 435d2a2 commit 052050d

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

src/lib_json/json_reader.cpp

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,39 @@ bool Reader::good() const {
892892
return !errors_.size();
893893
}
894894

895+
// exact copy of Features
896+
class OldFeatures {
897+
public:
898+
static OldFeatures all();
899+
static OldFeatures strictMode();
900+
OldFeatures();
901+
bool allowComments_;
902+
bool strictRoot_;
903+
bool allowDroppedNullPlaceholders_;
904+
bool allowNumericKeys_;
905+
}; // OldFeatures
906+
907+
// exact copy of Implementation of class Features
908+
// ////////////////////////////////
909+
910+
OldFeatures::OldFeatures()
911+
: allowComments_(true), strictRoot_(false),
912+
allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) {}
913+
914+
OldFeatures OldFeatures::all() { return OldFeatures(); }
915+
916+
OldFeatures OldFeatures::strictMode() {
917+
OldFeatures features;
918+
features.allowComments_ = false;
919+
features.strictRoot_ = true;
920+
features.allowDroppedNullPlaceholders_ = false;
921+
features.allowNumericKeys_ = false;
922+
return features;
923+
}
924+
925+
// Implementation of class Reader
926+
// ////////////////////////////////
927+
895928
// exact copy of Reader, renamed to OldReader
896929
class OldReader {
897930
public:
@@ -903,7 +936,7 @@ class OldReader {
903936
std::string message;
904937
};
905938

906-
OldReader(Features const& features);
939+
OldReader(OldFeatures const& features);
907940
bool parse(const char* beginDoc,
908941
const char* endDoc,
909942
Value& root,
@@ -1000,13 +1033,13 @@ class OldReader {
10001033
Location lastValueEnd_;
10011034
Value* lastValue_;
10021035
std::string commentsBefore_;
1003-
Features features_;
1036+
OldFeatures features_;
10041037
bool collectComments_;
10051038
}; // OldReader
10061039

10071040
// complete copy of Read impl, for OldReader
10081041

1009-
OldReader::OldReader(Features const& features)
1042+
OldReader::OldReader(OldFeatures const& features)
10101043
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
10111044
lastValue_(), commentsBefore_(), features_(features), collectComments_() {
10121045
}
@@ -1788,7 +1821,7 @@ class OldCharReader : public CharReader {
17881821
public:
17891822
OldCharReader(
17901823
bool collectComments,
1791-
Features const& features)
1824+
OldFeatures const& features)
17921825
: collectComments_(collectComments)
17931826
, reader_(features)
17941827
{}
@@ -1815,7 +1848,7 @@ CharReader* CharReaderBuilder::newCharReader() const
18151848
// TODO: Maybe serialize the invalid settings into the exception.
18161849

18171850
bool collectComments = settings_["collectComments"].asBool();
1818-
Features features = Features::all();
1851+
OldFeatures features = OldFeatures::all();
18191852
features.allowComments_ = settings_["allowComments"].asBool();
18201853
features.strictRoot_ = settings_["strictRoot"].asBool();
18211854
features.allowDroppedNullPlaceholders_ = settings_["allowDroppedNullPlaceholders"].asBool();

0 commit comments

Comments
 (0)