phrase.hh

Go to the documentation of this file.
00001 //Copyright 2013 Ben Loer
00002 //This file is part of the ConfigHandler library
00003 //It is released under the terms of the GNU General Public License v3
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1