diff options
| author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2016-11-22 02:10:08 -0600 |
|---|---|---|
| committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2016-12-08 03:52:23 -0600 |
| commit | e08fcad4f84d2183e00bd4dfaec58772ea7369ea (patch) | |
| tree | 71b4ceee38115fe36c8ed6ab8be3edde2cc68899 | |
| parent | 158c0464b6ffe993953c379b8f91e4d219a609ee (diff) | |
| download | openpower-vpd-parser-e08fcad4f84d2183e00bd4dfaec58772ea7369ea.tar.gz openpower-vpd-parser-e08fcad4f84d2183e00bd4dfaec58772ea7369ea.zip | |
parser: define implementation class
This change introduces a class that serves as the OpenPOWER VPD parser.
The class provides an API to construct itself with binary OpenPOWER VPD,
and an API to run the parser.
Change-Id: Ifcb360a8b67ac4d2a5116e2515cf689c552819b4
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
| -rw-r--r-- | impl.hpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/impl.hpp b/impl.hpp new file mode 100644 index 0000000..28fcbcc --- /dev/null +++ b/impl.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include "store.hpp" + +namespace openpower +{ +namespace vpd +{ +namespace parser +{ + +/** @class Impl + * @brief Implements parser for OpenPOWER VPD + * + * An Impl object must be constructed by passing in OpenPOWER VPD in + * binary format. To parse the VPD, call the run() method. The run() + * method returns an openpower::vpd::Store object, which contains + * parsed VPD, and provides access methods for the VPD. + * + * Following is the algorithm used to parse OpenPOWER VPD: + * 1) Validate that the first record is VHDR, the header record. + * 2) From the VHDR record, get the offset of the VTOC record, + * which is the table of contents record. + * 3) Process the VTOC record - note offsets of supported records. + * 4) For each supported record : + * 4.1) Jump to record via offset. Add record name to parser output. + * 4.2) Process record - for each contained and supported keyword: + * 4.2.1) Note keyword name and value, associate this information to + * to the record noted in step 4.1). + */ +class Impl +{ + public: + Impl() = delete; + Impl(const Impl&) = delete; + Impl& operator=(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(Impl&&) = delete; + ~Impl() = default; + + /** @brief Construct an Impl + * + * @param[in] vpdBuffer - Binary OpenPOWER VPD + */ + explicit Impl(Binary&& vpdBuffer) + : vpd(std::move(vpdBuffer)), + out{} + {} + + /** @brief Run the parser on binary OpenPOWER VPD + * + * @returns openpower::vpd::Store object + */ + Store run(); + + private: + /** @brief OpenPOWER VPD in binary format */ + Binary vpd; + + /** @brief parser output */ + Parsed out; +}; + +} // namespace parser +} // namespace vpd +} // namespace openpower |

