diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-08-06 10:27:06 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-08-06 10:27:06 +0200 |
| commit | b5cff8cc5c72c8d895e97075c0ab0f223cd81b09 (patch) | |
| tree | 2fbc937b2ddab3cca102341caadd6c6cc6373d45 | |
| parent | 7626425b2c6299b38865aa10c8d912e946f5f88f (diff) | |
| download | Project-Tick-b5cff8cc5c72c8d895e97075c0ab0f223cd81b09.tar.gz Project-Tick-b5cff8cc5c72c8d895e97075c0ab0f223cd81b09.zip | |
Move input_error out from stream_reader
| -rw-r--r-- | include/io/stream_reader.h | 12 | ||||
| -rw-r--r-- | src/tag_array.cpp | 8 | ||||
| -rw-r--r-- | src/tag_list.cpp | 2 | ||||
| -rw-r--r-- | src/tag_primitive.cpp | 2 | ||||
| -rw-r--r-- | test/io/read_test.cpp | 6 |
5 files changed, 15 insertions, 15 deletions
diff --git a/include/io/stream_reader.h b/include/io/stream_reader.h index 056d14e9dd..7d97824927 100644 --- a/include/io/stream_reader.h +++ b/include/io/stream_reader.h @@ -31,18 +31,18 @@ namespace nbt namespace io { +///Exception that gets thrown when reading is not successful +class input_error : public std::runtime_error +{ + using std::runtime_error::runtime_error; +}; + /** * @brief Helper class for reading NBT tags from input streams */ class stream_reader { public: - ///Exception that gets thrown when reading is not successful - class input_error : public std::runtime_error - { - using std::runtime_error::runtime_error; - }; - /** * @param is the stream to read from * @param e the byte order of the source data. The Java edition diff --git a/src/tag_array.cpp b/src/tag_array.cpp index f521768dd5..94b8ffe7ac 100644 --- a/src/tag_array.cpp +++ b/src/tag_array.cpp @@ -108,12 +108,12 @@ void tag_array<int8_t>::read_payload(io::stream_reader& reader) int32_t length; reader.read_num(length); if(length < 0 || !reader.get_istr()) - throw io::stream_reader::input_error("Error reading length of tag_byte_array"); + throw io::input_error("Error reading length of tag_byte_array"); data.resize(length); reader.get_istr().read(reinterpret_cast<char*>(data.data()), length); if(!reader.get_istr()) - throw io::stream_reader::input_error("Error reading contents of tag_byte_array"); + throw io::input_error("Error reading contents of tag_byte_array"); } template<> @@ -122,7 +122,7 @@ void tag_array<int32_t>::read_payload(io::stream_reader& reader) int32_t length; reader.read_num(length); if(length < 0 || !reader.get_istr()) - throw io::stream_reader::input_error("Error reading length of tag_int_array"); + throw io::input_error("Error reading length of tag_int_array"); data.clear(); data.reserve(length); @@ -133,7 +133,7 @@ void tag_array<int32_t>::read_payload(io::stream_reader& reader) data.push_back(val); } if(!reader.get_istr()) - throw io::stream_reader::input_error("Error reading contents of tag_int_array"); + throw io::input_error("Error reading contents of tag_int_array"); } template<class T> diff --git a/src/tag_list.cpp b/src/tag_list.cpp index 3bcc42e8b6..53c1a8e392 100644 --- a/src/tag_list.cpp +++ b/src/tag_list.cpp @@ -139,7 +139,7 @@ void tag_list::read_payload(io::stream_reader& reader) int32_t length; reader.read_num(length); if(length < 0 || !reader.get_istr()) - throw io::stream_reader::input_error("Error reading length of tag_list"); + throw io::input_error("Error reading length of tag_list"); if(lt != tag_type::End) { diff --git a/src/tag_primitive.cpp b/src/tag_primitive.cpp index 15fc87d752..358d946e6a 100644 --- a/src/tag_primitive.cpp +++ b/src/tag_primitive.cpp @@ -72,7 +72,7 @@ void tag_primitive<T>::read_payload(io::stream_reader& reader) { std::ostringstream str; str << "Error reading " << type; - throw io::stream_reader::input_error(str.str()); + throw io::input_error(str.str()); } } diff --git a/test/io/read_test.cpp b/test/io/read_test.cpp index d3ea8b7765..a6de378e1d 100644 --- a/test/io/read_test.cpp +++ b/test/io/read_test.cpp @@ -55,13 +55,13 @@ void test_stream_reader_big() ASSERT(reader.read_string() == "foobar"); - EXPECT_EXCEPTION(reader.read_type(false), io::stream_reader::input_error); + EXPECT_EXCEPTION(reader.read_type(false), io::input_error); ASSERT(!is); is.clear(); //Test for invalid tag type 12 is.str("\x0c"); - EXPECT_EXCEPTION(reader.read_type(), io::stream_reader::input_error); + EXPECT_EXCEPTION(reader.read_type(), io::input_error); ASSERT(!is); is.clear(); @@ -93,7 +93,7 @@ void test_stream_reader_little() ASSERT(reader.read_string() == "foobar"); - EXPECT_EXCEPTION(reader.read_string(), io::stream_reader::input_error); + EXPECT_EXCEPTION(reader.read_string(), io::input_error); ASSERT(!is); } |
