diff options
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 |
