00001 // MessageAttributes.h 00002 00003 #ifndef __ARC_MESSAGE_ATTRIBUTES__ 00004 #define __ARC_MESSAGE_ATTRIBUTES__ 00005 00006 #include <map> 00007 #include <string> 00008 00009 namespace Arc { 00010 00012 00017 typedef std::multimap<std::string,std::string> AttrMap; 00018 00019 00021 00026 typedef AttrMap::const_iterator AttrConstIter; 00027 00028 00030 00034 typedef AttrMap::iterator AttrIter; 00035 00036 00038 00052 class AttributeIterator { 00053 public: 00054 00056 00059 AttributeIterator(); 00060 00062 00067 const std::string& operator*() const; 00068 00070 00072 const std::string* operator->() const; 00073 00075 00078 const std::string& key(void) const; 00079 00081 00084 const AttributeIterator& operator++(); 00085 00087 00091 AttributeIterator operator++(int); 00092 00094 00098 bool hasMore() const; 00099 00100 protected: 00101 00103 00114 AttributeIterator(AttrConstIter begin, AttrConstIter end); 00115 00117 00121 AttrConstIter current_; 00122 00124 00128 AttrConstIter end_; 00129 00131 00137 friend class MessageAttributes; 00138 00139 }; 00140 00141 00143 00168 class MessageAttributes { 00169 public: 00170 00172 00176 MessageAttributes(); 00177 00179 00184 void set(const std::string& key, const std::string& value); 00185 00187 00193 void add(const std::string& key, const std::string& value); 00194 00196 00199 void removeAll(const std::string& key); 00200 00202 00208 void remove(const std::string& key, const std::string& value); 00209 00211 00216 int count(const std::string& key) const; 00217 00219 00227 const std::string& get(const std::string& key) const; 00228 00230 00237 AttributeIterator getAll(const std::string& key) const; 00238 00240 AttributeIterator getAll(void) const; 00241 00242 protected: 00243 00245 00248 AttrMap attributes_; 00249 00250 }; 00251 00252 } 00253 00254 #endif