Encode object path with sdbusplus

Currently the object path of service-config-manager are encoded by
simply replacing characters, which only support a limited number of
characters (only - and @). This patch uses sdbusplus to encode the
object paths to support more charaters and make it more general for
other applications to use.

Tested:
Object paths of service-config-manager are now in the sdbusplus format
like below:
  /xyz/openbmc_project/control/service/_70hosphor_2dipmi_2dnet_40eth0
  /xyz/openbmc_project/control/service/bmcweb

Change-Id: Ia2738d555a8ba921f6ac2eb4753ba319f489dc4f
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/src/main.cpp b/src/main.cpp
index 36f8cbb..01cedbf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -131,8 +131,7 @@
             }
 
             std::string instantiatedUnitName =
-                unitName + addInstanceName(instanceName, "_40");
-            boost::replace_all(instantiatedUnitName, "-", "_2d");
+                unitName + addInstanceName(instanceName, "@");
             const sdbusplus::message::object_path& objectPath =
                 std::get<static_cast<int>(ListUnitElements::objectPath)>(unit);
             // Group the service & socket units togther.. Same services
@@ -228,7 +227,7 @@
 
 #ifdef USB_CODE_UPDATE
     unitsToMonitor.emplace(
-        "phosphor_2dusb_2dcode_2dupdate",
+        "phosphor-usb-code-update",
         std::make_tuple(
             phosphor::service::usbCodeUpdateUnitName, "",
             "/org/freedesktop/systemd1/unit/usb_2dcode_2dupdate_2eservice",
@@ -238,14 +237,9 @@
     // create objects for needed services
     for (auto& it : unitsToMonitor)
     {
-        std::string objPath(std::string(phosphor::service::srcCfgMgrBasePath) +
-                            "/" + it.first);
-        std::string instanciatedUnitName =
-            std::get<static_cast<int>(monitorElement::unitName)>(it.second) +
-            addInstanceName(
-                std::get<static_cast<int>(monitorElement::instanceName)>(
-                    it.second),
-                "@");
+        sdbusplus::message::object_path basePath(
+            phosphor::service::srcCfgMgrBasePath);
+        std::string objPath(basePath / it.first);
         auto srvCfgObj = std::make_unique<phosphor::service::ServiceConfig>(
             server, conn, objPath,
             std::get<static_cast<int>(monitorElement::unitName)>(it.second),