home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / mechansm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  6.9 KB  |  173 lines

  1. //=============================================================================
  2. // File:       mechansm.h
  3. // Contents:   Declarations for DwMechanism
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  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.
  14. //
  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.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_MECHANSM_H
  24. #define DW_MECHANSM_H
  25.  
  26. #ifndef DW_CONFIG_H
  27. #include <mimelib/config.h>
  28. #endif
  29.  
  30. #ifndef DW_STRING_H
  31. #include <mimelib/string.h>
  32. #endif
  33.  
  34. #ifndef DW_FIELDBDY_H
  35. #include <mimelib/fieldbdy.h>
  36. #endif
  37.  
  38.  
  39. //=============================================================================
  40. //+ Name DwMechanism -- Class representing a MIME content-transfer-encoding field-body
  41. //+ Description
  42. //. {\tt DwMechanism} represents a field body for the
  43. //. Content-Transfer-Encoding header field as described in RFC-2045.
  44. //. {\tt DwMechanism} provides convenience functions that allow you to
  45. //. set or get the content-transfer-encoding attribute as an enumerated
  46. //. value.
  47. //=============================================================================
  48. // Last updated 1997-08-30
  49. //+ Noentry ~DwMechanism _PrintDebugInfo
  50.  
  51.  
  52. class DW_EXPORT DwMechanism : public DwFieldBody {
  53.  
  54. public:
  55.  
  56.     DwMechanism();
  57.     DwMechanism(const DwMechanism& aCte);
  58.     DwMechanism(const DwString& aStr, DwMessageComponent* aParent=0);
  59.     //. The first constructor is the default constructor, which sets the
  60.     //. {\tt DwMechanism} object's string representation to the empty
  61.     //. string and sets its parent to {\tt NULL}.
  62.     //.
  63.     //. The second constructor is the copy constructor, which copies the
  64.     //. string representation from {\tt aCte}.
  65.     //. The parent of the new {\tt DwMechanism} object is set to {\tt NULL}.
  66.     //.
  67.     //. The third constructor copies {\tt aStr} to the {\tt DwMechanism}
  68.     //. object's string representation and sets {\tt aParent} as its parent.
  69.     //. The virtual member function {\tt Parse()} should be called immediately
  70.     //. after this constructor in order to parse the string representation.
  71.     //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
  72.     //. a class derived from {\tt DwField}.
  73.  
  74.     virtual ~DwMechanism();
  75.  
  76.     const DwMechanism& operator = (const DwMechanism& aCte);
  77.     //. This is the assignment operator, which performs a deep copy of
  78.     //. {\tt aCte}.  The parent node of the {\tt DwMechanism} object
  79.     //. is not changed.
  80.  
  81.     virtual void Parse();
  82.     //. This virtual function, inherited from {\tt DwMessageComponent},
  83.     //. executes the parse method for {\tt DwMechanism} objects.
  84.     //. It should be called immediately after the string representation
  85.     //. is modified and before any of the object's attributes are retrieved.
  86.     //.
  87.     //. This function clears the is-modified flag.
  88.  
  89.     virtual void Assemble();
  90.     //. This virtual function, inherited from {\tt DwMessageComponent},
  91.     //. executes the assemble method for {\tt DwMechanism} objects.
  92.     //. It should be called whenever one of the object's attributes
  93.     //. is changed in order to assemble the string representation.
  94.     //. It will be called automatically for this object by the parent
  95.     //. object's {\tt Assemble()} member function if the is-modified
  96.     //. flag is set.
  97.     //.
  98.     //. This function clears the is-modified flag.
  99.  
  100.     virtual DwMessageComponent* Clone() const;
  101.     //. This virtual function, inherited from {\tt DwMessageComponent},
  102.     //. creates a new {\tt DwMechanism} object on the free store that has
  103.     //. the same value as this {\tt DwMechanism} object.  The basic idea
  104.     //. is that of a virtual copy constructor.
  105.  
  106.     int AsEnum() const;
  107.     //. Returns the content transfer encoding as an enumerated value.
  108.     //. Enumerated values are defined for all standard content transfer
  109.     //. encodings in the file enum.h.  If the content transfer encoding
  110.     //. is non-standard {\tt DwMime::kCteUnknown} is returned.  The
  111.     //. inherited member function {\tt DwMessageComponent::AsString()}
  112.     //. may be used to get the content transfer encoding, standard or
  113.     //. non-standard, as a string.
  114.  
  115.     void FromEnum(int aCte);
  116.     //. Sets the content transfer encoding from an enumerated value.
  117.     //. Enumerated values are defined for all standard content transfer
  118.     //. encodings in the file enum.h.  You may set the content transfer
  119.     //. encoding to any string value, standard or non-standard, by using the
  120.     //. inherited member function {\tt DwMessageComponent::FromString()}.
  121.  
  122.     static DwMechanism*
  123.         NewMechanism(const DwString& aStr, DwMessageComponent* aParent);
  124.     //. Creates a new {\tt DwMechanism} object on the free store.
  125.     //. If the static data member {\tt sNewMechanism} is {\tt NULL},
  126.     //. this member function will create a new {\tt DwMechanism}
  127.     //. and return it.  Otherwise, {\tt NewMechanism()} will call
  128.     //. the user-supplied function pointed to by
  129.     //. {\tt sNewMechanism}, which is assumed to return an
  130.     //. object from a class derived from {\tt DwMechanism}, and
  131.     //. return that object.
  132.  
  133.     //+ Var sNewMechanism
  134.     static DwMechanism*
  135.         (*sNewMechanism)(const DwString&, DwMessageComponent*);
  136.     //. If {\tt sNewMechanism} is not {\tt NULL}, it is assumed
  137.     //. to point to a user-supplied function that returns an object from
  138.     //. a class derived from {\tt DwMechanism}.
  139.  
  140. private:
  141.  
  142.     int mCteEnum;
  143.     static const char* const sClassName;
  144.  
  145.     void EnumToString();
  146.     void StringToEnum();
  147.  
  148. public:
  149.  
  150.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  151.     //. This virtual function, inherited from {\tt DwMessageComponent},
  152.     //. prints debugging information about this object to {\tt aStrm}.
  153.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  154.     //. components down to a level of {\tt aDepth}.
  155.     //.
  156.     //. This member function is available only in the debug version of
  157.     //. the library.
  158.  
  159.     virtual void CheckInvariants() const;
  160.     //. Aborts if one of the invariants of the object fails.  Use this
  161.     //. member function to track down bugs.
  162.     //.
  163.     //. This member function is available only in the debug version of
  164.     //. the library.
  165.  
  166. protected:
  167.  
  168.     void _PrintDebugInfo(std::ostream& aStrm) const;
  169.  
  170. };
  171.  
  172. #endif
  173.