ostringstream - C++ Reference
The current error state of the stream. Individual values may be obtained by calling , , and . See member type .
string::substr - C++ Reference
string substr (size_t pos = 0, size_t len = npos) const; Returns a newly constructed object with its value initialized to a copy of a substring of this object. The substring is the portion of the object that starts at character positionpos and spans len characters (or until the end of the string, whichever comes first).
ios::good - C++ Reference
true if none of the stream's state flags are set. false if any of the stream's state flags are set ( badbit, eofbit or failbit).