SOAPElement.h

Go to the documentation of this file.
00001 
00010 // SOAPElement.h: interface for the SOAPElement class.
00011 //
00013 
00014 /*
00015 #if !defined(SOAPELEMENT_H)
00016     #include "SOAPElement.h"
00017 #endif // !defined(SOAPELEMENT_H)
00018 */
00019 #if !defined(SOAPELEMENT_H)
00020 #define SOAPELEMENT_H
00021 
00022 #ifndef _STRING_
00023     #include <string>
00024 #endif // _STRING_
00025 
00026 #ifndef _VECTOR_
00027     #include <vector>
00028 #endif // _VECTOR_
00029 
00030 #if !defined(SOAPATTRIBUTE_H)
00031     #include "SOAPAttribute.h"
00032 #endif // !defined(SOAPATTRIBUTE_H)
00033 
00034 #include <sstream>
00035 
00036 class SOAPElement  
00037 {
00038 public:
00039     // Constructor/ Destructor
00040     SOAPElement();
00041     SOAPElement( const SOAPElement& rhs );
00042     SOAPElement& operator=( const SOAPElement& rhs );
00043     virtual ~SOAPElement();
00044     
00045     // accessorName
00046     // Description:
00047     //  Returns the string used to access the SOAPElement.
00048     // Arugments:
00049     //  N/A
00050     // Return Value:
00051     //  Reference to the actual accessor name.  Since I have no 
00052     //  intention of guarding the getting and setting of the accessor
00053     //  name, I return a reference to the internal element.
00054     std::string& accessorName();
00055     
00056     // namespaceName
00057     // Description:
00058     //  Returns the string used as the SOAPElement namespace.
00059     // Arugments:
00060     //  N/A
00061     // Return Value:
00062     //  Reference to the actual namespace name.  Since I have no 
00063     //  intention of guarding the getting and setting of the 
00064     //  namespace name, I return a reference to the internal element.
00065     std::string& namespaceName();
00066     
00067     // value
00068     // Description:
00069     //  Gets the value inside the element (between the 
00070     //  begin and end tags).  It's up to you to decide
00071     //  how to interpret it.
00072     // Arugments:
00073     //  N/A     
00074     // Return Value:
00075     //  Reference to the actual value.  Since I have no intention
00076     //  of guarding the getting and setting of the value,
00077     //  I return a reference to the internal element.
00078     std::string& value();
00079     
00080     // addAttribute
00081     // Description:
00082     //  Adds an attribute to the element.
00083     // Arugments:
00084     //  theAttribute: The attribute to add.
00085     // Return Value:
00086     //  true: Successfully added.
00087     //  false: Didn't add.
00088     bool addAttribute( SOAPAttribute theAttribute );
00089     
00090     // getAttribute
00091     // Description:
00092     //  Given an attribute name, this finds the named attribute.
00093     //  If you are looking for a fully qualified attribute (namespace
00094     //  plus base name), just pass it in.  I'll find the colon (':').
00095     // Arugments:
00096     //  szAttributeName: Name of the attribute to find.
00097     //  szValue: On return, contains a copy of the internal 
00098     //  attribute.
00099     // Return Value:
00100     //  true: Found it.
00101     //  false: Didn't find it.
00102     bool getAttribute( const std::string& szAttributeName, 
00103         SOAPAttribute& szValue );
00104     
00105     // addElement
00106     // Description:
00107     //  Adds an element beneath the current element.
00108     // Arugments:
00109     //  pElement: Pointer to the element.  This object
00110     //      expects to assume ownership of the element and
00111     //      will destroy it when this element is deleted or
00112     //      goes out of scope.  Don't call this method if you
00113     //      want to control the objects lifespan.
00114     // Return Value:
00115     //  true: Successfully added.
00116     //  false: Didn't add.
00117     bool addElement( SOAPElement* pElement );
00118     
00119     // getElement
00120     // Description:
00121     //  Given an element name, this finds the named element.
00122     //  If you are looking for a fully qualified element (namespace
00123     //  plus base name), just pass it in.  I'll find the colon (':').
00124     // Arugments:
00125     //  szElementName: Name of the element to find.
00126     //  pValue: Pointer to a SOAPElement pointer.  You don't need to
00127     //      delete this pointer when you are done-- this class still
00128     //      owns the memory.
00129     // Return Value:
00130     //  true: Found it.
00131     //  false: Didn't find it.
00132     bool getElement( const std::string& szElementName, 
00133         SOAPElement** pValue );
00134     
00135     // numElements
00136     // Description:
00137     //  Tells the caller how many immediate subelements
00138     //  are contained by this SOAPElement.  This does
00139     //  not return the total number of nodes in the tree.
00140     // Arugments:
00141     //  N/A
00142     // Return Value:
00143     //  Number of immediate child nodes.
00144     long numElements() const;
00145     
00146     // numAttributes
00147     // Description:
00148     //  Tells the caller how many attributes this element contains.
00149     // Arugments:
00150     //  N/A
00151     // Return Value:
00152     //  See description.
00153     long numAttributes();
00154     
00155     // elementAt
00156     // Description:
00157     //  Returns the SOAPElement at a specific index.
00158     // Arugments:
00159     //  index: Zero-based index of the SOAPElement you
00160     //      want to retrieve.
00161     // Return Value:
00162     //  Reference to the requested SOAPElement.
00163     SOAPElement& elementAt( long index );
00164     
00165     // attributeAt
00166     // Description:
00167     //  Returns the SOAPAttribute at a specific index.
00168     // Arugments:
00169     //  index: Zero-based index of the SOAPAttribute you
00170     //      want to retrieve.
00171     // Return Value:
00172     //  Reference to the requested SOAPAttribute.
00173     SOAPAttribute& attributeAt( long index );
00174     
00175 
00176         void serialize(std::ostringstream& stream);
00177         void serialize(std::ostringstream& stream, SOAPElement& element);
00178 
00179 private:
00180     
00181     // m_szAccessorName
00182     // Description: Name of the element (minus namespace name).
00183     std::string m_szAccessorName;
00184     
00185     // m_szNamespace
00186     // Description: Name of the namespace (minus accessor name).
00187     std::string m_szNamespace;
00188     
00189     // m_szValue
00190     // Description: Value contained between the start and stop tags.
00191     std::string m_szValue;
00192     
00193     // Retrieve attributess using attribute name.
00194     typedef std::vector< SOAPAttribute > AttributeContainer;
00195     
00196     // m_attributes
00197     // Description: List of attributes.
00198     AttributeContainer m_attributes;
00199     
00200     // ElementContainer
00201     // Description: Container of SOAPElements.
00202     //typedef std::vector< std::auto_ptr<SOAPElement> > ElementContainer;
00203         typedef std::vector<SOAPElement*> ElementContainer;
00204 
00205     // m_internalElements
00206     // Description: The SOAPElements owned by this SOAPElement.
00207     ElementContainer m_internalElements;
00208 };
00209 
00210 #endif // !defined(SOAPELEMENT_H)

Generated on Tue Mar 28 09:10:14 2006 for Simple SOAP by  doxygen 1.4.6