Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added eol option to to_bin_string()

  • Loading branch information...
commit 0c583143a754d362e1e59635b6752a667d9af7b5 1 parent 1dcb9ac
@saleyn authored
Showing with 7 additions and 2 deletions.
  1. +3 −1 include/utxx/string.hpp
  2. +4 −1 src/string.cpp
View
4 include/utxx/string.hpp
@@ -207,8 +207,10 @@ namespace utxx {
/// @param readable if true prints buffer as a readable string if it
/// contains all printable bytes. If false - binary
/// list is printed
+ /// @param eol if true - terminate string with end-of-line
std::string to_bin_string(const char* buf, size_t sz,
- bool hex = false, bool readable = true);
+ bool hex = false, bool readable = true,
+ bool eol = false);
#if __cplusplus >= 201103L
namespace {
View
5 src/string.cpp
@@ -34,7 +34,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace utxx {
-std::string to_bin_string(const char* buf, size_t sz, bool hex, bool readable) {
+std::string to_bin_string(const char* buf, size_t sz,
+ bool hex, bool readable, bool eol)
+{
std::stringstream out;
const char* begin = buf, *end = buf + sz;
bool printable = readable;
@@ -55,6 +57,7 @@ std::string to_bin_string(const char* buf, size_t sz, bool hex, bool readable) {
}
}
out << (printable ? "\"" : "") << ">>";
+ if (eol) out << std::endl;
return out.str();
}
Please sign in to comment.
Something went wrong with that request. Please try again.