sdbus++: interface: refactor enum-to-string conversion

Move the enum-to-string conversion functions as static members
inside the interface class, just like the string-to-enum conversion.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I4efe4f8c26fb4047de4e5a7487ea301d8b43be10
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp.in b/tools/sdbusplus/templates/interface.mako.server.cpp.in
index 060e32c..062cbf7 100644
--- a/tools/sdbusplus/templates/interface.mako.server.cpp.in
+++ b/tools/sdbusplus/templates/interface.mako.server.cpp.in
@@ -121,7 +121,7 @@
     }
 }
 
-std::string convertForMessage(${classname}::${e.name} v)
+std::string ${classname}::convert${e.name}ToString(${classname}::${e.name} v)
 {
     auto i = std::find_if(
             std::begin(mapping${classname}${e.name}),
diff --git a/tools/sdbusplus/templates/interface.mako.server.hpp b/tools/sdbusplus/templates/interface.mako.server.hpp
index 48c7038..32119f9 100644
--- a/tools/sdbusplus/templates/interface.mako.server.hpp
+++ b/tools/sdbusplus/templates/interface.mako.server.hpp
@@ -122,6 +122,13 @@
          *  @return - The enum value.
          */
         static ${e.name} convert${e.name}FromString(const std::string& s);
+
+        /** @brief Convert an enum value to a string.
+         *  @param[in] e - The enum to convert to a string.
+         *  @return - The string conversion in the form of
+         *            "${interface.name}.<value name>"
+         */
+        static std::string convert${e.name}ToString(${e.name} e);
     % endfor
 
         /** @brief Emit interface added */
@@ -183,7 +190,10 @@
  * @param[in] e - Enum value to convert.
  * @return C-string representing the name for the enum value.
  */
-std::string convertForMessage(${classname}::${e.name} e);
+inline std::string convertForMessage(${classname}::${e.name} e)
+{
+    return ${classname}::convert${e.name}ToString(e);
+}
     % endfor
 
 } // namespace server