summaryrefslogtreecommitdiffstats
path: root/src/mgr/DaemonKey.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/mgr/DaemonKey.cc
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mgr/DaemonKey.cc')
-rw-r--r--src/mgr/DaemonKey.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mgr/DaemonKey.cc b/src/mgr/DaemonKey.cc
new file mode 100644
index 000000000..5501ac106
--- /dev/null
+++ b/src/mgr/DaemonKey.cc
@@ -0,0 +1,35 @@
+#include "DaemonKey.h"
+
+std::pair<DaemonKey, bool> DaemonKey::parse(const std::string& s)
+{
+ auto p = s.find('.');
+ if (p == s.npos) {
+ return {{}, false};
+ } else {
+ return {DaemonKey{s.substr(0, p), s.substr(p + 1)}, true};
+ }
+}
+
+bool operator<(const DaemonKey& lhs, const DaemonKey& rhs)
+{
+ if (int cmp = lhs.type.compare(rhs.type); cmp < 0) {
+ return true;
+ } else if (cmp > 0) {
+ return false;
+ } else {
+ return lhs.name < rhs.name;
+ }
+}
+
+std::ostream& operator<<(std::ostream& os, const DaemonKey& key)
+{
+ return os << key.type << '.' << key.name;
+}
+
+namespace ceph {
+std::string to_string(const DaemonKey& key)
+{
+ return key.type + '.' + key.name;
+}
+}
+