apicompatanamdw/compatanalysercmd/libraryanalyser/inc/xmlsaxHandler.hpp
changeset 0 638b9c697799
equal deleted inserted replaced
-1:000000000000 0:638b9c697799
       
     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: 
       
    15 *
       
    16 */
       
    17 #include <xercesc/sax/HandlerBase.hpp>
       
    18 #include <xercesc/sax/AttributeList.hpp>
       
    19 #include <xercesc/util/PlatformUtils.hpp>
       
    20 #include "xmlstringtostlstring.hpp"
       
    21 
       
    22 #if !defined XMLSAXHANDLER
       
    23 	#define  XMLSAXHANDLER
       
    24 
       
    25 // Forward Reference
       
    26 //class AttributeList;
       
    27 class XMLNode;
       
    28 
       
    29 // T - Domain Map
       
    30 template<typename T>
       
    31 class XMLSAXHandler : public HandlerBase
       
    32 {
       
    33 	typedef T*	root;
       
    34 public:
       
    35 	XMLSAXHandler();
       
    36 	virtual ~XMLSAXHandler();
       
    37 
       
    38 	T& getDomainMap() { return dataMap; }
       
    39 
       
    40 	XMLNode& getRootElement() { return dataMap.root(); }
       
    41 	
       
    42 	// Handlers for the SAX DocumentHandler interface
       
    43 	virtual void startElement(const XMLCh* const name, AttributeList& attributes);
       
    44 	virtual void characters(const XMLCh* const chars, const unsigned int length);
       
    45 	virtual void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
       
    46 	virtual void endElement(const XMLCh* const name);
       
    47 //	void ignoreElement(const XMLCh* const aName);
       
    48 
       
    49 private:
       
    50 	// Private data members
       
    51 	T		dataMap;
       
    52 //	T name ;
       
    53 };
       
    54 
       
    55 template<typename T>
       
    56 XMLSAXHandler<T>::XMLSAXHandler()
       
    57 {
       
    58 }
       
    59 
       
    60 template<typename T>
       
    61 XMLSAXHandler<T>::~XMLSAXHandler()
       
    62 {
       
    63 }
       
    64 
       
    65 //  SAXParser: Implementation of the SAX DocumentHandler interface
       
    66 template<typename T>
       
    67 void XMLSAXHandler<T>::startElement(const XMLCh* const name, AttributeList&  attributes)
       
    68 {
       
    69 	XMLStringToSTLString str(name);
       
    70 	const XMLCh* value = NULL;
       
    71 
       
    72 		int length = attributes.getLength();
       
    73 		for(int i=0;i<length;i++)
       
    74 		{
       
    75 			value = attributes.getValue(i);
       
    76 		}
       
    77 		if (value)
       
    78 		{
       
    79                         XMLStringToSTLString val(value);
       
    80 			dataMap.create(str.data(),val.data());
       
    81 		}
       
    82 		else
       
    83 			dataMap.create(str.data());
       
    84 
       
    85 //	}
       
    86 }
       
    87 
       
    88 template<typename T>
       
    89 void XMLSAXHandler<T>::endElement(const XMLCh* const name)
       
    90 {
       
    91 	XMLStringToSTLString str(name);
       
    92 	dataMap.add(str.data());
       
    93 }
       
    94 
       
    95 template<typename T>
       
    96 void XMLSAXHandler<T>::characters(const XMLCh* const chars, const unsigned length)
       
    97 {
       
    98         XMLStringToSTLString str(chars);
       
    99 	dataMap.updateAttribute(str.data());
       
   100 }
       
   101 
       
   102 template<typename T>
       
   103 void XMLSAXHandler<T>::ignorableWhitespace( const XMLCh* const chars, const unsigned int length)
       
   104 {
       
   105 }
       
   106 /*
       
   107 template<typename T>
       
   108 void XMLSAXHandler<T>::ignoreElement(const XMLCh* const aName)
       
   109 {
       
   110 	name = aName;
       
   111 }*/
       
   112 
       
   113 #endif // XMLSAXHANDLER