Move methods to utility

Couple of methods has been moved from worker class to utility file.
More suited in utility as it process VPD and provides generic
information like hw version and IM value of the system.

Change-Id: I1aa51078c2ac9710b569faa3cf8e979abd3e6b73
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index 860d983..9a05294 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -122,77 +122,6 @@
     return true;
 }
 
-std::string Worker::getIMValue(const types::IPZVpdMap& parsedVpd) const
-{
-    if (parsedVpd.empty())
-    {
-        throw std::runtime_error("Empty VPD map. Can't Extract IM value");
-    }
-
-    const auto& itrToVSBP = parsedVpd.find("VSBP");
-    if (itrToVSBP == parsedVpd.end())
-    {
-        throw DataException("VSBP record missing.");
-    }
-
-    const auto& itrToIM = (itrToVSBP->second).find("IM");
-    if (itrToIM == (itrToVSBP->second).end())
-    {
-        throw DataException("IM keyword missing.");
-    }
-
-    types::BinaryVector imVal;
-    std::copy(itrToIM->second.begin(), itrToIM->second.end(),
-              back_inserter(imVal));
-
-    std::ostringstream imData;
-    for (auto& aByte : imVal)
-    {
-        imData << std::setw(2) << std::setfill('0') << std::hex
-               << static_cast<int>(aByte);
-    }
-
-    return imData.str();
-}
-
-std::string Worker::getHWVersion(const types::IPZVpdMap& parsedVpd) const
-{
-    if (parsedVpd.empty())
-    {
-        throw std::runtime_error("Empty VPD map. Can't Extract HW value");
-    }
-
-    const auto& itrToVINI = parsedVpd.find("VINI");
-    if (itrToVINI == parsedVpd.end())
-    {
-        throw DataException("VINI record missing.");
-    }
-
-    const auto& itrToHW = (itrToVINI->second).find("HW");
-    if (itrToHW == (itrToVINI->second).end())
-    {
-        throw DataException("HW keyword missing.");
-    }
-
-    types::BinaryVector hwVal;
-    std::copy(itrToHW->second.begin(), itrToHW->second.end(),
-              back_inserter(hwVal));
-
-    // The planar pass only comes from the LSB of the HW keyword,
-    // where as the MSB is used for other purposes such as signifying clock
-    // termination.
-    hwVal[0] = 0x00;
-
-    std::ostringstream hwString;
-    for (auto& aByte : hwVal)
-    {
-        hwString << std::setw(2) << std::setfill('0') << std::hex
-                 << static_cast<int>(aByte);
-    }
-
-    return hwString.str();
-}
-
 void Worker::fillVPDMap(const std::string& vpdFilePath,
                         types::VPDMapVariant& vpdMap)
 {
@@ -216,15 +145,28 @@
 {
     if (auto pVal = std::get_if<types::IPZVpdMap>(&parsedVpdMap))
     {
-        std::string hwKWdValue = getHWVersion(*pVal);
+        uint16_t l_errCode = 0;
+        std::string hwKWdValue =
+            vpdSpecificUtility::getHWVersion(*pVal, l_errCode);
         if (hwKWdValue.empty())
         {
+            if (l_errCode)
+            {
+                throw DataException("Failed to fetch HW value. Reason: " +
+                                    commonUtility::getErrCodeMsg(l_errCode));
+            }
             throw DataException("HW value fetched is empty.");
         }
 
-        const std::string& imKwdValue = getIMValue(*pVal);
+        const std::string& imKwdValue =
+            vpdSpecificUtility::getIMValue(*pVal, l_errCode);
         if (imKwdValue.empty())
         {
+            if (l_errCode)
+            {
+                throw DataException("Failed to fetch IM value. Reason: " +
+                                    commonUtility::getErrCodeMsg(l_errCode));
+            }
             throw DataException("IM value fetched is empty.");
         }