1515#include " Poco/Net/NameValueCollection.h"
1616#include " Poco/Exception.h"
1717#include < algorithm>
18+ #include < functional>
1819
1920
2021using Poco::NotFoundException;
@@ -55,7 +56,7 @@ void NameValueCollection::swap(NameValueCollection& nvc)
5556 std::swap (_map, nvc._map );
5657}
5758
58-
59+
5960const std::string& NameValueCollection::operator [] (const std::string& name) const
6061{
6162 ConstIterator it = _map.find (name);
@@ -65,8 +66,8 @@ const std::string& NameValueCollection::operator [] (const std::string& name) co
6566 throw NotFoundException (name);
6667}
6768
68-
69- void NameValueCollection::set (const std::string& name, const std::string& value)
69+
70+ void NameValueCollection::set (const std::string& name, const std::string& value)
7071{
7172 Iterator it = _map.find (name);
7273 if (it != _map.end ())
@@ -75,13 +76,13 @@ void NameValueCollection::set(const std::string& name, const std::string& value)
7576 _map.insert (HeaderMap::ValueType (name, value));
7677}
7778
78-
79+
7980void NameValueCollection::add (const std::string& name, const std::string& value)
8081{
8182 _map.insert (HeaderMap::ValueType (name, value));
8283}
8384
84-
85+
8586const std::string& NameValueCollection::get (const std::string& name) const
8687{
8788 ConstIterator it = _map.find (name);
@@ -101,6 +102,15 @@ const std::string& NameValueCollection::get(const std::string& name, const std::
101102 return defaultValue;
102103}
103104
105+ const std::vector<std::reference_wrapper<const std::string>> NameValueCollection::getAll (const std::string& name) const
106+ {
107+ std::vector<std::reference_wrapper<const std::string>> values;
108+ for (ConstIterator it = _map.find (name); it != _map.end (); it++)
109+ if (it->first == name)
110+ values.push_back (it->second );
111+ return values;
112+ }
113+
104114
105115bool NameValueCollection::has (const std::string& name) const
106116{
@@ -113,19 +123,19 @@ NameValueCollection::ConstIterator NameValueCollection::find(const std::string&
113123 return _map.find (name);
114124}
115125
116-
126+
117127NameValueCollection::ConstIterator NameValueCollection::begin () const
118128{
119129 return _map.begin ();
120130}
121131
122-
132+
123133NameValueCollection::ConstIterator NameValueCollection::end () const
124134{
125135 return _map.end ();
126136}
127137
128-
138+
129139bool NameValueCollection::empty () const
130140{
131141 return _map.empty ();
0 commit comments