Add readString PMBus function

This function will return the data read as an
std::string.

Change-Id: Idd7afbd9b4c7e602fad3146d941f03366140948b
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/pmbus.cpp b/pmbus.cpp
index 6ec4965..f000c75 100644
--- a/pmbus.cpp
+++ b/pmbus.cpp
@@ -192,6 +192,38 @@
     return data;
 }
 
+std::string PMBus::readString(const std::string& name, Type type)
+{
+    std::string data;
+    std::ifstream file;
+    auto path = getPath(type);
+    path /= name;
+
+    file.exceptions(std::ifstream::failbit |
+                    std::ifstream::badbit |
+                    std::ifstream::eofbit);
+
+    try
+    {
+        file.open(path);
+        file >> data;
+    }
+    catch (std::exception& e)
+    {
+        auto rc = errno;
+        log<level::ERR>("Failed to read sysfs file",
+                        entry("FILENAME=%s", path.c_str()));
+
+        using metadata = xyz::openbmc_project::Common::Device::ReadFailure;
+
+        elog<ReadFailure>(metadata::CALLOUT_ERRNO(rc),
+                          metadata::CALLOUT_DEVICE_PATH(
+                                  fs::canonical(basePath).c_str()));
+    }
+
+    return data;
+}
+
 void PMBus::write(const std::string& name, int value, Type type)
 {
     std::ofstream file;