2004-10-05 10:28:21 +00:00
|
|
|
//
|
2005-03-18 21:33:11 +00:00
|
|
|
// VMime library (http://www.vmime.org)
|
2005-01-03 12:26:48 +00:00
|
|
|
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
|
2004-10-05 10:28:21 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
2005-09-17 10:10:29 +00:00
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// Linking this library statically or dynamically with other modules is making
|
|
|
|
// a combined work based on this library. Thus, the terms and conditions of
|
|
|
|
// the GNU General Public License cover the whole combination.
|
2004-10-05 10:28:21 +00:00
|
|
|
//
|
|
|
|
|
2004-12-26 20:23:29 +00:00
|
|
|
#include "vmime/parameterizedHeaderField.hpp"
|
|
|
|
#include "vmime/text.hpp"
|
|
|
|
#include "vmime/parserHelpers.hpp"
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace vmime
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
parameterizedHeaderField::parameterizedHeaderField()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-03 11:16:26 +00:00
|
|
|
parameterizedHeaderField::~parameterizedHeaderField()
|
|
|
|
{
|
|
|
|
removeAllParameters();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-05 10:28:21 +00:00
|
|
|
/*
|
2004-10-21 15:05:47 +00:00
|
|
|
This class handles field contents of the following form:
|
|
|
|
Field: VALUE; PARAM1="VALUE1"; PARAM2="VALUE2"...
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
eg. RFC-1521
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
content := "Content-Type" ":" type "/" subtype *(";" parameter)
|
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
parameter := attribute "=" value
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
attribute := token ; case-insensitive
|
|
|
|
|
|
|
|
value := token / quoted-string
|
|
|
|
|
|
|
|
token := 1*<any (ASCII) CHAR except SPACE, CTLs, or tspecials>
|
|
|
|
|
|
|
|
tspecials := "(" / ")" / "<" / ">" / "@"
|
|
|
|
/ "," / ";" / ":" / "\" / <">
|
|
|
|
/ "/" / "[" / "]" / "?" / "="
|
|
|
|
; Must be in quoted-string,
|
|
|
|
; to use within parameter values
|
|
|
|
*/
|
|
|
|
|
2005-04-12 18:42:54 +00:00
|
|
|
|
|
|
|
#ifndef VMIME_BUILDING_DOC
|
|
|
|
|
|
|
|
struct paramInfo
|
|
|
|
{
|
|
|
|
bool extended;
|
|
|
|
std::vector <parameter::valueChunk> value;
|
|
|
|
string::size_type start;
|
|
|
|
string::size_type end;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VMIME_BUILDING_DOC
|
|
|
|
|
|
|
|
|
2004-10-05 10:28:21 +00:00
|
|
|
void parameterizedHeaderField::parse(const string& buffer, const string::size_type position,
|
|
|
|
const string::size_type end, string::size_type* newPosition)
|
|
|
|
{
|
|
|
|
const string::value_type* const pend = buffer.data() + end;
|
|
|
|
const string::value_type* const pstart = buffer.data() + position;
|
|
|
|
const string::value_type* p = pstart;
|
|
|
|
|
|
|
|
const string::size_type start = position;
|
|
|
|
|
|
|
|
while (p < pend && *p != ';') ++p;
|
|
|
|
|
2005-11-04 23:21:22 +00:00
|
|
|
getValue()->parse(buffer, start, position + (p - pstart));
|
2004-10-21 15:05:47 +00:00
|
|
|
|
|
|
|
removeAllParameters();
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
// If there is one or more parameters following...
|
|
|
|
if (p < pend)
|
|
|
|
{
|
2005-04-12 18:42:54 +00:00
|
|
|
std::map <string, paramInfo> params;
|
|
|
|
|
2004-10-05 10:28:21 +00:00
|
|
|
while (*p == ';')
|
|
|
|
{
|
|
|
|
// Skip ';'
|
|
|
|
++p;
|
|
|
|
|
2005-03-16 17:13:08 +00:00
|
|
|
while (p < pend && parserHelpers::isSpace(*p)) ++p;
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
const string::size_type attrStart = position + (p - pstart);
|
|
|
|
|
|
|
|
while (p < pend && !(*p == ';' || *p == '='))
|
|
|
|
++p;
|
|
|
|
|
|
|
|
if (p >= pend || *p == ';')
|
|
|
|
{
|
|
|
|
// Hmmmm... we didn't found an '=' sign.
|
|
|
|
// This parameter may not be valid so try to advance
|
|
|
|
// to the next one, if there is one.
|
|
|
|
while (p < pend && *p != ';')
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Extract the attribute name
|
|
|
|
string::size_type attrEnd = position + (p - pstart);
|
|
|
|
|
2005-03-16 17:13:08 +00:00
|
|
|
while (attrEnd != attrStart && parserHelpers::isSpace(buffer[attrEnd - 1]))
|
2004-10-05 10:28:21 +00:00
|
|
|
--attrEnd;
|
|
|
|
|
|
|
|
// Skip '='
|
|
|
|
++p;
|
|
|
|
|
|
|
|
// Skip white-spaces between '=' and the value
|
2005-03-16 17:13:08 +00:00
|
|
|
while (p < pend && parserHelpers::isSpace(*p)) ++p;
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
// Extract the value
|
|
|
|
string value;
|
|
|
|
|
|
|
|
// -- this is a quoted-string
|
|
|
|
if (*p == '"')
|
|
|
|
{
|
|
|
|
// Skip '"'
|
|
|
|
++p;
|
|
|
|
|
|
|
|
// Extract quoted-string
|
|
|
|
bool escape = false;
|
|
|
|
bool stop = false;
|
|
|
|
|
|
|
|
std::ostringstream ss;
|
|
|
|
string::size_type start = position + (p - pstart);
|
|
|
|
|
|
|
|
for ( ; p < pend && !stop ; ++p)
|
|
|
|
{
|
|
|
|
if (escape)
|
|
|
|
{
|
|
|
|
escape = false;
|
|
|
|
start = position + (p - pstart);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '"':
|
|
|
|
{
|
|
|
|
ss << string(buffer.begin() + start,
|
|
|
|
buffer.begin() + position + (p - pstart));
|
|
|
|
|
|
|
|
stop = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case '\\':
|
|
|
|
{
|
|
|
|
ss << string(buffer.begin() + start,
|
|
|
|
buffer.begin() + position + (p - pstart));
|
|
|
|
|
|
|
|
escape = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stop)
|
|
|
|
{
|
|
|
|
ss << string(buffer.begin() + start,
|
|
|
|
buffer.begin() + position + (p - pstart));
|
|
|
|
}
|
|
|
|
|
|
|
|
value = ss.str();
|
|
|
|
}
|
|
|
|
// -- the value is a simple token
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const string::size_type valStart = position + (p - pstart);
|
|
|
|
|
|
|
|
while (p < pend && *p != ';')
|
|
|
|
++p;
|
|
|
|
|
|
|
|
string::size_type valEnd = position + (p - pstart);
|
|
|
|
|
2005-03-16 17:13:08 +00:00
|
|
|
while (valEnd != valStart && parserHelpers::isSpace(buffer[valEnd - 1]))
|
2004-10-05 10:28:21 +00:00
|
|
|
--valEnd;
|
|
|
|
|
|
|
|
value = string(buffer.begin() + valStart,
|
|
|
|
buffer.begin() + valEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't allow ill-formed parameters
|
|
|
|
if (attrStart != attrEnd && value.length())
|
|
|
|
{
|
2005-04-12 18:42:54 +00:00
|
|
|
string name(buffer.begin() + attrStart, buffer.begin() + attrEnd);
|
|
|
|
|
|
|
|
// Check for RFC-2231 extended parameters
|
|
|
|
bool extended = false;
|
|
|
|
bool encoded = false;
|
|
|
|
|
|
|
|
if (name[name.length() - 1] == '*')
|
|
|
|
{
|
|
|
|
name.erase(name.end() - 1, name.end());
|
|
|
|
|
|
|
|
extended = true;
|
|
|
|
encoded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for RFC-2231 multi-section parameters
|
|
|
|
const string::size_type star = name.find_last_of('*');
|
|
|
|
|
|
|
|
if (star != string::npos)
|
|
|
|
{
|
|
|
|
bool allDigits = true;
|
|
|
|
|
|
|
|
for (string::size_type i = star + 1 ; allDigits && (i < name.length()) ; ++i)
|
|
|
|
allDigits = parserHelpers::isDigit(name[i]);
|
|
|
|
|
|
|
|
if (allDigits)
|
|
|
|
{
|
|
|
|
name.erase(name.begin() + star, name.end());
|
|
|
|
extended = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: we ignore section number, and we suppose that
|
|
|
|
// the sequence is correct (ie. the sections appear
|
|
|
|
// in order: param*0, param*1...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add/replace/modify the parameter
|
|
|
|
const std::map <string, paramInfo>::iterator it = params.find(name);
|
|
|
|
|
|
|
|
if (it != params.end())
|
|
|
|
{
|
|
|
|
paramInfo& info = (*it).second;
|
|
|
|
|
|
|
|
// An extended parameter replaces a normal one
|
|
|
|
if (!info.extended)
|
|
|
|
{
|
|
|
|
info.extended = extended;
|
|
|
|
info.value.clear();
|
|
|
|
info.start = attrStart;
|
|
|
|
}
|
2005-03-12 20:58:48 +00:00
|
|
|
|
2005-04-12 18:42:54 +00:00
|
|
|
// Append a new section for a multi-section parameter
|
|
|
|
parameter::valueChunk chunk;
|
|
|
|
chunk.encoded = encoded;
|
|
|
|
chunk.data = value;
|
2005-03-12 20:58:48 +00:00
|
|
|
|
2005-04-12 18:42:54 +00:00
|
|
|
info.value.push_back(chunk);
|
|
|
|
info.end = position + (p - pstart);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parameter::valueChunk chunk;
|
|
|
|
chunk.encoded = encoded;
|
|
|
|
chunk.data = value;
|
|
|
|
|
|
|
|
paramInfo info;
|
|
|
|
info.extended = extended;
|
|
|
|
info.value.push_back(chunk);
|
|
|
|
info.start = attrStart;
|
|
|
|
info.end = position + (p - pstart);
|
|
|
|
|
|
|
|
// Insert a new parameter
|
|
|
|
params.insert(std::map <string, paramInfo>::value_type(name, info));
|
|
|
|
}
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip white-spaces after this parameter
|
2005-03-16 17:13:08 +00:00
|
|
|
while (p < pend && parserHelpers::isSpace(*p)) ++p;
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-12 18:42:54 +00:00
|
|
|
|
|
|
|
for (std::map <string, paramInfo>::const_iterator it = params.begin() ;
|
|
|
|
it != params.end() ; ++it)
|
|
|
|
{
|
|
|
|
const paramInfo& info = (*it).second;
|
|
|
|
|
|
|
|
// Append this parameter to the list
|
2005-11-04 23:21:22 +00:00
|
|
|
ref <parameter> param = vmime::create <parameter>((*it).first);
|
2005-04-12 18:42:54 +00:00
|
|
|
|
|
|
|
param->parse(info.value);
|
|
|
|
param->setParsedBounds(info.start, info.end);
|
|
|
|
|
|
|
|
appendParameter(param);
|
|
|
|
}
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (newPosition)
|
|
|
|
*newPosition = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void parameterizedHeaderField::generate(utility::outputStream& os, const string::size_type maxLineLength,
|
|
|
|
const string::size_type curLinePos, string::size_type* newLinePos) const
|
|
|
|
{
|
|
|
|
string::size_type pos = curLinePos;
|
|
|
|
|
|
|
|
// Parent header field
|
|
|
|
headerField::generate(os, maxLineLength, pos, &pos);
|
|
|
|
|
|
|
|
// Parameters
|
2005-07-12 22:28:02 +00:00
|
|
|
for (std::vector <ref <parameter> >::const_iterator
|
2004-10-21 15:05:47 +00:00
|
|
|
it = m_params.begin() ; it != m_params.end() ; ++it)
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
|
|
|
os << "; ";
|
|
|
|
pos += 2;
|
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
(*it)->generate(os, maxLineLength, pos, &pos);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (newLinePos)
|
|
|
|
*newLinePos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
void parameterizedHeaderField::copyFrom(const component& other)
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2004-10-21 15:05:47 +00:00
|
|
|
headerField::copyFrom(other);
|
|
|
|
|
|
|
|
const parameterizedHeaderField& source = dynamic_cast<const parameterizedHeaderField&>(other);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
removeAllParameters();
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
for (std::vector <ref <parameter> >::const_iterator i = source.m_params.begin() ;
|
2004-10-21 15:05:47 +00:00
|
|
|
i != source.m_params.end() ; ++i)
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
appendParameter((*i)->clone().dynamicCast <parameter>());
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
2004-10-21 15:05:47 +00:00
|
|
|
}
|
|
|
|
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
parameterizedHeaderField& parameterizedHeaderField::operator=(const parameterizedHeaderField& other)
|
|
|
|
{
|
|
|
|
copyFrom(other);
|
|
|
|
return (*this);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
const bool parameterizedHeaderField::hasParameter(const string& paramName) const
|
|
|
|
{
|
2005-01-02 17:17:12 +00:00
|
|
|
const string name = utility::stringUtils::toLower(paramName);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
|
|
|
|
const std::vector <ref <parameter> >::const_iterator end = m_params.end();
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2005-01-02 17:17:12 +00:00
|
|
|
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
return (pos != end);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
ref <parameter> parameterizedHeaderField::findParameter(const string& paramName) const
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2005-01-02 17:17:12 +00:00
|
|
|
const string name = utility::stringUtils::toLower(paramName);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
// Find the first parameter that matches the specified name
|
2005-07-12 22:28:02 +00:00
|
|
|
std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
|
|
|
|
const std::vector <ref <parameter> >::const_iterator end = m_params.end();
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2005-01-02 17:17:12 +00:00
|
|
|
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
// No parameter with this name can be found
|
|
|
|
if (pos == end)
|
|
|
|
{
|
2004-10-21 15:05:47 +00:00
|
|
|
throw exceptions::no_such_parameter(paramName);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
// Else, return a reference to the existing parameter
|
|
|
|
else
|
|
|
|
{
|
2004-10-21 15:05:47 +00:00
|
|
|
return (*pos);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
ref <parameter> parameterizedHeaderField::getParameter(const string& paramName)
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2005-01-02 17:17:12 +00:00
|
|
|
const string name = utility::stringUtils::toLower(paramName);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
// Find the first parameter that matches the specified name
|
2005-07-12 22:28:02 +00:00
|
|
|
std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
|
|
|
|
const std::vector <ref <parameter> >::const_iterator end = m_params.end();
|
2004-10-05 10:28:21 +00:00
|
|
|
|
2005-01-02 17:17:12 +00:00
|
|
|
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
// If no parameter with this name can be found, create a new one
|
|
|
|
if (pos == end)
|
|
|
|
{
|
2005-11-04 23:21:22 +00:00
|
|
|
ref <parameter> param = vmime::create <parameter>(paramName);
|
2004-10-21 15:05:47 +00:00
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
appendParameter(param);
|
2004-10-05 10:28:21 +00:00
|
|
|
|
|
|
|
// Return a reference to the new parameter
|
2004-10-21 15:05:47 +00:00
|
|
|
return (param);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
// Else, return a reference to the existing parameter
|
|
|
|
else
|
|
|
|
{
|
2004-10-21 15:05:47 +00:00
|
|
|
return (*pos);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
void parameterizedHeaderField::appendParameter(ref <parameter> param)
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
|
|
|
m_params.push_back(param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
void parameterizedHeaderField::insertParameterBefore(ref <parameter> beforeParam, ref <parameter> param)
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
const std::vector <ref <parameter> >::iterator it = std::find
|
2004-10-21 15:05:47 +00:00
|
|
|
(m_params.begin(), m_params.end(), beforeParam);
|
|
|
|
|
|
|
|
if (it == m_params.end())
|
|
|
|
throw exceptions::no_such_parameter(beforeParam->getName());
|
|
|
|
|
|
|
|
m_params.insert(it, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
void parameterizedHeaderField::insertParameterBefore(const int pos, ref <parameter> param)
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
|
|
|
m_params.insert(m_params.begin() + pos, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
void parameterizedHeaderField::insertParameterAfter(ref <parameter> afterParam, ref <parameter> param)
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
const std::vector <ref <parameter> >::iterator it = std::find
|
2004-10-21 15:05:47 +00:00
|
|
|
(m_params.begin(), m_params.end(), afterParam);
|
|
|
|
|
|
|
|
if (it == m_params.end())
|
|
|
|
throw exceptions::no_such_parameter(afterParam->getName());
|
|
|
|
|
|
|
|
m_params.insert(it + 1, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
void parameterizedHeaderField::insertParameterAfter(const int pos, ref <parameter> param)
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2004-10-21 15:05:47 +00:00
|
|
|
m_params.insert(m_params.begin() + pos + 1, param);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
void parameterizedHeaderField::removeParameter(ref <parameter> param)
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
const std::vector <ref <parameter> >::iterator it = std::find
|
2004-10-21 15:05:47 +00:00
|
|
|
(m_params.begin(), m_params.end(), param);
|
|
|
|
|
|
|
|
if (it == m_params.end())
|
|
|
|
throw exceptions::no_such_parameter(param->getName());
|
|
|
|
|
|
|
|
m_params.erase(it);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
void parameterizedHeaderField::removeParameter(const int pos)
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
const std::vector <ref <parameter> >::iterator it = m_params.begin() + pos;
|
2004-10-21 15:05:47 +00:00
|
|
|
|
|
|
|
m_params.erase(it);
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
void parameterizedHeaderField::removeAllParameters()
|
2004-10-05 10:28:21 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
m_params.clear();
|
2004-10-05 10:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 15:05:47 +00:00
|
|
|
const int parameterizedHeaderField::getParameterCount() const
|
|
|
|
{
|
|
|
|
return (m_params.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bool parameterizedHeaderField::isEmpty() const
|
|
|
|
{
|
|
|
|
return (m_params.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
const ref <parameter> parameterizedHeaderField::getParameterAt(const int pos)
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
|
|
|
return (m_params[pos]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
const ref <parameter> parameterizedHeaderField::getParameterAt(const int pos) const
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
|
|
|
return (m_params[pos]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
const std::vector <ref <const parameter> > parameterizedHeaderField::getParameterList() const
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
std::vector <ref <const parameter> > list;
|
2004-10-21 15:05:47 +00:00
|
|
|
|
|
|
|
list.reserve(m_params.size());
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
for (std::vector <ref <parameter> >::const_iterator it = m_params.begin() ;
|
2004-10-21 15:05:47 +00:00
|
|
|
it != m_params.end() ; ++it)
|
|
|
|
{
|
|
|
|
list.push_back(*it);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
const std::vector <ref <parameter> > parameterizedHeaderField::getParameterList()
|
2004-10-21 15:05:47 +00:00
|
|
|
{
|
|
|
|
return (m_params);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
const std::vector <ref <const component> > parameterizedHeaderField::getChildComponents() const
|
2005-03-12 20:58:48 +00:00
|
|
|
{
|
2005-07-12 22:28:02 +00:00
|
|
|
std::vector <ref <const component> > list = headerField::getChildComponents();
|
2005-03-12 20:58:48 +00:00
|
|
|
|
2005-07-12 22:28:02 +00:00
|
|
|
for (std::vector <ref <parameter> >::const_iterator it = m_params.begin() ;
|
2005-03-12 20:58:48 +00:00
|
|
|
it != m_params.end() ; ++it)
|
|
|
|
{
|
|
|
|
list.push_back(*it);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-10-05 10:28:21 +00:00
|
|
|
} // vmime
|