Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JToken.hh
Go to the documentation of this file.
1#ifndef __JLANG__JTOKEN__
2#define __JLANG__JTOKEN__
3
4#include <string>
5#include <ostream>
6
7
8/**
9 * \author mdejong
10 */
11
12namespace JLANG {}
13namespace JPP { using namespace JLANG; }
14
15namespace JLANG {
16
17 /**
18 * Wrapper class around string.
19 *
20 * The redirect operator <tt>istream::operator>>()</tt> will read until given template character
21 * instead of the standard white space.
22 */
23 template<char sep>
24 class JToken :
25 public std::string
26 {
27 public:
28 /**
29 * Separator.
30 */
31 const static char SEPARATOR = sep;
32
33
34 /**
35 * Default constructor.
36 */
38 std::string()
39 {}
40
41
42 /**
43 * Read token from input stream.
44 *
45 * \param in input stream
46 * \param token token
47 * \return input stream
48 */
49 friend inline std::istream& operator>>(std::istream& in, JToken& token)
50 {
51 token.clear();
52
53 return getline(in, token, SEPARATOR);
54 }
55
56
57 /**
58 * Write token to output stream.
59 *
60 * \param out output stream
61 * \param token token
62 * \return output stream
63 */
64 friend inline std::ostream& operator<<(std::ostream& out, const JToken& token)
65 {
66 return out << static_cast<const std::string&>(token) << SEPARATOR;
67 }
68 };
69}
70
71#endif
Wrapper class around string.
Definition JToken.hh:26
static const char SEPARATOR
Separator.
Definition JToken.hh:31
friend std::ostream & operator<<(std::ostream &out, const JToken &token)
Write token to output stream.
Definition JToken.hh:64
JToken()
Default constructor.
Definition JToken.hh:37
friend std::istream & operator>>(std::istream &in, JToken &token)
Read token from input stream.
Definition JToken.hh:49
Auxiliary classes and methods for language specific functionality.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).