diff options
Diffstat (limited to 'binparse')
| -rw-r--r-- | binparse/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | binparse/output.hpp | 4 | ||||
| -rw-r--r-- | binparse/parse.hpp | 6 | ||||
| -rw-r--r-- | binparse/variant_output_helper.hpp | 18 |
4 files changed, 29 insertions, 0 deletions
diff --git a/binparse/CMakeLists.txt b/binparse/CMakeLists.txt index c41a2b5..e436331 100644 --- a/binparse/CMakeLists.txt +++ b/binparse/CMakeLists.txt @@ -1,6 +1,7 @@ add_library(binparse STATIC types.hpp + variant_output_helper.hpp parse.hpp parse.cpp output.hpp output.cpp otreestream.hpp otreestream.cpp diff --git a/binparse/output.hpp b/binparse/output.hpp index c5db2da..3919bef 100644 --- a/binparse/output.hpp +++ b/binparse/output.hpp @@ -42,6 +42,10 @@ std::ostream& operator<<(std::ostream& os, std::vector<uint8_t> vec); template <typename T, typename std::enable_if<boost::fusion::traits::is_sequence<T>::value>::type* = nullptr> std::ostream& operator<<(std::ostream&, T const&); + +template <typename ValueType> +std::ostream& operator<<(std::ostream& os, std::vector<ValueType> const& vec); + template <typename Key, typename Value> std::ostream& operator<<(std::ostream& os, std::map<Key, Value> const& map) { try { diff --git a/binparse/parse.hpp b/binparse/parse.hpp index 2103177..e02b230 100644 --- a/binparse/parse.hpp +++ b/binparse/parse.hpp @@ -12,9 +12,15 @@ #include <array> #include <vector> #include <string> +#include <cmath> namespace binparse { +template<typename T> +constexpr bool bit(unsigned char bit, T const& t) { + return t & T(std::pow(2, bit)); +} + struct UnexpectedEOS : public std::runtime_error { UnexpectedEOS(); diff --git a/binparse/variant_output_helper.hpp b/binparse/variant_output_helper.hpp new file mode 100644 index 0000000..7207a36 --- /dev/null +++ b/binparse/variant_output_helper.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "output.hpp" + +#include <boost/fusion/support/is_sequence.hpp> + +#include <ostream> + +namespace boost { namespace detail { namespace variant { + +template <typename T, typename std::enable_if<boost::fusion::traits::is_sequence<T>::value>::type* = nullptr> +std::ostream& operator<<(std::ostream& os, T const& t) { + return binparse::operator<<(os, t); +} + +} +} +}
\ No newline at end of file |
