pressrv_plat/simple_documents_api/inc/msimpleelement.h
changeset 0 c8caa15ef882
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    SIMPLE data element
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef M_simpleelement_H
       
    22 #define M_simpleelement_H
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <msimpleattribute.h>
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 class MSimpleNamespace;
       
    29 
       
    30 /**
       
    31  *  MSimpleDocument
       
    32  *
       
    33  *  SIMPLE data document
       
    34  *
       
    35  *  @lib simplexmlutils
       
    36  *  @since S60 3.2
       
    37  */
       
    38 
       
    39 class MSimpleElement
       
    40     {
       
    41 
       
    42 public:
       
    43 
       
    44     /**
       
    45      * Destroy this element entity and all its descendant elements.
       
    46      * @since S60 3.2
       
    47      */
       
    48     virtual void Close() = 0;
       
    49 
       
    50     /**
       
    51      * Getter for Element's local name.
       
    52      * LocalName and Namespace are given in factory method.
       
    53      * @since S60 3.2
       
    54      * @return KNullDesC8 if not set
       
    55      */
       
    56     virtual const TDesC8& LocalName() = 0;
       
    57 
       
    58     /**
       
    59      * Getter for Element's own default namespace.
       
    60      *
       
    61      * @since S60 3.2
       
    62      * @return pointer to the MSimpleNamespace object of this Element.
       
    63      *        NULL if not set for this element. Ownership is transferred.
       
    64      */
       
    65     virtual MSimpleNamespace* DefNamespaceL() = 0;
       
    66 
       
    67     /**
       
    68      * Method for checking if the element has any content within.
       
    69      *
       
    70      * @since S60 3.2
       
    71      * @return ETrue if has content, EFalse if not.
       
    72      */
       
    73     virtual TBool HasContent() = 0;
       
    74 
       
    75     /**
       
    76      * Getter for the content of the element, unicode version.
       
    77      *
       
    78      * @since S60 3.2
       
    79      * @return content as unicode. Ownership IS TRANSFERRED to the caller.
       
    80      */
       
    81     virtual HBufC* ContentUnicodeL()= 0;
       
    82 
       
    83     /**
       
    84      * Sets the content to the element. Old content is overwritten.
       
    85      *
       
    86      * @since S60 3.2
       
    87      * @param aContent: The content to be set. Can be KNullDesC
       
    88      */
       
    89     virtual void SetContentUnicodeL( const TDesC& aContent ) = 0;
       
    90 
       
    91     /**
       
    92      * Getting the child elements of this element.
       
    93      * @param aElementArray: Array to be filled with the child elements,
       
    94      *         or empty array if no childs.
       
    95      *         Any modifications made on the returned items
       
    96      *         modify the real childs.
       
    97      *         Do NOT call ResetAndDestroy() for the array,
       
    98      *         you may call Reset() only. The array is valid only till
       
    99      *         the next call of this method in this entity. New elements are
       
   100      *         not attached to the array automatically, so that you have
       
   101      *         to re-call this method if you wish to see all the elements
       
   102      *         after calling AddSimpleElementL() method.
       
   103      * @return KErrNone     ok
       
   104      *         KErrNotFound No child elements exist.
       
   105      */
       
   106     virtual TInt SimpleElementsL( RPointerArray<MSimpleElement>& aElementArray ) = 0;
       
   107 
       
   108     /**
       
   109      * Gets the value of the given attribute.
       
   110      *
       
   111      * @since S60 3.2
       
   112      * @param aName:    Name of the attribute in question.
       
   113      * @return the value of the attribute, or NULL if not found. Ownership is
       
   114      *        TRANSFERRED.
       
   115      */
       
   116     virtual HBufC* AttrValueLC( const TDesC8& aName ) = 0;
       
   117 
       
   118     /**
       
   119      * Gets the value of the given attribute.
       
   120      * @param aName:    Name of the attribute in question.
       
   121      * @return the value of the attribute, or NULL if not found. Ownership is
       
   122      *         NOT TRANSFERRED.
       
   123      */
       
   124     virtual const TDesC8* AttrValue( const TDesC8& aName ) = 0;
       
   125 
       
   126     /**
       
   127      * Adds an attribute. If attribute is already existing,
       
   128      * the value of the attribute will be replaced.
       
   129      *
       
   130      * @since S60 3.2
       
   131      * @param aName     Name of the attribute to be added.
       
   132      * @param aValue    Value of the attribute to be added.
       
   133      */
       
   134     virtual void AddAttrL( const TDesC8& aName, const TDesC& aValue ) = 0;
       
   135 
       
   136     /**
       
   137      * From MSimpleElement
       
   138      * Gets all the attributes of this element in an array.
       
   139      *
       
   140      * @since S60 3.2
       
   141      * @param aArray: Array to be filled with the attributes,
       
   142      *         or empty array if no childs.
       
   143      *         Any modifications made on the returned items
       
   144      *         modify the real attributes.
       
   145      *         Do NOT call ResetAndDestroy() for the array,
       
   146      *         you may call Reset() only. The array is valid only till
       
   147      *         the next call of this method in this entity. New attributes are
       
   148      *         not attached to the array automatically, so that you have
       
   149      *         to re-call this method if you wish to see all the elements
       
   150      *         after calling AddAttrL() method.
       
   151      * @return KErrNone ok
       
   152      *         KErrNotFound No child elements exist.
       
   153      */
       
   154     virtual TInt SimpleAttributesL( RPointerArray<MSimpleAttribute>& aArray ) = 0;
       
   155 
       
   156     /**
       
   157      * Gets the parent element of this element.
       
   158      *
       
   159      * @since S60 3.2
       
   160      * @return the parent element or NULL if no parent set.
       
   161      *        Ownership is NOT transferred to the caller.
       
   162      */
       
   163     virtual MSimpleElement* SimpleParentL() = 0;
       
   164 
       
   165     /**
       
   166      * Detach the element from its parent.
       
   167      * Notice that the current element instance should not be
       
   168      * used after this method is called successfully.
       
   169      * Leaves with KErrNotFound if parent was not set and
       
   170      * nothing to detach.
       
   171      *
       
   172      * @since S60 3.2
       
   173      */
       
   174     virtual void DetachSimpleL() = 0;
       
   175 
       
   176     /**
       
   177      * Constructs and adds a new element to the children elements.
       
   178      * Sets this element to be the new parent of the given element.
       
   179      *
       
   180      * @since S60 3.2
       
   181      * @param aNsUri:       namespace URI of the new element
       
   182      * @param aLocalName:   local name of the new element
       
   183      * @return the added Element.
       
   184      * OWNERSHIP IS TRANSFERRED.
       
   185      * Leave if aLocalName contains illegal characters or
       
   186      *       if aLocalName is zero length.
       
   187      */
       
   188     virtual MSimpleElement* AddSimpleElementL(
       
   189         const TDesC8& aNsUri,
       
   190         const TDesC8& aLocalName ) = 0;
       
   191 
       
   192     /**
       
   193      * Constructs and adds a new element to the children elements.
       
   194      * Sets this element to be the new parent of the given element.
       
   195      * Note: Element is created with no specific namespace, default namespace
       
   196      * of some of the upper level elements are in effect if there is such a
       
   197      * namespace.
       
   198      *
       
   199      * @since S60 3.2
       
   200      * @param aLocalName:   local name of the new element
       
   201      * @return the added Element. OWNERSHIP IS TRANSFERRED.
       
   202      * Leave if aLocalName contains illegal characters.
       
   203      */
       
   204     virtual MSimpleElement* AddSimpleElementL(
       
   205         const TDesC8& aLocalName ) = 0;
       
   206 
       
   207     /**
       
   208      * Remove an element from the childs.
       
   209      *
       
   210      * @since S60 3.2
       
   211      * @param   aNsUri:     the namespace URI of the element to be removed.
       
   212      * @param   aLocalName: the local name of the element to be removed.
       
   213      */
       
   214     virtual void RemoveSimpleElement(
       
   215         const TDesC8& aNsUri,
       
   216         const TDesC8& aLocalName ) = 0;
       
   217 
       
   218     };
       
   219 
       
   220 #endif
       
   221 
       
   222 // End of File