mirror of https://github.com/odrling/Aegisub
Remove all the json::Reader::Read overloads, as we never actually use them
Originally committed to SVN as r6021.
This commit is contained in:
parent
ba1d1596de
commit
61b1741376
|
@ -85,17 +85,7 @@ public:
|
|||
bool EOS() const { return m_itCurrent == m_Tokens.end(); }
|
||||
};
|
||||
|
||||
void Reader::Read(Object& object, std::istream& istr) { Read_i(object, istr); }
|
||||
void Reader::Read(Array& array, std::istream& istr) { Read_i(array, istr); }
|
||||
void Reader::Read(String& string, std::istream& istr) { Read_i(string, istr); }
|
||||
void Reader::Read(Integer& number, std::istream& istr) { Read_i(number, istr); }
|
||||
void Reader::Read(Double& number, std::istream& istr) { Read_i(number, istr); }
|
||||
void Reader::Read(Boolean& boolean, std::istream& istr) { Read_i(boolean, istr); }
|
||||
void Reader::Read(Null& null, std::istream& istr) { Read_i(null, istr); }
|
||||
void Reader::Read(UnknownElement& unknown, std::istream& istr) { Read_i(unknown, istr); }
|
||||
|
||||
template <typename ElementTypeT>
|
||||
void Reader::Read_i(ElementTypeT& element, std::istream& istr) {
|
||||
void Reader::Read(UnknownElement& unknown, std::istream& istr) {
|
||||
Reader reader;
|
||||
|
||||
Tokens tokens;
|
||||
|
@ -103,7 +93,7 @@ void Reader::Read_i(ElementTypeT& element, std::istream& istr) {
|
|||
reader.Scan(tokens, inputStream);
|
||||
|
||||
TokenStream tokenStream(tokens);
|
||||
element = reader.Parse(tokenStream);
|
||||
unknown = reader.Parse(tokenStream);
|
||||
|
||||
if (!tokenStream.EOS()) {
|
||||
Token const& token = tokenStream.Peek();
|
||||
|
|
|
@ -55,16 +55,6 @@ public:
|
|||
Reader::Location m_locTokenEnd;
|
||||
};
|
||||
|
||||
// if you know what the document looks like, call one of these...
|
||||
static void Read(Object& object, std::istream& istr);
|
||||
static void Read(Array& array, std::istream& istr);
|
||||
static void Read(String& string, std::istream& istr);
|
||||
static void Read(Integer& number, std::istream& istr);
|
||||
static void Read(Double& number, std::istream& istr);
|
||||
static void Read(Boolean& boolean, std::istream& istr);
|
||||
static void Read(Null& null, std::istream& istr);
|
||||
|
||||
// ...otherwise, if you don't know, call this & visit it
|
||||
static void Read(UnknownElement& elementRoot, std::istream& istr);
|
||||
|
||||
private:
|
||||
|
@ -94,9 +84,6 @@ private:
|
|||
class TokenStream;
|
||||
typedef std::vector<Token> Tokens;
|
||||
|
||||
template <typename ElementTypeT>
|
||||
static void Read_i(ElementTypeT& element, std::istream& istr);
|
||||
|
||||
// scanning istream into token sequence
|
||||
void Scan(Tokens& tokens, InputStream& inputStream);
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ TEST_F(lagi_cajun, ObjectEquality) {
|
|||
}
|
||||
|
||||
TEST_F(lagi_cajun, Read) {
|
||||
json::Object obj;
|
||||
json::UnknownElement obj;
|
||||
std::istringstream doc("{\"String\" : \"This is a test\", \"Boolean\" : false, \"Null\" : null }");
|
||||
EXPECT_NO_THROW(json::Reader::Read(obj, doc));
|
||||
EXPECT_NO_THROW(obj["String"]);
|
||||
|
@ -321,52 +321,47 @@ TEST_F(lagi_cajun, Write) {
|
|||
}
|
||||
|
||||
TEST_F(lagi_cajun, ReaderParserErrors) {
|
||||
json::Array arr;
|
||||
json::UnknownElement ue;
|
||||
|
||||
std::istringstream missing_comma("[1 2]");
|
||||
EXPECT_THROW(json::Reader::Read(arr, missing_comma), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, missing_comma), json::Exception);
|
||||
|
||||
json::Double num;
|
||||
std::istringstream garbage_after_number("123eee");
|
||||
EXPECT_THROW(json::Reader::Read(num, garbage_after_number), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, garbage_after_number), json::Exception);
|
||||
|
||||
json::String str;
|
||||
std::istringstream unexpected_eof("[");
|
||||
EXPECT_THROW(json::Reader::Read(str, unexpected_eof), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, unexpected_eof), json::Exception);
|
||||
|
||||
std::istringstream bad_initial_token("]");
|
||||
EXPECT_THROW(json::Reader::Read(str, bad_initial_token), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, bad_initial_token), json::Exception);
|
||||
|
||||
std::istringstream garbage_after_end("[]a");
|
||||
EXPECT_THROW(json::Reader::Read(str, garbage_after_end), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, garbage_after_end), json::Exception);
|
||||
|
||||
json::Null null;
|
||||
std::istringstream empty_str("");
|
||||
EXPECT_THROW(json::Reader::Read(null, empty_str), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, empty_str), json::Exception);
|
||||
|
||||
json::Object obj;
|
||||
std::istringstream dupe_keys("{\"a\": [], \"a\": 0}");
|
||||
EXPECT_THROW(json::Reader::Read(obj, dupe_keys), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, dupe_keys), json::Exception);
|
||||
|
||||
std::istringstream unique_keys("{\"a\": [], \"b\": 0}");
|
||||
EXPECT_NO_THROW(json::Reader::Read(obj, unique_keys));
|
||||
EXPECT_NO_THROW(json::Reader::Read(ue, unique_keys));
|
||||
}
|
||||
|
||||
TEST_F(lagi_cajun, ReaderScanErrors) {
|
||||
json::Object obj;
|
||||
json::UnknownElement ue;
|
||||
|
||||
std::istringstream doc("[true, false, thiswontwork]");
|
||||
EXPECT_THROW(json::Reader::Read(ue, doc), json::Exception);
|
||||
|
||||
EXPECT_THROW(json::Reader::Read(obj, doc), json::Exception);
|
||||
|
||||
json::Double num;
|
||||
std::istringstream garbage_after_number("123abc");
|
||||
EXPECT_THROW(json::Reader::Read(num, garbage_after_number), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, garbage_after_number), json::Exception);
|
||||
|
||||
json::String str;
|
||||
std::istringstream bad_escape("\"\\j\"");
|
||||
EXPECT_THROW(json::Reader::Read(str, bad_escape), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, bad_escape), json::Exception);
|
||||
|
||||
std::istringstream unexpected_eof("\"abc");
|
||||
EXPECT_THROW(json::Reader::Read(str, unexpected_eof), json::Exception);
|
||||
EXPECT_THROW(json::Reader::Read(ue, unexpected_eof), json::Exception);
|
||||
}
|
||||
|
||||
std::string roundtrip_test(const char *in) {
|
||||
|
|
Loading…
Reference in New Issue