webservices/wsxml/src/sennamespace.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:        
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 #include "SenNameSpace.h"
       
    27 #include "SenXmlConstants.h"
       
    28 
       
    29 EXPORT_C CSenNamespace* CSenNamespace::NewL(const TDesC8& aUri)
       
    30     {
       
    31     // Note: intentionally calling the other version of NewLC to leave out
       
    32     // one call in call stack
       
    33     CSenNamespace* pNew = CSenNamespace::NewLC(KNullDesC8, aUri);
       
    34     CleanupStack::Pop();
       
    35     return pNew;
       
    36     }
       
    37 
       
    38 EXPORT_C CSenNamespace* CSenNamespace::NewLC(const TDesC8& aUri)
       
    39     {
       
    40     CSenNamespace* pNew = CSenNamespace::NewLC(KNullDesC8, aUri);
       
    41     return pNew;
       
    42     }
       
    43 
       
    44 EXPORT_C CSenNamespace* CSenNamespace::NewL(const TDesC8& aPrefix, const TDesC8& aUri)
       
    45     {
       
    46     CSenNamespace* pNew = CSenNamespace::NewLC(aPrefix, aUri);
       
    47     CleanupStack::Pop();
       
    48     return pNew;
       
    49     }
       
    50 
       
    51 EXPORT_C CSenNamespace* CSenNamespace::NewLC(const TDesC8& aPrefix, const TDesC8& aUri)
       
    52     {
       
    53     CSenNamespace* pNew = new (ELeave) CSenNamespace();
       
    54     CleanupStack::PushL(pNew);
       
    55 
       
    56     pNew->ConstructL(aPrefix, aUri);
       
    57     return pNew;
       
    58     }
       
    59 
       
    60 
       
    61 CSenNamespace::CSenNamespace()
       
    62 :   ipPrefix(NULL),
       
    63     ipUri(NULL)
       
    64     {
       
    65 
       
    66     }
       
    67 
       
    68 void CSenNamespace::ConstructL(const TDesC8& aPrefix, const TDesC8& aUri)
       
    69     {
       
    70     if (aPrefix.Length() > -1)
       
    71         {
       
    72         ipPrefix = aPrefix.AllocL();
       
    73         }
       
    74 
       
    75     if (aUri.Length() > 0)
       
    76         {
       
    77         ipUri = aUri.AllocL();
       
    78         }
       
    79     }
       
    80 
       
    81 EXPORT_C CSenNamespace::~CSenNamespace()
       
    82     {
       
    83     delete ipPrefix;
       
    84     delete ipUri;
       
    85     }
       
    86 
       
    87 EXPORT_C TBool CSenNamespace::Compare(const TDesC8& aOtherPrefix,
       
    88                                        const TDesC8& aOtherUri) const
       
    89     {
       
    90     TBool retVal(EFalse);
       
    91     if (aOtherUri == URI())
       
    92         {
       
    93         if (aOtherPrefix == KNullDesC8 || aOtherPrefix == Prefix())
       
    94             {
       
    95             retVal = ETrue;
       
    96             }
       
    97         }
       
    98     return retVal;
       
    99     }
       
   100 
       
   101 EXPORT_C TBool CSenNamespace::Compare(
       
   102                                 const CSenNamespace& aOtherNamespace) const
       
   103     {
       
   104     return this->Compare(aOtherNamespace.Prefix(), aOtherNamespace.URI());
       
   105     }
       
   106 
       
   107 EXPORT_C TBool CSenNamespace::MatchesL(
       
   108                                 const CSenNamespace& aOtherNamespace) const
       
   109     {
       
   110     return (*ipUri == aOtherNamespace.URI());
       
   111     }
       
   112 
       
   113 EXPORT_C const TDesC8& CSenNamespace::URI() const
       
   114     {
       
   115     if(ipUri)
       
   116         {
       
   117         return *ipUri;
       
   118         }
       
   119     else
       
   120         {
       
   121         return KNullDesC8;
       
   122         }
       
   123     }
       
   124 
       
   125 EXPORT_C void CSenNamespace::SetUriL(const TDesC8& aUri)
       
   126     {
       
   127     HBufC8* pUri = NULL;
       
   128     if(aUri!=KNullDesC8)
       
   129         {
       
   130         pUri = aUri.AllocL();
       
   131         }
       
   132     delete ipUri;
       
   133     ipUri = pUri;
       
   134     }
       
   135 
       
   136 EXPORT_C const TDesC8& CSenNamespace::Prefix() const
       
   137     {
       
   138     if(ipPrefix)
       
   139         {
       
   140         return *ipPrefix;
       
   141         }
       
   142     else
       
   143         {
       
   144         return KNullDesC8;
       
   145         }
       
   146     }
       
   147 
       
   148 EXPORT_C void CSenNamespace::SetPrefixL(const TDesC8& aPrefix)
       
   149     {
       
   150     HBufC8* pPrefix = NULL;
       
   151     if(aPrefix!=KNullDesC8)
       
   152         {
       
   153         pPrefix = aPrefix.AllocL();
       
   154         }
       
   155     delete ipPrefix;
       
   156     ipPrefix = pPrefix;
       
   157     }
       
   158 
       
   159 
       
   160 
       
   161 EXPORT_C void CSenNamespace::InsertL(RBufWriteStream& aWs)
       
   162     {
       
   163     if(!ipUri)
       
   164         {
       
   165         //SENDEBUG((_L("CSenNamespace::InsertL illegal ns, it has no URI!")));
       
   166         return;
       
   167         }
       
   168 
       
   169     aWs.WriteL(KSenSpaceXmlns);
       
   170     if(ipPrefix && ipPrefix->Length()>0)
       
   171         {
       
   172         aWs.WriteL(KSenColon);
       
   173         aWs.WriteL(*ipPrefix);
       
   174         }
       
   175     aWs.WriteL(KSenEquals);
       
   176     aWs.WriteL(*ipUri);
       
   177     }
       
   178 
       
   179 //  End of File