SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Base class for classes that represent message headers as defined in the Internet Message format specification (RFC 2822). More...
#include <rw/mime/RWMimeHeader.h>
Public Member Functions | |
RWMimeHeader (void) | |
RWMimeHeader (const RWCString &label) | |
RWMimeHeader (const RWMimeHeader &second) | |
virtual | ~RWMimeHeader (void) |
RWCString | asString (void) const |
void | fromString (const RWCString &headerString) |
RWCString | getLabel (void) const |
RWMimeHeader & | operator= (const RWMimeHeader &second) |
Public Member Functions inherited from RWHandleBase | |
bool | isValid (void) const |
bool | operator!= (const RWHandleBase &second) const |
bool | operator< (const RWHandleBase &second) const |
bool | operator== (const RWHandleBase &second) const |
Protected Member Functions | |
RWMimeHeaderImp & | body (void) const |
virtual bool | checkLabel (const RWCString &label) const |
Protected Member Functions inherited from RWHandleBase | |
RWHandleBase (void) | |
RWHandleBase (RWStaticCtor) | |
RWHandleBase (RWBodyBase *body) | |
RWHandleBase (const RWHandleBase &second) | |
~RWHandleBase (void) | |
RWBodyBase & | body (void) const |
RWHandleBase & | operator= (const RWHandleBase &second) |
Friends | |
bool | operator!= (const RWMimeHeader &first, const RWMimeHeader &second) |
bool | operator== (const RWMimeHeader &first, const RWMimeHeader &second) |
RWMimeHeader is a base class for classes that represent message headers as defined in the Internet Message format specification (RFC 2822). A header consists of a label and a value. MIME requires that both the label and value contain only printable characters in the US-ASCII character set. The name may not contain a colon. To create a header value in another character set, encode the value according to the guidelines in RFC 2047.
The label appears first in the header, and is separated from the value by a colon. So, the header line
contains the label From
, a colon as a separator, and the value
The Internet Message Format does not define the structure or meaning of a value. Therefore, RWMimeHeader does not define an interface for working with a header value. Just as each individual header in the specification defines the structure and semantics of its value, each derived class implements its own interface for working with the header value.
An instance of RWMimeHeader is a handle to a private, reference-counted body. Note that the body is always a specific header implementation.
Classes that contain MIME headers collect the headers as instances of RWMimeHeader. Each derived class contains a conversion constructor which creates a new derived-class handle to the implementation of the RWMimeHeader. Conversion happens automatically when an RWMimeHeader is assigned to a handle of the appropriate type. For example,
In the code above, the RWMimePart::getHeader() function returns an RWMimeHeader. Because RWMimeVersionHeader provides a conversion constructor from RWMimeHeader, the compiler automatically invokes that conversion constructor. The result is a completely typesafe assignment; no downcast is required. The conversion is also efficient, since the conversion constructor simply creates a new handle to the existing implementation.
RWMimeHeader::RWMimeHeader | ( | void | ) |
Default constructor. Constructs a header with an empty label and an empty value.
RWMimeHeader::RWMimeHeader | ( | const RWCString & | label | ) |
Constructs a header with the given label and an empty value. Does not verify that the string provided meets the requirements for an Internet Message Format header. The RWCString should contain 7-bit US-ASCII data.
RWMimeHeader::RWMimeHeader | ( | const RWMimeHeader & | second | ) |
Copy constructor. Constructs a new handle to the body second refers to.
|
virtual |
Destructor.
RWCString RWMimeHeader::asString | ( | void | ) | const |
Returns this header as a string. Throws RWMimeError if self cannot be represented as a valid header. The RWCString should contain 7-bit US-ASCII data.
|
protected |
Returns a reference to the underlying implementation.
|
protectedvirtual |
Returns true
. Since RWMimeHeader does not represent any specific header, this class imposes no special requirements on a label. In RWMimeHeader this function returns true
without examining label. Derived classes that represent specific headers may require specific values for a label.
Reimplemented in RWMimeContentTypeHeader, RWMimeGenericHeader, RWMimeContentLocationHeader, RWMimeContentIdHeader, RWMimeContentTransferEncodingHeader, RWMimeVersionHeader, RWMimeContentDispositionHeader, and RWMimeContentDescriptionHeader.
void RWMimeHeader::fromString | ( | const RWCString & | headerString | ) |
Populates self with the contents of headerString. Throws RWMimeParseError if the function cannot parse headerString as a valid header. In derived classes, throws RWMimeError if the label in headerString is not a valid label for the header that the class represents. The RWCString should contain 7-bit US-ASCII data.
RWCString RWMimeHeader::getLabel | ( | void | ) | const |
Returns the label of this header. The RWCString should contain 7-bit US-ASCII data.
RWMimeHeader& RWMimeHeader::operator= | ( | const RWMimeHeader & | second | ) |
Assignment operator. Makes self a handle identical to second.
|
friend |
Inequality operator. Returns true
if first is not equal to second, false
otherwise. Uses a case-insensitive comparison for labels. If the labels match, compares the values as appropriate for the specific header type.
|
friend |
Equality operator. Returns true
if first is equal to second, false
otherwise. Uses a case-insensitive comparison for labels. If the labels match, compares the values as appropriate for the specific header type.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |