aboutsummaryrefslogtreecommitdiff
path: root/pages/projects/binary_mapping.md
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-09-11 19:25:25 +0200
committerAdrian Kummerlaender2014-09-11 19:25:25 +0200
commit508f63886336c68b4a758502b5ccb353df345e3d (patch)
treec5b8ccbc6f95777eb9851885712a168cab20f3ab /pages/projects/binary_mapping.md
parent218f393c16e4bff9abdd42958ff6d05e23fa281c (diff)
downloadblog_content-508f63886336c68b4a758502b5ccb353df345e3d.tar
blog_content-508f63886336c68b4a758502b5ccb353df345e3d.tar.gz
blog_content-508f63886336c68b4a758502b5ccb353df345e3d.tar.bz2
blog_content-508f63886336c68b4a758502b5ccb353df345e3d.tar.lz
blog_content-508f63886336c68b4a758502b5ccb353df345e3d.tar.xz
blog_content-508f63886336c68b4a758502b5ccb353df345e3d.tar.zst
blog_content-508f63886336c68b4a758502b5ccb353df345e3d.zip
Expanded the content of some project pages
Diffstat (limited to 'pages/projects/binary_mapping.md')
-rw-r--r--pages/projects/binary_mapping.md31
1 files changed, 29 insertions, 2 deletions
diff --git a/pages/projects/binary_mapping.md b/pages/projects/binary_mapping.md
index c178236..0c1d2ed 100644
--- a/pages/projects/binary_mapping.md
+++ b/pages/projects/binary_mapping.md
@@ -19,6 +19,33 @@ A explanation of an earlier version of this template library can be found on thi
* Unit Tests based on GoogleTest
* MIT license
-[blog]: /article/mapping-binary-structures-as-tuples-using-template-metaprogramming
-[Github]: https://github.com/KnairdA/BinaryMapping
+## Usage example
+
+~~~
+BinaryMapping::Container<
+ BinaryMapping::Tuple<
+ BinaryMapping::LittleEndian,
+ std::uint32_t,
+ std::int16_t,
+ BinaryMapping::ByteField<3>,
+ std::uint8_t
+ >
+> container(10);
+
+for ( auto&& tuple : container ) {
+ tuple.set<0>(UINT32_MAX);
+ tuple.set<1>(INT16_MAX);
+ tuple.set<2>({1, 2, 3});
+ tuple.set<3>(42);
+}
+
+std::uint32_t test = container.at(5).get<0>();
+~~~
+{: .language-cpp}
+
+The code listed above defines a container of a tuple consisting of a `std::uint32_t`, `std::int16_t`, 3-byte and `std::uint8_t` field with little endianess, instantiates a buffer containing ten instances of this tuple, iterates through all 10 elements, gives them values, transparently converts to the correct endianess and extracts the value of the first field of the fifth tuple contained in the buffer. In short: BinaryMapping is a library that abstracts endianess aware serializing of binary structures into structures, containers and iterators. If you are interested in further details of the usage of all features provided by BinaryMapping don't hesitate to check out the [documentation].
+
+[blog]: /article/mapping_binary_structures_as_tuples_using_template_metaprogramming
+[Github]: https://github.com/KnairdA/BinaryMapping/
[cgit]: http://code.kummerlaender.eu/BinaryMapping/
+[documentation]: https://github.com/KnairdA/BinaryMapping/blob/master/docs/