webservices/wsstar/wsstarpolicy/inc/wspolicywriter.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2009 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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef C_WS_POLICY_WRITER_H
       
    26 #define C_WS_POLICY_WRITER_H
       
    27 
       
    28 
       
    29 #include <e32std.h>
       
    30 #include <f32file.h>
       
    31 #include <s32mem.h>
       
    32 
       
    33 #include "SenDomFragment.h"
       
    34 #include "policyassertion.h"
       
    35 #include "primitiveassertion.h"
       
    36 
       
    37 class CPolicyAssertion;
       
    38 class CAndCompositeAssertion;
       
    39 class CXorCompositeAssertion;
       
    40 class CAssertion;
       
    41 class CPrimitiveAssertion;
       
    42 class CPolicyReferenceAssertion;
       
    43 namespace PolicyWriter
       
    44 {
       
    45     // XML String constants
       
    46 _LIT8(KSenColon,                 ":");
       
    47 _LIT8(KStartElement,              "<");
       
    48 _LIT8(KSenGreaterThan,           ">");
       
    49 _LIT8(KSenSpace,                 " ");
       
    50 _LIT8(KSenDblQuot,               "\"");
       
    51 _LIT8(KSenEquals,                "=");
       
    52 _LIT8(KSenEqualsDblQuot,         "=\"");
       
    53 _LIT8(KEndElement,               "/>");
       
    54 _LIT8(KSenLessThanSlash,         "</");
       
    55 _LIT8(KSenSpaceXmlns,            " xmlns");
       
    56 _LIT8(KSenXmlns,                 "xmlns");
       
    57 _LIT8(KSenXmlNsAttNamePlusColon, " xmlns:"); 
       
    58 
       
    59 // The predeclared, basic XML entities:
       
    60 // &apos;    (')
       
    61 // &quot;    (")
       
    62 // &gt;      (>)
       
    63 // &lt;      (<)
       
    64 // &amp;     (&)
       
    65 _LIT8(KSenQuotedApos,    "&apos;");
       
    66 _LIT8(KSenQuotedDblQuot, "&quot;");
       
    67 _LIT8(KSenQuotedGt,      "&gt;");
       
    68 _LIT8(KSenQuotedLt,      "&lt;");
       
    69 _LIT8(KSenQuotedAmp,     "&amp;");
       
    70 _LIT8(KWspPolicyPrefix,     "wsp:Policy");
       
    71 _LIT8(KWspXorPrefix,     "wsp:ExactlyOne");
       
    72 _LIT8(KWspAndPrefix,     "wsp:All");
       
    73 _LIT8(KWspPolicyReferencePrefix,     "wsp:PolicyReference");
       
    74 _LIT8(KWspPolicyReferenceUri,     "URI ");
       
    75 
       
    76 _LIT8(KSenXmlNsAttNamePlusColonWsp, " xmlns:wsp");
       
    77 }
       
    78 
       
    79 typedef RSenPointerMap<TDesC8, TDesC8> RNamespaceMap;
       
    80 
       
    81 class CWSPolicyWriter : public CBase
       
    82 {
       
    83 public:
       
    84     static  CWSPolicyWriter* NewL();
       
    85     static  CWSPolicyWriter* NewLC();
       
    86     ~CWSPolicyWriter();
       
    87     
       
    88 //#ifdef _SENDEBUG    
       
    89     void WriteToFileAllL(CSenElement* aXml);
       
    90     void WriteToFileAllL(TDesC8& aXml);
       
    91 //#endif
       
    92     
       
    93     HBufC8* WriteAllAsXMlL(CPolicyAssertion* aPolicy);
       
    94     HBufC8* WriteAllAsXmlL(CSenElement* aXml);
       
    95     TPtrC8 WriteToBufL(CBufBase& aBuf, CPolicyAssertion* aEle);
       
    96 private:
       
    97     
       
    98      TInt WritePolicyL(CPolicyAssertion* aEle, RWriteStream& aWriteStream);
       
    99      TInt WriteAndAssertionL(CAndCompositeAssertion* aEle, RWriteStream& aWriteStream);
       
   100      TInt WriteXorAssertionL(CXorCompositeAssertion* aEle, RWriteStream& aWriteStream);
       
   101      TInt WriteAssertionL(MAssertion* aEle, RWriteStream& aWriteStream);
       
   102      TInt WritePolicyReferenceL(CPolicyReferenceAssertion* aAssertion, RWriteStream& aWriteStream);
       
   103      TInt WritePrimitiveAssertionL(CPrimitiveAssertion* aEle, RWriteStream& aWriteStream);
       
   104      TInt WriteTermsL(RPointerArray<MAssertion>& aTerms, RWriteStream& aWriteStream);
       
   105      void WriteAttributesL(CPrimitiveAssertion* aAsserion, RWriteStream& aWriteStream);
       
   106      
       
   107      TPtrC8 GetAttrib(TPtrC8 aReference, CSenElement* aEle);
       
   108      
       
   109      TInt AddNameSpaceL(TPtrC8 aName, TPtrC8 aUri);	//codescannerwarnings
       
   110      TBool IsNamespaceAdded(TPtrC8 aName);
       
   111      
       
   112      CWSPolicyWriter();
       
   113      void ConstructL();
       
   114 private:
       
   115     RNamespaceMap iNamespcaes;
       
   116     TInt count;
       
   117 };
       
   118 #endif //C_WS_POLICY_WRITER_H