#ifndef __JLANG__JTOKEN__ #define __JLANG__JTOKEN__ #include /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Wrapper class around string. * * The redirect operator istream::operator>>() will read until given template character * instead of the standard white space. */ template class JToken : public std::string { public: /** * Separator. */ const static char SEPARATOR = sep; /** * Default constructor. */ JToken() : std::string() {} /** * Read token from input stream. * * \param in input stream * \param token token * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JToken& token) { token.clear(); return getline(in, token, SEPARATOR); } /** * Write token to output stream. * * \param out output stream * \param token token * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JToken& token) { return out << static_cast(token) << SEPARATOR; } }; } #endif