Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
petya2164 committed May 2, 2017
1 parent 7622250 commit a98c8ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion NEWS.rst
Expand Up @@ -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
-----
Expand All @@ -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
-----
Expand Down
15 changes: 14 additions & 1 deletion src/hex/dump.hpp
Expand Up @@ -48,6 +48,7 @@ struct dump
assert(m_size);
}

/// @param vector The vector instance which we want to dump
template<class PodType, class Allocator>
dump(const std::vector<PodType, Allocator>& vector)
{
Expand Down Expand Up @@ -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<uint8_t> 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<uint8_t> parse_hex_string(const std::string& hex_string)
{
std::vector<uint8_t> result;
Expand All @@ -97,6 +103,13 @@ inline std::vector<uint8_t> 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)
Expand Down

0 comments on commit a98c8ed

Please sign in to comment.