xml/xmlfw/src/xmlframework/attribute.cpp
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <xml/attribute.h>
       
    17 
       
    18 using namespace Xml;
       
    19 
       
    20 
       
    21 EXPORT_C RAttribute::RAttribute()
       
    22 /**
       
    23 Default constructor
       
    24 
       
    25 */
       
    26 	{
       
    27 	// do nothing;
       
    28 	}
       
    29 	
       
    30 	
       
    31 EXPORT_C RAttribute RAttribute::Copy()
       
    32 /**
       
    33 Copy method. The original and copy must be closed seperately.
       
    34 
       
    35 */
       
    36 	{
       
    37 	RAttribute copy;
       
    38 	RTagInfo tagCopy = iAttribute.Copy();
       
    39 	copy.Open(const_cast <RString&> (tagCopy.Uri()),
       
    40 			  const_cast <RString&> (tagCopy.Prefix()),
       
    41 			  const_cast <RString&> (tagCopy.LocalName()),
       
    42 			  iValue.Copy(),
       
    43 			  iType);
       
    44 	return copy;
       
    45 	}
       
    46 	
       
    47 
       
    48 
       
    49 EXPORT_C void RAttribute::Close()
       
    50 /**
       
    51 This method cleans up the object before destruction. It releases all resources in
       
    52 accordance to the R Class pattern.
       
    53 
       
    54 @post				This object may be allowed to go out of scope.
       
    55 
       
    56 */
       
    57 	{
       
    58 	iAttribute.Close();
       
    59 	iValue.Close();
       
    60 	}
       
    61 
       
    62 
       
    63 
       
    64 EXPORT_C void RAttribute::Open(const RString& aUri, const RString& aPrefix, 
       
    65 							   const RString& aLocalName, 
       
    66 							   const RString& aValue, const TAttributeType aType)
       
    67 /**
       
    68 This method sets all the attribute's contents, taking ownership of the RStrings.
       
    69 
       
    70 @pre				The object has just been constructed and no other values have been set.
       
    71 @post				The objects members have been set to the values given.
       
    72 
       
    73 @param				aUri The URI of the namespace.
       
    74 @param				aPrefix The prefix of the qualified name.
       
    75 @param				aLocalName The local name of the qualified name.
       
    76 @param				aValue The value associated with this attribute.
       
    77 @param				aType The type associated with this attribute.
       
    78 */
       
    79 	{
       
    80 	iAttribute.Open(aUri, aPrefix, aLocalName);
       
    81 	iValue = aValue;
       
    82 	iType = aType;
       
    83 	}
       
    84 
       
    85 
       
    86 
       
    87 EXPORT_C void RAttribute::Open(const RString& aUri, const RString& aPrefix, 
       
    88 							   const RString& aLocalName, const TAttributeType aType)
       
    89 /**
       
    90 This method sets the attribute's contents, taking ownership of the RStrings.
       
    91 
       
    92 @pre				The object has just been constructed and no other values have been set.
       
    93 @post				The objects members have been set to the values given.
       
    94 
       
    95 @param				aUri The URI of the namespace.
       
    96 @param				aPrefix The prefix of the qualified name.
       
    97 @param				aLocalName The local name of the qualified name.
       
    98 @param				aType The type associated with this attribute.
       
    99 */
       
   100 	{
       
   101 	iAttribute.Open(aUri, aPrefix, aLocalName);
       
   102 	iType = aType;
       
   103 	}
       
   104 
       
   105 
       
   106 
       
   107 EXPORT_C const RTagInfo& RAttribute::Attribute() const
       
   108 /**
       
   109 This method returns a handle to the attribute's name details.
       
   110 
       
   111 @return				The attribute's name details.
       
   112 
       
   113 @pre				The objects members have been pre-set accordingly.
       
   114 
       
   115 */
       
   116 	{
       
   117 	return iAttribute;
       
   118 	}
       
   119 
       
   120 
       
   121 
       
   122 EXPORT_C const RString& RAttribute::Value() const
       
   123 /**
       
   124 This method returns a handle to the attribute value. 
       
   125 If the attribute value is a list of tokens (IDREFS, ENTITIES or NMTOKENS), 
       
   126 the tokens will be concatenated into a single RString with each token separated 
       
   127 by a single space.
       
   128 
       
   129 @return				A handle to the attribute value.
       
   130 
       
   131 @pre				The objects members have been pre-set accordingly.
       
   132 
       
   133 */
       
   134 	{
       
   135 	return iValue;
       
   136 	}
       
   137 
       
   138 
       
   139 
       
   140 EXPORT_C TAttributeType RAttribute::Type() const
       
   141 /**
       
   142 This method returns the attribute's type. 
       
   143 
       
   144 @return				The attribute's type.
       
   145 
       
   146 @pre				The objects members have been pre-set accordingly.
       
   147 
       
   148 */
       
   149 	{
       
   150 	return iType;
       
   151 	}
       
   152 
       
   153 
       
   154 
       
   155 EXPORT_C void RAttribute::SetValue(const RString& aValue)
       
   156 /**
       
   157 This method sets the attribute's value, taking ownership of the RString.
       
   158 
       
   159 @param				aValue The attributes value.
       
   160 */
       
   161 	{
       
   162 	iValue.Close();
       
   163 	iValue = aValue;
       
   164 	}