diff options
author | Laurent Richard <[email protected]> | 2004-10-06 11:04:00 +0000 |
---|---|---|
committer | Laurent Richard <[email protected]> | 2004-10-06 11:04:00 +0000 |
commit | f3d249c81b6395550fe81c31da9a63b9146810cf (patch) | |
tree | c4c0bc7734bd1e73de314a7f2f2a1953f889a6a9 /src/header.cpp | |
parent | Fixed possible bug in destructor, when parent folder is closed before destroy... (diff) | |
download | vmime-f3d249c81b6395550fe81c31da9a63b9146810cf.tar.gz vmime-f3d249c81b6395550fe81c31da9a63b9146810cf.zip |
Adding functions in 'header' object to retrieve a list of fields by name/type
Diffstat (limited to 'src/header.cpp')
-rw-r--r-- | src/header.cpp | 45 |
1 files changed, 42 insertions, 3 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 |