Inheritance diagram for MediaType:

MediaType has member functions that allow you to set or get the type and subtype as either enumerated values or as strings. It also contains a list of Parameter objects that represent the parameters of the field body. You can use convenience functions to directly access the boundary parameter of a multipart media type, or to access the name parameter that is often used with several media types, such as application/octet-stream.
Some MIME parsers have problems with folded header fields, and this especially seems to be a problem with the content-type field. To disable folding when the MediaType object is assembled, call the inherited member function FieldBody::setFoldingEnabled() with an argument of false.
Public Member Functions | |
| MediaType () | |
| Default constructor. | |
| MediaType (const MediaType &other) | |
| Copy constructor. | |
| MediaType (const String &str, Node *parent=0) | |
| Constructor that takes an initial string and parent node. | |
| virtual | ~MediaType () |
| Destructor. | |
| const MediaType & | operator= (const MediaType &other) |
| Assignment operator. | |
| virtual void | parse () |
| Parses the string representation. | |
| virtual void | assemble () |
| Assembles the string representation. | |
| virtual Node * | clone () const |
| Creates a copy of this object. | |
| MType | typeAsEnum () const |
| Gets the primary type as an enumerated value. | |
| void | typeFromEnum (MType type) |
| Sets the primary type from an enumerated value. | |
| const String & | type () const |
| Gets the primary type as a string. | |
| void | setType (const String &str) |
| Sets the primary type from a string. | |
| const String & | subtype () const |
| Gets the subtype as a string. | |
| void | setSubtype (const String &str) |
| Sets the subtype from a string. | |
| const String & | boundary () const |
| Gets the value of the boundary parameter, if present. | |
| void | setBoundary (const String &str) |
| Sets the value of the boundary parameter. | |
| virtual const String & | createBoundary (unsigned level=0) |
| Creates and adds a boundary parameter. | |
| const String & | name () const |
| Gets the value of the name parameter, if present. | |
| void | setName (const String &str) |
| Sets the value of the name parameter. | |
| const String & | charset () const |
| Gets the value of the charset parameter, if present. | |
| void | setCharset (const String &str) |
| Sets the value of the charset parameter. | |
| int | numParameters () const |
| Gets the number of parameters in the list. | |
| void | addParameter (Parameter *param) |
| Adds a parameter to the end of the list. | |
| void | deleteAllParameters () |
| Deletes all parameters in the list. | |
| Parameter & | parameterAt (int index) const |
| Gets the parameter at the specified position in the list. | |
| void | insertParameterAt (int index, Parameter *param) |
| Inserts a parameter at the specified position in the list. | |
| Parameter * | removeParameterAt (int index) |
| Removes the parameter at the specified position in the list. | |
Static Public Member Functions | |
| MediaType * | newMediaType () |
| Creates a new instance. | |
Static Public Attributes | |
| MediaType *(* | sNewMediaType )() |
| Provides a class factory hook. | |
Protected Member Functions | |
| void | _copyParameters (const MediaType &type) |
| Copies all parameters from another list. | |
| void | _addParameter (Parameter *parameter) |
| Adds a parameter to the end of the list. | |
| void | _insertParameterAt (int index, Parameter *param) |
| Inserts a parameter at the specified position in the list. | |
| Parameter * | _removeParameterAt (int index) |
| Removes the parameter at the specified position in the list. | |
| void | _deleteAllParameters () |
| Deletes all parameters in the list. | |
|
|
This constructor sets the MediaType object's string representation to the empty string and sets its parent node to NULL. |
|
|
This constructor performs a deep copy of its argument. The parent node of the new MediaType object is set to NULL.
|
|
||||||||||||
|
This constructor sets the MediaType object's string representation to str and sets its parent node to parent. Normally, you call the virtual function parse() immediately after this constructor to create the broken-down representation.
|
|
|
Destructor |
|
|
Same as addParameter(), but does not set the is-modified flag.
|
|
|
Copies the list of Parameter objects from type. Assumes the list in this MediaType object is emtpy. Does not set the is-modified flag.
|
|
|
Same as deleteAllParameters(), but does not set the is-modified flag.
|
|
||||||||||||
|
Same as insertParameterAt(), but does not set the is-modified flag.
|
|
|
Same as removeParameterAt(), but does not set the is-modified flag.
|
|
|
Adds param to the end of the parameter list. The MediaType destructor deletes the Parameter objects in the list.
|
|
|
This virtual function, inherited from Node, executes the assemble operation for MediaType objects. The assemble operation creates or updates the string representation from the broken-down representation. For MediaType objects, the assemble operation builds the string representation from the type, subtype, and list of Parameter objects. Before it builds the string representation for the MediaType object, this function first calls the assemble() member function of each Parameter object in its list. You should call this member function after you set or modify the type, subtype, or any of the contained Parameter objects, and before you retrieve the string representation. This function clears the is-modified flag. Reimplemented from FieldBody. |
|
|
Gets the value of the boundary parameter. The boundary parameter is required if the primary type is multipart. If there is no boundary parameter, this member function returns an empty string. This member function is a convenience function that searches the list of Parameter objects.
|
|
|
Gets the value of the charset parameter, if such a parameter is present. The charset parameter is often found in text media types. It indicates the character encoding of the text content. This member function is a convenience function that searches the list of Parameter objects.
|
|
|
This virtual function, inherited from Node, creates a new MediaType object that has the same value as this MediaType object. The parent node of the new MediaType object is set to NULL.
Reimplemented from FieldBody. |
|
|
Creates a boundary string and sets it as the value of the boundary parameter. The boundary parameter is required if the primary type is multipart. level indicates the level of a nested multipart body part; if it is positive, it is used to form part of the created boundary string. This member function is a convenience function that accesses the list of Parameter objects.
|
|
|
Removes and deletes all Parameter objects in the parameter list. |
|
||||||||||||
|
Inserts param into the parameter list at position index. If index is zero, then the function inserts param into the first position in the list. If index equals numParameters(), then the function inserts param into the last position in the list. If index is less than numParameters(), then the function moves the Parameter objects at position index or greater to a higher position in the list. The MediaType destructor deletes the Parameter objects in the list. The function's behavior is undefined if index is out of range. Valid values for index are 0 <= index <= numParameters().
|
|
|
Gets the value of the name parameter, if such a parameter is present. The name parameter is often found in several media types, including the application/octet-stream media type; it suggests a file name for saving the content to a disk file. (The filename parameter in the content-disposition header field is an alternative way to indicate a file name.) This member function is a convenience function that searches the list of Parameter objects.
|
|
|
Creates a new MediaType object. If the static data member sNewMediaType is NULL, this member function creates a new MediaType object and returns it. Otherwise, newMediaType() calls the user-supplied function that sNewMediaType points to and returns the object created by that function.
|
|
|
Gets the number of Parameter objects in the parameter list.
|
|
|
Performs a deep copy of its argument. The parent node of this MediaType object is not changed.
|
|
|
Gets the Parameter object at position index in the parameter list. The function's behavior is undefined if index is out of range. Valid values for index are 0 <= index < numParameters().
|
|
|
This virtual function, inherited from Node, executes the parse operation for MediaType objects. The parse operation creates or updates the broken-down representation from the string representation. For MediaType objects, the parse operation parses the string representation to extract the type, subtype, and the list of Parameter objects. This member function also calls the parse() member function of each Parameter object in its list. You should call this member function after you set or modify the string representation, and before you access the type, subtype, or any of the contained Parameter objects. This function clears the is-modified flag. Reimplemented from FieldBody. |
|
|
Removes the Parameter object at position index from the parameter list and returns it. If index is less than numParameters()-1, then the function moves the Parameter objects at position (index + 1) or greater to a lower position in the list. The function's behavior is undefined if index is out of range. Valid values for index are 0 <= index < numParameters().
|
|
|
Sets the value of the boundary parameter. The boundary parameter is required if the primary type is multipart. If no boundary parameter exists when this function is called, this function will create a new boundary parameter and add it to the list. This member function is a convenience function that accesses the list of Parameter objects.
|
|
|
Sets the value of the charset parameter. If a charset parameter is not already present, it is added. The charset parameter is often found in text media types. It character encoding for the text content. This member function is a convenience function that accesses the list of Parameter objects.
|
|
|
Sets the value of the name parameter. If a name parameter is not already present, it is added. The name parameter is often found in several media types, including the application/octet-stream media type; it suggests a file name for saving the content to a disk file. (The filename parameter in the content-disposition header field is an alternative way to indicate a file name.) This member function is a convenience function that accesses the list of Parameter objects.
|
|
|
Sets the subtype from a string.
|
|
|
Sets the primary type from a string.
|
|
|
Gets the subtype as a string.
|
|
|
Gets the primary type as a string.
|
|
|
Gets the primary type as an enumerated value.
|
|
|
Sets the primary type from an enumerated value.
|
|
|
If sNewMediaType is not NULL, it must point to a user-supplied function that returns a new instance of a subclass of MediaType.
|
Copyright © 2001-2007 Hunny Software, Inc. All rights reserved.