summaryrefslogtreecommitdiff
path: root/le/le_object_table_entry.cpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-06-22 00:15:08 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-06-22 00:16:28 +0200
commit22231518b9c2c0b7f73c72a6ca834df659c63c7f (patch)
tree12b1d20efd3303583649966ddfe135a81ae8109b /le/le_object_table_entry.cpp
parent46145fe7d5b1d9f0921121a088a3d61f968cc473 (diff)
downloadopenwar-22231518b9c2c0b7f73c72a6ca834df659c63c7f.tar.gz
openwar-22231518b9c2c0b7f73c72a6ca834df659c63c7f.tar.bz2
openwar-22231518b9c2c0b7f73c72a6ca834df659c63c7f.zip
Reduces the amount of boilerplate neccesary to parse the binary format.
Diffstat (limited to 'le/le_object_table_entry.cpp')
-rw-r--r--le/le_object_table_entry.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/le/le_object_table_entry.cpp b/le/le_object_table_entry.cpp
new file mode 100644
index 0000000..92810aa
--- /dev/null
+++ b/le/le_object_table_entry.cpp
@@ -0,0 +1,31 @@
+#include "le_object_table_entry.hpp"
+
+#include "parse.hpp"
+#include "output.hpp"
+
+#include <boost/fusion/adapted/struct.hpp>
+
+BOOST_FUSION_ADAPT_STRUCT(
+ le::ObjectTableEntry,
+ (binparse::Value32, virtual_size)
+ (binparse::Offset32, reloc_base_address)
+ (binparse::Value32, ojbect_flags)
+ (binparse::Value32, page_table_index)
+ (binparse::Value32, nr_page_table_entries)
+ (binparse::Value32, reserved)
+)
+
+namespace le {
+
+ObjectTableEntry parse_object_table_entry(std::istream& is) {
+ using binparse::parse;
+
+ return parse<ObjectTableEntry>(is);
+}
+
+std::ostream& operator<<(std::ostream& os, const ObjectTableEntry& entry)
+{
+ return binparse::operator<<(os, entry);
+}
+
+}