Created
November 4, 2017 18:21
-
-
Save athoik/144ea81a342c554d0fbdae110ce9a66a to your computer and use it in GitHub Desktop.
Branding Test for E2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <iostream> | |
#include <map> | |
class Branding | |
{ | |
std::map<std::string,std::string> m_branding; | |
public: | |
Branding(); | |
const std::string getValue(const std::string &key); | |
const std::string Version() { return getValue("version"); } | |
const std::string Creator() { return getValue("creator"); } | |
const std::string MachineName() { return getValue("machine_name"); } | |
}; | |
Branding::Branding() | |
{ | |
std::string key, value; | |
std::ifstream f("/etc/image-version"); | |
while (f.good()) | |
{ | |
std::getline(f, key, '\t'); | |
std::getline(f, value); | |
if (!key.size() || !value.size()) | |
break; | |
m_branding[key] = value; | |
std::cout << "key:" << key << " value:" << value << std::endl; | |
} | |
} | |
const std::string Branding::getValue(const std::string &key) | |
{ | |
std::map<std::string,std::string>::iterator it = m_branding.find(key); | |
if (it != m_branding.end()) | |
return it->second; | |
return "N/A"; | |
} | |
int main() | |
{ | |
Branding x; | |
std::cout << "Version: " << x.Version() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment