Revamped code for VPD parser

The commit removes all the pre-existing code from the branch
and pushes the revamped code.

Major modification includes:
- Movement from multi exe to single daemon model.
- Multithreaded approach to parse FRU VPD.
- Better error handling.
- Refactored code for performance optimization.

Note: This code supports all the existing functionalities as it is.

Change-Id: I1ddce1f0725ac59020b72709689a1013643bda8b
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/include/keyword_vpd_parser.hpp b/vpd-manager/include/keyword_vpd_parser.hpp
new file mode 100644
index 0000000..ae30a34
--- /dev/null
+++ b/vpd-manager/include/keyword_vpd_parser.hpp
@@ -0,0 +1,97 @@
+#pragma once
+
+#include "parser_interface.hpp"
+#include "types.hpp"
+
+namespace vpd
+{
+
+/**
+ * @brief Concrete class to implement Keyword VPD parsing
+ *
+ * The class inherits ParserInterface class and overrides the parser
+ * functionality to implement parsing logic for Keyword VPD format.
+ */
+class KeywordVpdParser : public ParserInterface
+{
+  public:
+    KeywordVpdParser() = delete;
+    KeywordVpdParser(const KeywordVpdParser&) = delete;
+    KeywordVpdParser(KeywordVpdParser&&) = delete;
+    ~KeywordVpdParser() = default;
+
+    /**
+     * @brief Constructor
+     *
+     * @param kwVpdVector - move it to object's m_keywordVpdVector
+     */
+    KeywordVpdParser(const types::BinaryVector& kwVpdVector) :
+        m_keywordVpdVector(kwVpdVector),
+        m_vpdIterator(m_keywordVpdVector.begin())
+    {}
+
+    /**
+     * @brief A wrapper function to parse the keyword VPD binary data.
+     *
+     * It validates certain tags and checksum data, calls helper function
+     * to parse and emplace the data as keyword-value pairs in KeywordVpdMap.
+     *
+     * @throw DataException - VPD is not valid
+     * @return map of keyword:value
+     */
+    types::VPDMapVariant parse();
+
+  private:
+    /**
+     * @brief Parse the VPD data and emplace them as pair into the Map.
+     *
+     * @throw DataException - VPD data size is 0, check VPD
+     * @return map of keyword:value
+     */
+    types::KeywordVpdMap populateVpdMap();
+
+    /**
+     * @brief Validate checksum.
+     *
+     * Finding the 2's complement of sum of all the
+     * keywords,values and large resource identifier string.
+     *
+     * @param[in] i_checkSumStart - VPD iterator pointing at checksum start
+     * value
+     * @param[in] i_checkSumEnd - VPD iterator pointing at checksum end value
+     * @throw DataException - checksum invalid, check VPD
+     */
+    void validateChecksum(types::BinaryVector::const_iterator i_checkSumStart,
+                          types::BinaryVector::const_iterator i_checkSumEnd);
+
+    /**
+     * @brief It reads 2 bytes from current VPD pointer
+     *
+     * @return 2 bytes of VPD data
+     */
+    inline size_t getKwDataSize()
+    {
+        return (*(m_vpdIterator + 1) << 8 | *m_vpdIterator);
+    }
+
+    /**
+     * @brief Check for given number of bytes validity
+     *
+     * Check if number of elements from (begining of the vector) to (iterator +
+     * numberOfBytes) is lesser than or equal to the total no.of elements in
+     * the vector. This check is performed before advancement of the iterator.
+     *
+     * @param[in] numberOfBytes - no.of positions the iterator is going to be
+     * iterated
+     *
+     * @throw DataException - Truncated VPD data, check VPD.
+     */
+    void checkNextBytesValidity(uint8_t numberOfBytes);
+
+    /*Vector of keyword VPD data*/
+    const types::BinaryVector& m_keywordVpdVector;
+
+    /*Iterator to VPD data*/
+    types::BinaryVector::const_iterator m_vpdIterator;
+};
+} // namespace vpd