Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
InputByteStream: add docs to readers
Browse files Browse the repository at this point in the history
  • Loading branch information
anonimal committed Feb 8, 2018
1 parent 9a30188 commit b988ea7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/core/util/byte_stream.h
Expand Up @@ -46,7 +46,6 @@ namespace kovri
{
namespace core
{

// TODO(anonimal): our interfaces should use const pointer - but doing so will break
// our current SSU implementation. Finish the SSU rewrite and use const correctness!
class ByteStream
Expand Down Expand Up @@ -113,15 +112,10 @@ class InputByteStream : public ByteStream

// TODO(anonimal): optional endian conversion

/// @brief Reads unsigned integral value from stream byte(s)
/// @brief Reads unsigned integral value from given buffer
/// @param buf Buffer to read from
/// @return Unsigned integral value read from byte(s)
/// @note Converts from big endian to host order (when applicable)
/// @return Size value read from byte(s)
template <typename UInt>
UInt Read()
{
return Read<UInt>(ReadBytes(sizeof(UInt)));
}

template <typename UInt>
static UInt Read(const std::uint8_t* buf)
{
Expand All @@ -133,6 +127,14 @@ class InputByteStream : public ByteStream
std::memcpy(&size, buf, sizeof(size));
return boost::endian::big_to_native(size);
}

/// @brief Reads unsigned integral value from stream byte(s)
/// @return Unsigned integral value read from byte(s)
template <typename UInt>
UInt Read()
{
return Read<UInt>(ReadBytes(sizeof(UInt)));
}
};

/// @class OutputByteStream
Expand Down

0 comments on commit b988ea7

Please sign in to comment.