1
//=============================================================================
3
// Contents: Declarations for DwParameter
4
// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
5
// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
7
// Copyright (c) 1996, 1997 Douglas W. Sauder
8
// All rights reserved.
10
// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
11
// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
12
// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
13
// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
16
// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
18
// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
19
// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
21
//=============================================================================
27
#include <mimelib/config.h>
31
#include <mimelib/string.h>
35
#include <mimelib/msgcmp.h>
39
//=============================================================================
40
//+ Name DwParameter -- Class representing a MIME field body parameter
42
//. {\tt DwParameter} represents the {\it parameter} component of the
43
//. Content-Type header field as described in RFC-2045. A parameter
44
//. consists of an attribute/value pair. {\tt DwParameter} has member
45
//. functions for getting or setting a parameter's attribute and value.
47
//. A {\tt DwParameter} object may be included in a list of {\tt DwParameter}
48
//. objects. You can get the next {\tt DwParameter} object in the list by
49
//. calling the member function {\tt Next()}.
50
//=============================================================================
51
// Last modified 1997-08-13
52
//+ Noentry ~DwParameter _PrintDebugInfo
54
class DW_EXPORT DwParameter : public DwMessageComponent {
56
friend class DwMediaType;
61
DwParameter(const DwParameter& aParam);
62
DwParameter(const DwString& aStr, DwMessageComponent* aParent=0);
63
//. The first constructor is the default constructor, which sets the
64
//. {\tt DwParameter} object's string representation to the empty string
65
//. and sets its parent to NULL.
67
//. The second constructor is the copy constructor, which copies the
68
//. string representation, attribute, and value from {\tt aParam}.
69
//. The parent of the new {\tt DwParameter} object is set to NULL.
71
//. The third constructor copies {\tt aStr} to the {\tt DwParameter}
72
//. object's string representation and sets {\tt aParent} as its parent.
73
//. The virtual member function {\tt Parse()} should be called immediately
74
//. after this constructor in order to parse the string representation.
75
//. Unless it is NULL, {\tt aParent} should point to an object of a class
76
//. derived from {\tt DwMediaType}.
78
virtual ~DwParameter();
80
const DwParameter& operator = (const DwParameter& aParam);
81
//. This is the assignment operator.
84
//. This virtual function, inherited from {\tt DwMessageComponent},
85
//. executes the parse method for {\tt DwParameter} objects.
86
//. It should be called immediately after the string representation
87
//. is modified and before the parts of the broken-down
88
//. representation are accessed.
90
virtual void Assemble();
91
//. This virtual function, inherited from {\tt DwMessageComponent},
92
//. executes the assemble method for {\tt DwParameter} objects.
93
//. It should be called whenever one of the object's attributes
94
//. is changed in order to assemble the string representation from
95
//. its broken-down representation. It will be called
96
//. automatically for this object by the parent object's
97
//. {\tt Assemble()} member function if the is-modified flag is set.
99
virtual DwMessageComponent* Clone() const;
100
//. This virtual function, inherited from {\tt DwMessageComponent},
101
//. creates a new {\tt DwParameter} on the free store that has the same
102
//. value as this {\tt DwParameter} object. The basic idea is that of
103
//. a ``virtual copy constructor.''
105
const DwString& Attribute() const;
106
//. Returns the attribute contained by this parameter.
108
void SetAttribute(const DwString& aAttribute);
109
//. Sets the attribute contained by this parameter.
111
const DwString& Value() const;
112
//. Returns the value contained by this parameter.
114
void SetValue(const DwString& aValue, bool forceNoQuotes=false);
115
//. Sets the value contained by this parameter.
117
DwParameter* Next() const ;
118
//. Returns the next {\tt DwParameter} object in the list.
120
void SetNext(DwParameter* aParam);
121
//. Returns the next {\tt DwParameter} object in the list. Since
122
//. {\tt DwMediaType} has member functions for adding {\tt DwParameter}
123
//. objects to its list, you should avoid using this function.
125
static DwParameter* NewParameter(const DwString& aStr,
126
DwMessageComponent* aParent);
127
//. Creates a new {\tt DwParameter} object on the free store.
128
//. If the static data member {\tt sNewParameter} is NULL,
129
//. this member function will create a new {\tt DwParameter}
130
//. and return it. Otherwise, {\tt NewParameter()} will call
131
//. the user-supplied function pointed to by {\tt sNewParameter},
132
//. which is assumed to return an object from a class derived from
133
//. {\tt DwParameter}, and return that object.
135
//+ Var sNewParameter
136
static DwParameter* (*sNewParameter)(const DwString&, DwMessageComponent*);
137
//. If {\tt sNewParameter} is not NULL, it is assumed to point to a
138
//. user-supplied function that returns an object from a class derived from
139
//. {\tt DwParameter}.
147
static const char* const sClassName;
151
virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
152
//. This virtual function, inherited from {\tt DwMessageComponent},
153
//. prints debugging information about this object to {\tt aStrm}.
154
//. It will also call {\tt PrintDebugInfo()} for any of its child
155
//. components down to a level of {\tt aDepth}.
157
//. This member function is available only in the debug version of
160
virtual void CheckInvariants() const;
161
//. Aborts if one of the invariants of the object fails. Use this
162
//. member function to track down bugs.
164
//. This member function is available only in the debug version of
169
void _PrintDebugInfo(std::ostream& aStrm) const;