summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--version.cpp21
-rwxr-xr-xversion.hpp21
2 files changed, 24 insertions, 18 deletions
diff --git a/version.cpp b/version.cpp
index 9c86756..4260a89 100644
--- a/version.cpp
+++ b/version.cpp
@@ -15,10 +15,11 @@ namespace manager
using namespace phosphor::logging;
-std::string Version::getVersion(const std::string& manifestFilePath)
+std::string Version::getValue(const std::string& manifestFilePath,
+ std::string key)
{
- constexpr auto versionKey = "version=";
- constexpr auto versionKeySize = strlen(versionKey);
+ key = key + "=";
+ auto keySize = key.length();
if (manifestFilePath.empty())
{
@@ -26,7 +27,7 @@ std::string Version::getVersion(const std::string& manifestFilePath)
throw std::runtime_error("MANIFESTFilePath is empty");
}
- std::string version{};
+ std::string value{};
std::ifstream efile;
std::string line;
efile.exceptions(std::ifstream::failbit
@@ -39,9 +40,9 @@ std::string Version::getVersion(const std::string& manifestFilePath)
efile.open(manifestFilePath);
while (getline(efile, line))
{
- if (line.compare(0, versionKeySize, versionKey) == 0)
+ if (line.compare(0, keySize, key) == 0)
{
- version = line.substr(versionKeySize);
+ value = line.substr(keySize);
break;
}
}
@@ -49,10 +50,10 @@ std::string Version::getVersion(const std::string& manifestFilePath)
}
catch (const std::exception& e)
{
- log<level::ERR>("Error in reading Host MANIFEST file");
+ log<level::ERR>("Error in reading MANIFEST file");
}
- return version;
+ return value;
}
std::string Version::getId(const std::string& version)
@@ -61,8 +62,8 @@ std::string Version::getId(const std::string& version)
if (version.empty())
{
- log<level::ERR>("Error Host version is empty");
- throw std::runtime_error("Host version is empty");
+ log<level::ERR>("Error version is empty");
+ throw std::runtime_error("Version is empty");
}
// Only want 8 hex digits.
diff --git a/version.hpp b/version.hpp
index 6c45e0a..cd52fa0 100755
--- a/version.hpp
+++ b/version.hpp
@@ -23,16 +23,19 @@ class Version : public VersionInherit
public:
/** @brief Constructs Version Software Manager
*
- * @param[in] bus - The Dbus bus object
- * @param[in] objPath - The Dbus object path
- * @param[in] versionId - The Host version identifier
+ * @param[in] bus - The Dbus bus object
+ * @param[in] objPath - The Dbus object path
+ * @param[in] versionId - The version identifier
+ * @param[in] versionPurpose - The version purpose
*/
Version(sdbusplus::bus::bus& bus,
const std::string& objPath,
- const std::string& versionId) : VersionInherit(
+ const std::string& versionId,
+ VersionPurpose versionPurpose) : VersionInherit(
bus, (objPath).c_str(), true)
{
// Set properties.
+ purpose(versionPurpose);
version(versionId);
// Emit deferred signal.
@@ -40,18 +43,20 @@ class Version : public VersionInherit
}
/**
- * @brief Get the code version identifier.
+ * @brief Read the manifest file to get the value of the key.
*
- * @return The version identifier.
+ * @return The value of the key.
**/
- static std::string getVersion(const std::string& manifestFilePath);
+ static std::string getValue(const std::string& manifestFilePath,
+ std::string key);
/**
- * @brief Get the Host Version id.
+ * @brief Get the Version id.
*
* @return The id.
**/
static std::string getId(const std::string& version);
+
};
} // namespace manager
OpenPOWER on IntegriCloud