aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-09-06 18:48:36 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-09-06 18:48:36 +0200
commitee95df36af1645f5eab9b94b86d4e77e06f7d247 (patch)
treea6e659cac410fe0419b65cada58d333e52d6a772
parent91e54cf9150b37036447d423857d2bd18e4bf02b (diff)
downloadble-toys-ee95df36af1645f5eab9b94b86d4e77e06f7d247.tar.gz
ble-toys-ee95df36af1645f5eab9b94b86d4e77e06f7d247.tar.bz2
ble-toys-ee95df36af1645f5eab9b94b86d4e77e06f7d247.tar.xz
ble-toys-ee95df36af1645f5eab9b94b86d4e77e06f7d247.zip
o Actually formatting UUIDs as UUIDs.
-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) {