2
// NameValueCollection.cpp
4
// $Id: //poco/1.2/Net/src/NameValueCollection.cpp#1 $
8
// Module: NameValueCollection
10
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
13
// Permission is hereby granted, free of charge, to any person or organization
14
// obtaining a copy of the software and accompanying documentation covered by
15
// this license (the "Software") to use, reproduce, display, distribute,
16
// execute, and transmit the Software, and to prepare derivative works of the
17
// Software, and to permit third-parties to whom the Software is furnished to
18
// do so, all subject to the following:
20
// The copyright notices in the Software and this entire statement, including
21
// the above license grant, this restriction and the following disclaimer,
22
// must be included in all copies of the Software, in whole or in part, and
23
// all derivative works of the Software, unless such copies or derivative
24
// works are solely in the form of machine-executable object code generated by
25
// a source language processor.
27
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
30
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
31
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
32
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33
// DEALINGS IN THE SOFTWARE.
37
#include "Poco/Net/NameValueCollection.h"
38
#include "Poco/Exception.h"
42
using Poco::NotFoundException;
49
NameValueCollection::NameValueCollection()
54
NameValueCollection::NameValueCollection(const NameValueCollection& nvc):
60
NameValueCollection::~NameValueCollection()
65
NameValueCollection& NameValueCollection::operator = (const NameValueCollection& nvc)
75
void NameValueCollection::swap(NameValueCollection& nvc)
77
std::swap(_map, nvc._map);
81
const std::string& NameValueCollection::operator [] (const std::string& name) const
83
ConstIterator it = _map.find(name);
87
throw NotFoundException(name);
91
void NameValueCollection::set(const std::string& name, const std::string& value)
93
Iterator it = _map.find(name);
96
_map.insert(HeaderMap::value_type(name, value));
100
void NameValueCollection::add(const std::string& name, const std::string& value)
102
_map.insert(HeaderMap::value_type(name, value));
106
const std::string& NameValueCollection::get(const std::string& name) const
108
ConstIterator it = _map.find(name);
109
if (it != _map.end())
112
throw NotFoundException(name);
116
const std::string& NameValueCollection::get(const std::string& name, const std::string& defaultValue) const
118
ConstIterator it = _map.find(name);
119
if (it != _map.end())
126
bool NameValueCollection::has(const std::string& name) const
128
return _map.find(name) != _map.end();
132
NameValueCollection::ConstIterator NameValueCollection::find(const std::string& name) const
134
return _map.find(name);
138
NameValueCollection::ConstIterator NameValueCollection::begin() const
144
NameValueCollection::ConstIterator NameValueCollection::end() const
150
bool NameValueCollection::empty() const
156
int NameValueCollection::size() const
158
return (int) _map.size();
162
void NameValueCollection::erase(const std::string& name)
168
void NameValueCollection::clear()
174
} } // namespace Poco::Net