Interface & Factory implementation for VPD Parsers
This commit abstracts the implementation logic of different parser.
A parser factory is implemented to provide instance of required
parser based on the type of vpd file needed to be parsed.
The interface should be derived to implement any further parser logic
related to vpd.
Status: This does not add any new function, so basic testing of
VPD parsing, VPD tool and writes was performed.
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: I3ce1a2d6b7e8d8984fd7800132e78ab8a9a21e56
diff --git a/app.cpp b/app.cpp
index 948decd..dbdda96 100644
--- a/app.cpp
+++ b/app.cpp
@@ -1,6 +1,6 @@
#include "args.hpp"
#include "defines.hpp"
-#include "parser.hpp"
+#include "ipz_parser.hpp"
#include "write.hpp"
#include <exception>
@@ -8,6 +8,7 @@
#include <iostream>
#include <iterator>
#include <string>
+#include <variant>
#include <vector>
int main(int argc, char** argv)
@@ -17,6 +18,8 @@
try
{
using namespace openpower::vpd;
+ using namespace openpower::vpd::ipz::parser;
+
args::Args arguments = args::parse(argc, argv);
bool haveVpd = arguments.count("vpd");
@@ -45,7 +48,8 @@
std::istreambuf_iterator<char>());
// Parse VPD
- auto vpdStore = parse(std::move(vpd));
+ IpzVpdParser ipzParser(std::move(vpd));
+ auto vpdStore = std::move(std::get<Store>(ipzParser.parse()));
if (doDump)
{