diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-06-19 20:23:07 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-06-19 20:23:07 +0200 |
| commit | cea325b7451c1fb8dd22462ec2e7b5b88ea9b547 (patch) | |
| tree | ffa2811b2ca24b3aa7e08bb28b45e7e9adbd154c /binparse/binparse.hpp | |
| parent | c66d1f5c0af70161f4ad4c4175f4280e95b55dfd (diff) | |
| download | openwar-cea325b7451c1fb8dd22462ec2e7b5b88ea9b547.tar.gz openwar-cea325b7451c1fb8dd22462ec2e7b5b88ea9b547.tar.bz2 openwar-cea325b7451c1fb8dd22462ec2e7b5b88ea9b547.zip | |
Adds an LE executable parser.
Adds the binparse library that holds common components for the MZ and LE parsers.
Diffstat (limited to 'binparse/binparse.hpp')
| -rw-r--r-- | binparse/binparse.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/binparse/binparse.hpp b/binparse/binparse.hpp new file mode 100644 index 0000000..1620ab5 --- /dev/null +++ b/binparse/binparse.hpp @@ -0,0 +1,57 @@ +#include "types.hpp" + +#include <string> +#include <ostream> +#include <iomanip> + +namespace binparse { + +struct UnexpectedEOS : public std::runtime_error { + UnexpectedEOS(); + + UnexpectedEOS(std::string location); +}; + +template<typename T> +T parse(std::istream& is, std::string name); + +template<> +uint8_t parse<uint8_t>(std::istream& is, std::string name); + +template<> +uint16_t parse<uint16_t>(std::istream& is, std::string name); + +template<> +uint32_t parse<uint32_t>(std::istream& is, std::string name); + +template<> +Magic16 parse<Magic16>(std::istream& is, std::string name); + +template<> +Value16 parse<Value16>(std::istream& is, std::string name); + +template<> +Offset16 parse<Offset16>(std::istream& is, std::string name); + +template<> +Value32 parse<Value32>(std::istream& is, std::string name); + +template<> +Offset32 parse<Offset32>(std::istream& is, std::string name); + +std::string to_string(Magic16 magic); + +//overload inside this namespace to output unsigned char as value not as characters. +std::ostream& operator<<(std::ostream& os, uint8_t); + +std::ostream& operator<<(std::ostream& os, Value8 v); +std::ostream& operator<<(std::ostream& os, Offset8 o); + +std::ostream& operator<<(std::ostream& os, Magic16 m); +std::ostream& operator<<(std::ostream& os, Value16 v); +std::ostream& operator<<(std::ostream& os, Offset16 o); + +std::ostream& operator<<(std::ostream& os, Value32 v); +std::ostream& operator<<(std::ostream& os, Offset32 o); + +}
\ No newline at end of file |
