aboutsummaryrefslogtreecommitdiffstats
path: root/vmime
diff options
context:
space:
mode:
Diffstat (limited to 'vmime')
-rw-r--r--vmime/contentDispositionField.hpp5
-rw-r--r--vmime/defaultParameter.hpp70
-rw-r--r--vmime/parameter.hpp16
-rw-r--r--vmime/parameterFactory.hpp16
-rw-r--r--vmime/parameterizedHeaderField.hpp4
-rw-r--r--vmime/standardParams.hpp2
-rw-r--r--vmime/utility/stream.hpp13
7 files changed, 123 insertions, 3 deletions
diff --git a/vmime/contentDispositionField.hpp b/vmime/contentDispositionField.hpp
index dc62baa0..74382c49 100644
--- a/vmime/contentDispositionField.hpp
+++ b/vmime/contentDispositionField.hpp
@@ -26,6 +26,7 @@
#include "vmime/contentDisposition.hpp"
#include "vmime/dateTime.hpp"
+#include "vmime/word.hpp"
namespace vmime
@@ -52,8 +53,8 @@ public:
const datetime& getReadDate() const;
void setReadDate(const datetime& readDate);
- const string getFilename() const;
- void setFilename(const string& filename);
+ const word getFilename() const;
+ void setFilename(const word& filename);
const string getSize() const;
void setSize(const string& size);
diff --git a/vmime/defaultParameter.hpp b/vmime/defaultParameter.hpp
new file mode 100644
index 00000000..7c6f7af7
--- /dev/null
+++ b/vmime/defaultParameter.hpp
@@ -0,0 +1,70 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+
+#ifndef VMIME_DEFAULTPARAMETER_HPP_INCLUDED
+#define VMIME_DEFAULTPARAMETER_HPP_INCLUDED
+
+
+#include "vmime/parameter.hpp"
+#include "vmime/parameterFactory.hpp"
+
+#include "vmime/word.hpp"
+
+
+namespace vmime
+{
+
+
+/** Default parameter implementation (with support for RFC-2231).
+ */
+
+class defaultParameter : public parameter
+{
+ friend class parameterFactory::registerer <defaultParameter>;
+
+protected:
+
+ defaultParameter();
+
+public:
+
+ defaultParameter& operator=(const defaultParameter& other);
+
+ const word& getValue() const;
+ word& getValue();
+
+ void setValue(const word& value);
+ void setValue(const component& value);
+
+ void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+ void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
+
+private:
+
+ void parse(const std::vector <valueChunk>& chunks);
+
+
+ word m_value;
+};
+
+
+} // vmime
+
+
+#endif // VMIME_DEFAULTPARAMETER_HPP_INCLUDED
diff --git a/vmime/parameter.hpp b/vmime/parameter.hpp
index 605b7ba8..b62c87ab 100644
--- a/vmime/parameter.hpp
+++ b/vmime/parameter.hpp
@@ -36,6 +36,20 @@ class parameter : public component
public:
+#ifndef VMIME_BUILDING_DOC
+
+ /** A single section of a multi-section parameter,
+ * as defined in RFC-2231/3. This is used when
+ * calling parse() on the parameter.
+ */
+ struct valueChunk
+ {
+ bool encoded;
+ string data;
+ };
+
+#endif // VMIME_BUILDING_DOC
+
parameter* clone() const;
void copyFrom(const component& other);
parameter& operator=(const parameter& other);
@@ -79,6 +93,8 @@ private:
string m_name;
void generateValue(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const;
+
+ virtual void parse(const std::vector <valueChunk>& chunks);
};
diff --git a/vmime/parameterFactory.hpp b/vmime/parameterFactory.hpp
index 3c05f4f8..28d8cbdb 100644
--- a/vmime/parameterFactory.hpp
+++ b/vmime/parameterFactory.hpp
@@ -67,7 +67,23 @@ public:
(utility::stringUtils::toLower(name), &registerer<T>::creator));
}
+ /** Create a new parameter and parse its value. The returned parameter
+ * can then be added in a vmime::parameterizedHeaderField object.
+ *
+ * @param name parameter name (ASCII characters only)
+ * @param value value to be parsed
+ * @return created parameter
+ */
parameter* create(const string& name, const string& value = NULL_STRING);
+
+ /** Create a new parameter and set its value. The returned parameter
+ * can then be added in a vmime::parameterizedHeaderField object.
+ *
+ * @param name parameter name (ASCII characters only)
+ * @param value value to be set
+ * @return created parameter
+ */
+ parameter* create(const string& name, const component& value);
};
diff --git a/vmime/parameterizedHeaderField.hpp b/vmime/parameterizedHeaderField.hpp
index 3e971c1b..ec85b766 100644
--- a/vmime/parameterizedHeaderField.hpp
+++ b/vmime/parameterizedHeaderField.hpp
@@ -32,6 +32,10 @@ namespace vmime
{
+/** A header field that can also contain parameters (name=value pairs).
+ * Parameters can be created using vmime::parameterFactory.
+ */
+
class parameterizedHeaderField : virtual public headerField
{
friend class headerFieldFactory::registerer <parameterizedHeaderField>;
diff --git a/vmime/standardParams.hpp b/vmime/standardParams.hpp
index 62f5774c..6c48835f 100644
--- a/vmime/standardParams.hpp
+++ b/vmime/standardParams.hpp
@@ -22,6 +22,7 @@
#include "vmime/genericParameter.hpp"
+#include "vmime/defaultParameter.hpp"
// Inclusion for field value types
#include "vmime/dateTime.hpp"
@@ -42,7 +43,6 @@ namespace vmime
}
-DECLARE_STANDARD_PARAM(defaultParameter, string);
DECLARE_STANDARD_PARAM(dateParameter, datetime);
DECLARE_STANDARD_PARAM(charsetParameter, charset);
diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp
index 5875a1f1..fa7186d1 100644
--- a/vmime/utility/stream.hpp
+++ b/vmime/utility/stream.hpp
@@ -23,6 +23,7 @@
#include <istream>
#include <ostream>
+#include <sstream>
#include "vmime/types.hpp"
@@ -122,6 +123,18 @@ outputStream& operator<<(outputStream& os, const char (&str)[N])
}
+template <typename T>
+outputStream& operator<<(outputStream& os, const T& t)
+{
+ std::ostringstream oss;
+ oss << t;
+
+ os << oss.str();
+
+ return (os);
+}
+
+
/** Copy data from one stream into another stream using a buffered method.
*
* @param is input stream (source data)