aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/header.cpp45
-rw-r--r--src/header.hpp9
2 files changed, 48 insertions, 6 deletions
diff --git a/src/header.cpp b/src/header.cpp
index f7745360..eb972de0 100644
--- a/src/header.cpp
+++ b/src/header.cpp
@@ -286,8 +286,6 @@ const bool header::fieldsContainer::has(const string& fieldName) const
}
-// Find the first field that matches the specified type/name.
-// If no field is found, an exception is thrown.
headerField& header::fieldsContainer::find(const headerField::Types fieldType) const
{
// Find the first field that matches the specified type
@@ -335,7 +333,48 @@ headerField& header::fieldsContainer::find(const string& fieldName) const
}
-// Find the first field that matches the specified type/name
+std::vector <headerField*> header::fieldsContainer::findAllByType(const headerField::Types fieldType)
+{
+ std::vector <headerField*> result;
+
+ std::vector <headerField*>::const_iterator pos = m_fields.begin();
+ const std::vector <headerField*>::const_iterator end = m_fields.end();
+
+ for ( ; pos != end ; ++pos)
+ {
+ // Add the header if it matches the specified type
+ if ((*pos)->type() == fieldType)
+ {
+ result.push_back(*pos);
+ }
+ }
+
+ return result;
+}
+
+
+std::vector <headerField*> header::fieldsContainer::findAllByName(const string& fieldName)
+{
+ const string name = toLower(fieldName);
+
+ std::vector <headerField*> result;
+
+ std::vector <headerField*>::const_iterator pos = m_fields.begin();
+ const std::vector <headerField*>::const_iterator end = m_fields.end();
+
+ for ( ; pos != end ; ++pos)
+ {
+ // Add the header if it matches the specified type
+ if (toLower((*pos)->name()) == name)
+ {
+ result.push_back(*pos);
+ }
+ }
+
+ return result;
+}
+
+
headerField& header::fieldsContainer::get(const headerField::Types fieldType)
{
// Find the first field that matches the specified type
diff --git a/src/header.hpp b/src/header.hpp
index 8ce070b9..b675e6fc 100644
--- a/src/header.hpp
+++ b/src/header.hpp
@@ -56,13 +56,11 @@ class header : public component
friend class body;
friend class message;
-protected:
+public:
header();
~header();
-public:
-
// A sub-class for field manipulation
class fieldsContainer
{
@@ -125,6 +123,11 @@ public:
headerField& find(const headerField::Types fieldType) const;
headerField& find(const string& fieldName) const;
+ // Find all fields that matche the specified type/name.
+ // If no field is found, an empty vector is returned.
+ std::vector <headerField*> findAllByType(const headerField::Types fieldType);
+ std::vector <headerField*> findAllByName(const string& fieldName);
+
// Find the first field that matches the specified type/name.
// If no field is found, one will be created.
headerField& get(const headerField::Types fieldType);