Moving some methods from threshold to utils

Two methods splitFileName and readFile seems to be more generic
and used not only by thresholds. Moving splitFileName and readFile
from the threshold namespace to utils.

Tested:
    Manual tests where done on CPUSensor. No differences detected
    comparing to results before these changes.

Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
Change-Id: I8ab58099eca740b6111a382f68f2ab32d7762a78
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 6b9ddf9..1add0e6 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -322,3 +322,45 @@
         std::array<std::string, 1>{
             "xyz.openbmc_project.Inventory.Item.System"});
 }
+
+std::optional<double> readFile(const std::string& thresholdFile,
+                               const double& scaleFactor)
+{
+    std::string line;
+    std::ifstream labelFile(thresholdFile);
+    if (labelFile.good())
+    {
+        std::getline(labelFile, line);
+        labelFile.close();
+
+        try
+        {
+            return std::stod(line) / scaleFactor;
+        }
+        catch (const std::invalid_argument&)
+        {
+            return std::nullopt;
+        }
+    }
+    return std::nullopt;
+}
+
+std::optional<std::tuple<std::string, std::string, std::string>>
+    splitFileName(const std::filesystem::path& filePath)
+{
+    if (filePath.has_filename())
+    {
+        const auto fileName = filePath.filename().string();
+        const std::regex rx(R"((\w+)(\d+)_(.*))");
+        std::smatch mr;
+
+        if (std::regex_search(fileName, mr, rx))
+        {
+            if (mr.size() == 4)
+            {
+                return std::make_optional(std::make_tuple(mr[1], mr[2], mr[3]));
+            }
+        }
+    }
+    return std::nullopt;
+}
\ No newline at end of file