Class Poco::Net::NameValueCollection (original) (raw)

Library: Net
Package: Messages
Header: Poco/Net/NameValueCollection.h

Description

A collection of name-value pairs that are used in various internet protocols like HTTP and SMTP.

The name is case-insensitive.

There can be more than one name-value pair with the same name.

Inheritance

Known Derived Classes: HTMLForm, HTTPAuthenticationParams, HTTPMessage, HTTPRequest, HTTPResponse, HTTPServerRequest, HTTPServerRequestImpl, HTTPServerResponse, HTTPServerResponseImpl, MailMessage, MessageHeader

Member Summary

Member Functions: add, begin, clear, empty, end, erase, find, get, has, operator =, operator [], secureClear, secureErase, set, size, swap

Types Aliases

ConstIterator

using ConstIterator = HeaderMap::ConstIterator;

HeaderMap

using HeaderMap = Poco::ListMap < std::string, std::string >;

Iterator

using Iterator = HeaderMap::Iterator;

Constructors

NameValueCollection

NameValueCollection();

NameValueCollection

NameValueCollection(
const NameValueCollection & nvc
);

NameValueCollection

NameValueCollection(
NameValueCollection && nvc
) noexcept;

Destructor

~NameValueCollection virtual

virtual ~NameValueCollection();

Member Functions

add

void add(
const std::string & name,
const std::string & value
);

Adds a new name-value pair with the given name and value.

begin inline

ConstIterator begin() const;

Returns an iterator pointing to the begin of the name-value pair collection.

begin

Iterator begin();

Returns an iterator pointing to the begin of the name-value pair collection.

clear

void clear();

Removes all name-value pairs and their values.

empty inline

bool empty() const;

Returns true iff the header does not have any content.

end inline

ConstIterator end() const;

Returns an iterator pointing to the end of the name-value pair collection.

end

Iterator end();

Returns an iterator pointing to the end of the name-value pair collection.

erase

void erase(
const std::string & name
);

Removes all name-value pairs with the given name.

erase

void erase(
Iterator it
);

Removes the name-value pair referenced by the given iterator.

find inline

ConstIterator find(
const std::string & name
) const;

Returns an iterator pointing to the first name-value pair with the given name.

find

Iterator find(
const std::string & name
);

Returns an iterator pointing to the first name-value pair with the given name.

get

const std::string & get(
const std::string & name
) const;

Returns the value of the first name-value pair with the given name.

Throws a NotFoundException if the name-value pair does not exist.

get

const std::string & get(
const std::string & name,
const std::string & defaultValue
) const;

Returns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned.

has

bool has(
const std::string & name
) const;

Returns true if there is at least one name-value pair with the given name.

operator =

NameValueCollection & operator = (
const NameValueCollection & nvc
);

operator =

NameValueCollection & operator = (
NameValueCollection && nvc
) noexcept;

operator []

const std::string & operator[] (
const std::string & name
) const;

Returns the value of the (first) name-value pair with the given name.

Throws a NotFoundException if the name-value pair does not exist.

secureClear

void secureClear();

Removes all name-value pairs and their values. Additionally, all values are also overwritten with zeroes.

secureErase

void secureErase(
const std::string & name
);

Securely erases all name-value pairs with the given name, by first overwriting the value with zeroes before removing the value.

secureErase

void secureErase(
Iterator it
);

Securely erases the name-value pair referenced by the given iterator, by first overwriting the value with zeroes before removing the value.

set

void set(
const std::string & name,
const std::string & value
);

Sets the value of the (first) name-value pair with the given name.

size inline

std::size_t size() const;

Returns the number of name-value pairs in the collection.

swap

void swap(
NameValueCollection & nvc
) noexcept;