phrase.hh
Go to the documentation of this file.00001
00002
00003
00004
00011 #ifndef PHRASE_h
00012 #define PHRASE_h
00013
00018 #include <string>
00019 #include <iostream>
00020
00021 class phrase : public std::string{
00022 public:
00023 phrase() : std::string() {}
00024 phrase(const char* s) : std::string(s) {}
00025 phrase(const std::string& s) : std::string(s) {}
00026 phrase& operator=(const char* s){ std::string::operator=(s); return *this; }
00027 phrase& operator=(const std::string& s)
00028 { std::string::operator=(s); return *this; }
00029 };
00030
00032 inline std::istream& operator>>(std::istream& in, phrase& s){
00033 s.clear();
00034 char next=0;
00035 in >> next;
00036 if(next == '"'){
00037 while( in.get(next) && next != '"'){
00038 s.append(1,next);
00039 }
00040 }
00041 else{
00042 in.unget();
00043 in >> (std::string&)s;
00044 }
00045
00046 return in;
00047
00048 }
00049
00051 inline std::ostream& operator<<(std::ostream& o, const phrase& s){
00052 return o<<'"'<<(std::string&)(s)<<'"';
00053 }
00054
00055
00056 #endif