1 //=============================================================================
2 // File:       text.h
3 // Contents:   Declarations for DwText
4 // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
5 // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
6 // $Revision: 1.9 $
7 // $Date: 2002/04/22 09:45:44 $
8 //
9 // Copyright (c) 1996, 1997 Douglas W. Sauder
10 // All rights reserved.
11 //
12 // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
13 // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
14 // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
15 // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 //
17 // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
18 // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
20 // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
21 // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
22 //
23 //=============================================================================
24 
25 #ifndef DW_TEXT_H
26 #define DW_TEXT_H
27 
28 #ifndef DW_CONFIG_H
29 #include <mimelib/config.h>
30 #endif
31 
32 #ifndef DW_STRING_H
33 #include <mimelib/string.h>
34 #endif
35 
36 #ifndef DW_FIELDBDY_H
37 #include <mimelib/fieldbdy.h>
38 #endif
39 
40 //=============================================================================
41 //+ Name DwText -- Class representing text in a RFC-822 header field-body
42 //+ Description
43 //. {\tt DwText} represents an unstructured field body in a header field.
44 //. It roughly corresponds to the {\it text} element of the BNF grammar
45 //. defined in RFC-822.
46 //=============================================================================
47 // Last modified 1997-07-30
48 //+ Noentry ~DwText sClassName _PrintDebugInfo
49 
50 
51 class DW_EXPORT DwText : public DwFieldBody {
52 
53 public:
54 
55     DwText();
56     DwText(const DwText& aText);
57     DwText(const DwString& aStr, DwMessageComponent* aParent=0);
58     //. The first constructor is the default constructor, which sets the
59     //. {\tt DwText} object's string representation to the empty string
60     //. and sets its parent to NULL.
61     //.
62     //. The second constructor is the copy constructor, which copies the
63     //. string representation from {\tt aText}.
64     //. The parent of the new {\tt DwText} object is set to NULL.
65     //.
66     //. The third constructor copies {\tt aStr} to the {\tt DwText}
67     //. object's string representation and sets {\tt aParent} as its parent.
68     //. The virtual member function {\tt Parse()} should be called immediately
69     //. after this constructor in order to parse the string representation.
70     //. Unless it is NULL, {\tt aParent} should point to an object of a class
71     //. derived from {\tt DwField}.
72 
73     virtual ~DwText();
74 
75     const DwText& operator = (const DwText& aText);
76     //. This is the assignment operator.
77 
78     virtual void Parse();
79     //. This virtual member function is inherited from
80     //. {\tt DwMessageComponent}, where it is declared a pure virtual
81     //. function.  For a {\tt DwText} object, this member function does
82     //. nothing, since {\tt DwText} represents an unstructured field body
83     //. (like the Subject header field) that does not have a broken-down
84     //. form.
85     //.
86     //. Note, however, that this function should still be called consistently,
87     //. since a subclass of {\tt DwText} may implement a parse method.
88     //.
89     //. This function clears the is-modified flag.
90 
91     virtual void Assemble();
92     //. This virtual member function is inherited from
93     //. {\tt DwMessageComponent}, where it is declared a pure virtual
94     //. function.  For a {\tt DwText} object, this member function does
95     //. nothing, since {\tt DwText} represents an unstructured field body
96     //. (like the Subject header field) that does not have a broken-down
97     //. form.
98     //.
99     //. Note, however, that this function should still be called consistently,
100     //. since a subclass of {\tt DwText} may implement an assemble method.
101     //.
102     //. This function clears the is-modified flag.
103 
104     virtual DwMessageComponent* Clone() const;
105     //. This virtual function, inherited from {\tt DwMessageComponent},
106     //. creates a new {\tt DwText} on the free store that has the same
107     //. value as this {\tt DwText} object.  The basic idea is that of
108     //. a ``virtual copy constructor.''
109 
110     static DwText* NewText(const DwString& aStr, DwMessageComponent* aParent);
111     //. Creates a new {\tt DwText} object on the free store.
112     //. If the static data member {\tt sNewText} is NULL,
113     //. this member function will create a new {\tt DwText}
114     //. and return it.  Otherwise, {\tt NewText()} will call
115     //. the user-supplied function pointed to by {\tt sNewText},
116     //. which is assumed to return an object from a class derived from
117     //. {\tt DwText}, and return that object.
118 
119     //+ Var sNewText
120     static DwText* (*sNewText)(const DwString&, DwMessageComponent*);
121     //. If {\tt sNewText} is not NULL, it is assumed to point to a
122     //. user-supplied function that returns an object from a class derived from
123     //. {\tt DwText}.
124 
125 private:
126 
127     static const char* const sClassName;
128 
129 public:
130 
131     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
132     //. This virtual function, inherited from {\tt DwMessageComponent},
133     //. prints debugging information about this object to {\tt aStrm}.
134     //. It will also call {\tt PrintDebugInfo()} for any of its child
135     //. components down to a level of {\tt aDepth}.
136     //.
137     //. This member function is available only in the debug version of
138     //. the library.
139 
140     virtual void CheckInvariants() const;
141     //. Aborts if one of the invariants of the object fails.  Use this
142     //. member function to track down bugs.
143     //.
144     //. This member function is available only in the debug version of
145     //. the library.
146 
147 protected:
148 
149     void _PrintDebugInfo(std::ostream& aStrm) const;
150 
151 };
152 
153 #endif
154