From 349a9e51db5f54696b172808dd62da7853f297e2 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 21 Sep 2023 12:51:46 +0300 Subject: [PATCH] Implement wsrep::id::to_string() --- include/wsrep/id.hpp | 5 +++++ src/id.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/include/wsrep/id.hpp b/include/wsrep/id.hpp index fc1e82b..d1b175a 100644 --- a/include/wsrep/id.hpp +++ b/include/wsrep/id.hpp @@ -93,6 +93,11 @@ namespace wsrep { return undefined_; } + + /** + * Return id in string representation. + */ + std::string to_string() const; private: static const wsrep::id undefined_; native_type data_; diff --git a/src/id.cpp b/src/id.cpp index f197beb..2999dc3 100644 --- a/src/id.cpp +++ b/src/id.cpp @@ -50,6 +50,13 @@ wsrep::id::id(const std::string& str) } } +std::string wsrep::id::to_string() const +{ + std::ostringstream os; + os << *this; + return os.str(); +} + std::ostream& wsrep::operator<<(std::ostream& os, const wsrep::id& id) { const char* ptr(static_cast(id.data()));