aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ble/misc.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/ble/misc.cpp b/ble/misc.cpp
index afd89cb..b26b99e 100644
--- a/ble/misc.cpp
+++ b/ble/misc.cpp
@@ -1,10 +1,7 @@
#include "ble/misc.h"
-#include <ios>
-#include <ostream>
-#include <iomanip>
#include <ble/misc.h>
-
+#include <string>
namespace trygvis {
namespace bluetooth {
@@ -15,21 +12,13 @@ std::ostream &operator<<(std::ostream &s, Uuid const &uuid) {
}
std::string Uuid::str() const {
- auto v = value;
-
- std::stringstream s;
- s << std::hex << std::setw(2) <<
- int(v[0]) << int(v[1]) << ":" <<
- int(v[2]) << int(v[3]) << ":" <<
- int(v[4]) << int(v[5]) << ":" <<
- int(v[6]) << int(v[7]) << ":" <<
- int(v[8]) << int(v[9]) << ":" <<
- int(v[10]) << int(v[11]) << ":" <<
- int(v[12]) << int(v[13]) << ":" <<
- int(v[14]) << int(v[15]) << ":" <<
- std::resetiosflags(std::ios_base::basefield);
-
- return s.str();
+ char str[37];
+
+ std::sprintf(str, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7],
+ value[8], value[9], value[10], value[11], value[12], value[13], value[14], value[15]);
+
+ return {str};
}
Uuid makeUuid(const Uuid &base, uint8_t a, uint8_t b) {