From a98c8ed93a6fe8ddc33a5001313d1415e14f14b0 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Tue, 2 May 2017 23:31:52 +0200 Subject: [PATCH] Add some comments --- NEWS.rst | 5 ++++- src/hex/dump.hpp | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 61e4141..4837d57 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -7,6 +7,9 @@ every change, see the Git log. Latest ------ * tbd +* Minor: Added a constructor to create a hex::dump object from std::vector. +* Minor: Added the parse_hex_string helper function to create a byte vector +from a hexadecimal string representation. 4.0.0 ----- @@ -20,7 +23,7 @@ Latest 2.0.0 ----- -* Major: Removed dependency on storage to ease reuseability. +* Major: Removed dependency on storage to ease reuseability. 1.0.0 ----- diff --git a/src/hex/dump.hpp b/src/hex/dump.hpp index 36d41d1..53be11c 100644 --- a/src/hex/dump.hpp +++ b/src/hex/dump.hpp @@ -48,6 +48,7 @@ struct dump assert(m_size); } + /// @param vector The vector instance which we want to dump template dump(const std::vector& vector) { @@ -80,7 +81,12 @@ struct dump uint32_t m_size; }; - +/// Helper function to convert a hexadecimal string to an equivalent byte +/// vector. For example, the string "ff 02 03 04" is converted to a +/// std::vector containing { 0xff, 0x02, 0x03, 0x04 }. +/// +/// @param hex_string The input string of hexadecimal characters +/// @return The byte vector created from the string representation inline std::vector parse_hex_string(const std::string& hex_string) { std::vector result; @@ -97,6 +103,13 @@ inline std::vector parse_hex_string(const std::string& hex_string) return result; } +/// Compares two hex::dump objects to see whether they are +/// equal, i.e. they contain exactly the same data. +/// +/// @param a The first hex::dump object +/// @param b The second hex::dump object +/// @return True if the hex::dump objects contain the same data, +/// otherwise false. inline bool operator==(const dump& a, const dump& b) { if (a.m_size != b.m_size)