Refactored header field values and parameters.
This commit is contained in:
parent
cffdc6caf5
commit
c179a10068
@ -1,109 +0,0 @@
|
|||||||
//
|
|
||||||
// VMime library (http://www.vmime.org)
|
|
||||||
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef VMIME_GENERICFIELD_HPP_INCLUDED
|
|
||||||
#define VMIME_GENERICFIELD_HPP_INCLUDED
|
|
||||||
|
|
||||||
|
|
||||||
#include "vmime/headerField.hpp"
|
|
||||||
#include "vmime/headerFieldFactory.hpp"
|
|
||||||
|
|
||||||
#include "vmime/typeAdapter.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace vmime
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/** Generic implementation for headerField.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class VALUE_TYPE>
|
|
||||||
class genericField : virtual public headerField
|
|
||||||
{
|
|
||||||
friend class vmime::creator; // create ref
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
genericField() : m_value(vmime::create <VALUE_TYPE>()) { }
|
|
||||||
|
|
||||||
|
|
||||||
const ref <const component> getValueImp() const
|
|
||||||
{
|
|
||||||
return (m_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
ref <component> getValueImp()
|
|
||||||
{
|
|
||||||
return (m_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
genericField <VALUE_TYPE>& operator=(const genericField <VALUE_TYPE>& other)
|
|
||||||
{
|
|
||||||
copyFrom(other);
|
|
||||||
return (*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class TYPE>
|
|
||||||
void setValue(const TYPE& value)
|
|
||||||
{
|
|
||||||
*m_value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
VALUE_TYPE& getValue()
|
|
||||||
{
|
|
||||||
return *m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VALUE_TYPE& getValue() const
|
|
||||||
{
|
|
||||||
return *m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setValue(const component& value)
|
|
||||||
{
|
|
||||||
const VALUE_TYPE& v = dynamic_cast <const VALUE_TYPE&>(value);
|
|
||||||
*m_value = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
ref <VALUE_TYPE> m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** Generic implementation for headerField with a value of type 'string'.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class genericField <string> : public genericField <typeAdapter <string> >
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // vmime
|
|
||||||
|
|
||||||
|
|
||||||
#endif // VMIME_GENERICFIELD_HPP_INCLUDED
|
|
@ -1,109 +0,0 @@
|
|||||||
//
|
|
||||||
// VMime library (http://www.vmime.org)
|
|
||||||
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef VMIME_GENERICPARAMETER_HPP_INCLUDED
|
|
||||||
#define VMIME_GENERICPARAMETER_HPP_INCLUDED
|
|
||||||
|
|
||||||
|
|
||||||
#include "vmime/parameter.hpp"
|
|
||||||
#include "vmime/parameterFactory.hpp"
|
|
||||||
|
|
||||||
#include "vmime/typeAdapter.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace vmime
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/** Generic implementation for parameter.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class VALUE_TYPE>
|
|
||||||
class genericParameter : public parameter
|
|
||||||
{
|
|
||||||
friend class vmime::creator; // create ref
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
genericParameter() : m_value(vmime::create <VALUE_TYPE>()) { }
|
|
||||||
|
|
||||||
|
|
||||||
const ref <const component> getValueImp() const
|
|
||||||
{
|
|
||||||
return m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ref <component> getValueImp()
|
|
||||||
{
|
|
||||||
return m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
genericParameter <VALUE_TYPE>& operator=(const genericParameter <VALUE_TYPE>& other)
|
|
||||||
{
|
|
||||||
copyFrom(other);
|
|
||||||
return (*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
const VALUE_TYPE& getValue() const
|
|
||||||
{
|
|
||||||
return (*m_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
VALUE_TYPE& getValue()
|
|
||||||
{
|
|
||||||
return (*m_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class TYPE>
|
|
||||||
void setValue(const TYPE& value)
|
|
||||||
{
|
|
||||||
*m_value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setValue(const component& value)
|
|
||||||
{
|
|
||||||
const VALUE_TYPE& v = dynamic_cast <const VALUE_TYPE&>(value);
|
|
||||||
*m_value = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
ref <VALUE_TYPE> m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** Generic implementation for parameter of type 'string'.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class genericParameter <string> : public genericParameter <typeAdapter <string> >
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // vmime
|
|
||||||
|
|
||||||
|
|
||||||
#endif // VMIME_GENERICPARAMETER_HPP_INCLUDED
|
|
@ -1,114 +0,0 @@
|
|||||||
//
|
|
||||||
// VMime library (http://www.vmime.org)
|
|
||||||
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef VMIME_STANDARDFIELDS_HPP_INCLUDED
|
|
||||||
#define VMIME_STANDARDFIELDS_HPP_INCLUDED
|
|
||||||
|
|
||||||
|
|
||||||
#include "vmime/genericField.hpp"
|
|
||||||
#include "vmime/parameterizedHeaderField.hpp"
|
|
||||||
#include "vmime/headerFieldFactory.hpp"
|
|
||||||
|
|
||||||
// Inclusion for field value types
|
|
||||||
#include "vmime/addressList.hpp"
|
|
||||||
#include "vmime/encoding.hpp"
|
|
||||||
#include "vmime/dateTime.hpp"
|
|
||||||
#include "vmime/text.hpp"
|
|
||||||
#include "vmime/messageId.hpp"
|
|
||||||
#include "vmime/relay.hpp"
|
|
||||||
#include "vmime/mailboxList.hpp"
|
|
||||||
#include "vmime/disposition.hpp"
|
|
||||||
#include "vmime/path.hpp"
|
|
||||||
#include "vmime/messageIdSequence.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace vmime
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
#define DECLARE_STANDARD_FIELD(fieldClassName, valueTypeClassName) \
|
|
||||||
class fieldClassName : public genericField <valueTypeClassName> { \
|
|
||||||
friend class vmime::creator; \
|
|
||||||
protected: \
|
|
||||||
fieldClassName() { } \
|
|
||||||
fieldClassName(const fieldClassName&) \
|
|
||||||
: headerField(), \
|
|
||||||
genericField <valueTypeClassName>() { /* Not used */ } \
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef VMIME_NO_MULTIPLE_INHERITANCE
|
|
||||||
|
|
||||||
template <class TYPE>
|
|
||||||
class genericParameterizedHeaderField : public genericField <TYPE>
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DECLARE_STANDARD_FIELD_PARAM(fieldClassName, valueTypeClassName) \
|
|
||||||
class fieldClassName : public genericParameterizedHeaderField <valueTypeClassName> { \
|
|
||||||
friend class vmime::creator; \
|
|
||||||
protected: \
|
|
||||||
fieldClassName() { } \
|
|
||||||
fieldClassName(const fieldClassName&) \
|
|
||||||
: headerField(), \
|
|
||||||
genericParameterizedHeaderField <valueTypeClassName>() { /* Not used */ } \
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // VMIME_NO_MULTIPLE_INHERITANCE
|
|
||||||
|
|
||||||
#define DECLARE_STANDARD_FIELD_PARAM(fieldClassName, valueTypeClassName) \
|
|
||||||
class fieldClassName : public genericField <valueTypeClassName>, \
|
|
||||||
public parameterizedHeaderField { \
|
|
||||||
friend class vmime::creator; \
|
|
||||||
protected: \
|
|
||||||
fieldClassName() { } \
|
|
||||||
fieldClassName(const fieldClassName&) \
|
|
||||||
: headerField(), \
|
|
||||||
genericField <valueTypeClassName>(), \
|
|
||||||
parameterizedHeaderField() { /* Not used */ } \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // VMIME_NO_MULTIPLE_INHERITANCE
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DECLARE_STANDARD_FIELD(addressListField, addressList);
|
|
||||||
DECLARE_STANDARD_FIELD_PARAM(contentEncodingField, encoding);
|
|
||||||
DECLARE_STANDARD_FIELD(dateField, datetime);
|
|
||||||
DECLARE_STANDARD_FIELD(textField, text);
|
|
||||||
DECLARE_STANDARD_FIELD(messageIdField, messageId);
|
|
||||||
DECLARE_STANDARD_FIELD(defaultField, string);
|
|
||||||
DECLARE_STANDARD_FIELD(relayField, relay);
|
|
||||||
DECLARE_STANDARD_FIELD(mailboxListField, mailboxList);
|
|
||||||
DECLARE_STANDARD_FIELD(dispositionField, disposition);
|
|
||||||
DECLARE_STANDARD_FIELD(pathField, path);
|
|
||||||
DECLARE_STANDARD_FIELD(messageIdSequenceField, messageIdSequence);
|
|
||||||
|
|
||||||
|
|
||||||
#undef DECLARE_STANDARD_FIELD
|
|
||||||
#undef DECLARE_STANDARD_FIELD_PARAM
|
|
||||||
|
|
||||||
|
|
||||||
} // vmime
|
|
||||||
|
|
||||||
|
|
||||||
#endif // VMIME_STANDARDFIELDS_HPP_INCLUDED
|
|
@ -1,60 +0,0 @@
|
|||||||
//
|
|
||||||
// VMime library (http://www.vmime.org)
|
|
||||||
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef VMIME_STANDARDPARAMS_HPP_INCLUDED
|
|
||||||
#define VMIME_STANDARDPARAMS_HPP_INCLUDED
|
|
||||||
|
|
||||||
|
|
||||||
#include "vmime/genericParameter.hpp"
|
|
||||||
#include "vmime/defaultParameter.hpp"
|
|
||||||
|
|
||||||
// Inclusion for field value types
|
|
||||||
#include "vmime/dateTime.hpp"
|
|
||||||
#include "vmime/charset.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace vmime
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
#define DECLARE_STANDARD_PARAM(paramClassName, valueTypeClassName) \
|
|
||||||
class paramClassName : public genericParameter <valueTypeClassName> { \
|
|
||||||
friend class vmime::creator; \
|
|
||||||
protected: \
|
|
||||||
paramClassName() { } \
|
|
||||||
paramClassName(const paramClassName&) \
|
|
||||||
: genericParameter <valueTypeClassName>() { /* Not used */ } \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DECLARE_STANDARD_PARAM(dateParameter, datetime);
|
|
||||||
DECLARE_STANDARD_PARAM(charsetParameter, charset);
|
|
||||||
|
|
||||||
|
|
||||||
#undef DECLARE_STANDARD_PARAM
|
|
||||||
|
|
||||||
|
|
||||||
} // vmime
|
|
||||||
|
|
||||||
|
|
||||||
#endif // VMIME_STANDARDPARAMS_HPP_INCLUDED
|
|
Loading…
Reference in New Issue
Block a user