00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COLORMAP_H
00021 #define COLORMAP_H
00022
00023 #include <map>
00024 #include <string>
00025 #include <boost/shared_ptr.hpp>
00026 #include <sstream>
00027
00028 using std::map;
00029 using std::string;
00030 using std::ostringstream;
00031
00032 namespace srchilite {
00033
00038 class ColorMap: public map<string, string> {
00039 protected:
00041 string default_color;
00042
00043 public:
00048 void setDefault(const string &d) {
00049 default_color = d;
00050 }
00051
00057 const string getColor(const string &key) {
00058 const_iterator it = find(key);
00059 if (it == end())
00060 return default_color;
00061 else
00062 return it->second;
00063 }
00064
00068 const string toString() const {
00069 ostringstream s;
00070 for (const_iterator it = begin(); it != end(); ++it)
00071 s << "[" << it->first << "]=" << it->second << "\n";
00072 s << "default=" << default_color;
00073 return s.str();
00074 }
00075 };
00076
00078 typedef boost::shared_ptr<ColorMap> ColorMapPtr;
00079
00080 }
00081
00082 #endif // COLORMAP_H