Implement mode/owner and string conversions

Move Manager::convertToMode() to utils::strToMode();
Move Manager::convertToOwner() to utils::strToOwner();
Add utils::modeToStr() and utils::ownerToStr();
Adjust and add unit tests.

Change-Id: Ied35d0e732c477017e1b2db1a3464b0425b12387
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/utils.hpp b/utils.hpp
index 97b26e7..54b7d7d 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -1,6 +1,9 @@
 #pragma once
 
+#include "types.hpp"
+
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
 
 #include <fstream>
 
@@ -86,6 +89,48 @@
     return value.template get<T>();
 }
 
-}
-}
-}
+/** @brief Convert a string to enum Mode
+ *
+ * Convert the time mode string to enum.
+ * Valid strings are "NTP", "MANUAL"
+ * If it's not a valid time mode string, it means something
+ * goes wrong so raise exception.
+ *
+ * @param[in] mode - The string of time mode
+ *
+ * @return The Mode enum
+ */
+Mode strToMode(const std::string& mode);
+
+/** @brief Convert a string to enum Owner
+ *
+ * Convert the time owner string to enum.
+ * Valid strings are "BMC", "HOST", "SPLIT", "BOTH"
+ * If it's not a valid time owner string, it means something
+ * goes wrong so raise exception.
+ *
+ * @param[in] owner - The string of time owner
+ *
+ * @return The Owner enum
+ */
+Owner strToOwner(const std::string& owner);
+
+/** @brief Convert a mode enum to mode string
+ *
+ * @param[in] mode - The Mode enum
+ *
+ * @return The string of the mode
+ */
+const char* modeToStr(Mode mode);
+
+/** @brief Convert a owner enum to owner string
+ *
+ * @param[in] owner - The Owner enum
+ *
+ * @return The string of the owner
+ */
+const char* ownerToStr(Owner owner);
+
+} // namespace utils
+} // namespace time
+} // namespace phosphor