]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/msg_types: move ceph_entity_name::parse() into .cc
authorKefu Chai <kchai@redhat.com>
Thu, 1 Apr 2021 04:36:00 +0000 (12:36 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 1 Apr 2021 14:43:09 +0000 (22:43 +0800)
for faster compilation.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/msg/msg_types.cc
src/msg/msg_types.h

index 50a75cc86d0594d4edd34aa294b2373242d8822b..94e307f7a0d687d44d5090213583e5b650029664 100644 (file)
 
 #include "common/Formatter.h"
 
+bool entity_name_t::parse(std::string_view s)
+{
+  const char *start = s.data();
+  char *end = nullptr;
+  bool got = parse(start, &end);
+  return got && end == start + s.size();
+}
+
+bool entity_name_t::parse(const char *start, char **end)
+{
+  if (strstr(start, "mon.") == start) {
+    _type = TYPE_MON;
+    start += 4;
+  } else if (strstr(start, "osd.") == start) {
+    _type = TYPE_OSD;
+    start += 4;
+  } else if (strstr(start, "mds.") == start) {
+    _type = TYPE_MDS;
+    start += 4;
+  } else if (strstr(start, "client.") == start) {
+    _type = TYPE_CLIENT;
+    start += 7;
+  } else if (strstr(start, "mgr.") == start) {
+    _type = TYPE_MGR;
+    start += 4;
+  } else {
+    return false;
+  }
+  if (isspace(*start))
+    return false;
+  _num = strtoll(start, end, 10);
+  if (*end == NULL || *end == start)
+    return false;
+  return true;
+}
+
 void entity_name_t::dump(ceph::Formatter *f) const
 {
   f->dump_string("type", type_str());
index 7a542c23279f508db56d34a8e2a46ea662f8299c..84a87bdceac7050c8e17d22f4abce2ea7ef2881d 100644 (file)
@@ -81,38 +81,8 @@ public:
     return n;
   }
 
-  bool parse(std::string_view s) {
-    const char *start = s.data();
-    char *end = nullptr;
-    bool got = parse(start, &end);
-    return got && end == start + s.size();
-  }
-  bool parse(const char *start, char **end) {
-    if (strstr(start, "mon.") == start) {
-      _type = TYPE_MON;
-      start += 4;
-    } else if (strstr(start, "osd.") == start) {
-      _type = TYPE_OSD;
-      start += 4;
-    } else if (strstr(start, "mds.") == start) {
-      _type = TYPE_MDS;
-      start += 4;
-    } else if (strstr(start, "client.") == start) {
-      _type = TYPE_CLIENT;
-      start += 7;
-    } else if (strstr(start, "mgr.") == start) {
-      _type = TYPE_MGR;
-      start += 4;
-    } else {
-      return false;
-    }
-    if (isspace(*start))
-      return false;
-    _num = strtoll(start, end, 10);
-    if (*end == NULL || *end == start)
-      return false;
-    return true;
-  }
+  bool parse(std::string_view s);
+  bool parse(const char *start, char **end);
 
   DENC(entity_name_t, v, p) {
     denc(v._type, p);