Processing header subitems

The next action is to process the header bodies into subitems. To do this, add the following highlighted declaration to the public section of the header_body class:

    public:         header_body() = default;         header_body(const string& b) : body(b) {}         string get_body() const { return body; }         vector<pair<string, string>> subitems();     };

Each subitem will be a name/value pair, and since the order of a subitem may be important, the subitems are stored in a vector. Change the main function, remove the call to get_headers, and instead print out each header individually:

    email eml;     eml.parse(stm);     for (auto header : eml) {           cout << header.first << " : ";           vector<pair<string, string>> subItems = header.second.subitems(); ...

Get Beginning C++ Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.