}
Note::Pointer
-Notes::add(const String ¬eKey)
+Notes::findByName(const String ¬eKey) const
{
- typedef Notes::NotesList::iterator AMLI;
+ typedef Notes::NotesList::const_iterator AMLI;
for (AMLI i = notes.begin(); i != notes.end(); ++i) {
if ((*i)->key == noteKey)
return (*i);
}
- Note::Pointer note = new Note(noteKey);
- notes.push_back(note);
+ return Note::Pointer();
+}
+
+void
+Notes::add(const String ¬eKey, const String ¬eValue)
+{
+ Note::Pointer key = add(noteKey);
+ key->addValue(noteValue);
+}
+
+Note::Pointer
+Notes::add(const String ¬eKey)
+{
+ Note::Pointer note = findByName(noteKey);
+ if (note == NULL) {
+ note = new Note(noteKey);
+ notes.push_back(note);
+ }
return note;
}
public:
typedef Vector<Note::Pointer> NotesList;
typedef NotesList::iterator iterator; ///< iterates over the notes list
+ typedef NotesList::const_iterator const_iterator; ///< iterates over the notes list
Notes(const char *aDescr, const char **metasBlacklist): descr(aDescr), blacklisted(metasBlacklist) {}
Notes(): descr(NULL), blacklisted(NULL) {}
* returns a pointer to the existing object.
*/
Note::Pointer add(const String ¬eKey);
+
+public:
+ /**
+ * Adds a note key and value to the notes list.
+ * If the key name already exists in list, add the given value to its set of values.
+ */
+ void add(const String ¬eKey, const String ¬eValue);
+
+ /**
+ * Looks up a note by key name and returns a Note::Pointer to it
+ */
+ Note::Pointer findByName(const String ¬eKey) const;
};
class NotePairs : public HttpHeader