Source-highlight Library
/home/bettini/work/source-highlight/src-highlite/lib/srchilite/stringdef.h
00001 //
00002 // C++ Interface: StringDef
00003 //
00004 // Description: a string definition that is used by all the language elements.
00005 //
00006 //
00007 // Author: Lorenzo Bettini, 1999-2007 <http://www.lorenzobettini.it>
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 #ifndef STRINGDEF_H
00013 #define STRINGDEF_H
00014 
00015 #include <string>
00016 #include <list>
00017 
00018 namespace srchilite {
00019 
00020 class StringDefs;
00021 
00025 class StringDef {
00026 private:
00028     std::string stringdef;
00030     std::string orig;
00032     bool doubleQuotedString;
00034     bool hasBackRef_;
00035 
00036 public:
00042     StringDef(const std::string &s, const std::string &o) :
00043         stringdef(s), orig(o), doubleQuotedString(false), hasBackRef_(false) {
00044     }
00045 
00052     StringDef(const std::string &s, bool doubleQuotes = false) :
00053         stringdef(s), doubleQuotedString(doubleQuotes), hasBackRef_(false) {
00054     }
00055 
00060     const std::string toString() const;
00061 
00067     const std::string toStringOriginal() const {
00068         return orig;
00069     }
00070 
00075     bool isDoubleQuoted() const {
00076         return doubleQuotedString;
00077     }
00078 
00082     bool hasBackRef() const {
00083         return hasBackRef_;
00084     }
00085 
00089     void setBackRef(bool b) {
00090         hasBackRef_ = b;
00091     }
00092 
00100     static StringDef *concat(const StringDef *s1, const StringDef *s2);
00101 
00102 };
00103 
00104 typedef std::list<StringDef *> StringDefsBase;
00105 
00110 class StringDefs : public StringDefsBase {
00111 public:
00112     ~StringDefs() {
00113         for (StringDefsBase::iterator it = begin(); it != end(); ++it)
00114             delete *it;
00115     }
00116 };
00117 
00118 }
00119 
00120 #endif