O'Reilly logo

Beginning C++ Programming by Richard Grimes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required