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 Modern C++: Efficient and Scalable Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.