apicompatanamdw/compatanalysercmd/libraryanalyser/inc/xmldomainmap.hpp
author Maciej Seroka <maciejs@symbian.org>
Thu, 11 Nov 2010 14:03:20 +0000
changeset 26 26ffa9d5444d
parent 0 638b9c697799
permissions -rw-r--r--
Updated knownissues.xml - wk_45_2010
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     1
/*
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     3
* All rights reserved.
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     4
* This component and the accompanying materials are made available
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     6
* which accompanies this distribution, and is available
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     8
*
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
     9
* Initial Contributors:
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    11
*
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    12
* Contributors:
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    13
*
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    14
* Description: 
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    15
*
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    16
*/
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    17
#ifndef XMLDATAMAP
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    18
#define XMLDATAMAP
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    19
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    20
// STL related includes
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    21
#include <stack>
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    22
#include <list>
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    23
//#include <unistd.h>
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    24
using namespace std;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    25
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    26
template<typename T>
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    27
class XMLDomainMap
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    28
{
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    29
     //   typedef T              DomainObject; //satarupa
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    30
	typedef std::stack<T>	DomainObjectStack;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    31
	typedef std::list<T>         DomainObjectList;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    32
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    33
public:
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    34
	XMLDomainMap() {
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    35
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    36
	
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    37
	XMLDomainMap(const XMLDomainMap<T>& rhs) {
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    38
		if(&rhs == this)
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    39
			return;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    40
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    41
		this->operator=(rhs);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    42
		return;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    43
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    44
	
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    45
	virtual ~XMLDomainMap() {
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    46
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    47
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    48
	XMLDomainMap<T>& operator=(const XMLDomainMap<T>& rhs) {
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    49
		if(&rhs == this)
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    50
			return *this;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    51
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    52
		objectStack = rhs.objectStack;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    53
		objectList = rhs.objectList;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    54
		return *this;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    55
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    56
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    57
	// public interface
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    58
	void create(const std::string& name) {
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    59
		T obj(name);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    60
		objectStack.push(obj);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    61
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    62
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    63
	void create(const std::string& name,const std::string& value) {
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    64
		T obj(name,value);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    65
		objectStack.push(obj);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    66
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    67
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    68
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    69
	// called from the endElement method of SAX Handler
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    70
	void add(const std::string& name) {
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    71
		T child = objectStack.top();
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    72
		child.name(name);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    73
		objectStack.pop();
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    74
	
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    75
		if(objectStack.size())
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    76
		{
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    77
			T parent = objectStack.top();
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    78
			objectStack.pop();
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    79
			parent.addChild(child);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    80
			objectStack.push(parent);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    81
		}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    82
		else
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    83
		{
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    84
			objectList.push_back(child);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    85
		}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    86
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    87
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    88
	// called from the characters method of SAX Handler
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    89
	void updateAttribute(const std::string& v)
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    90
	{
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    91
		T obj = objectStack.top();		
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    92
		
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    93
		if((obj!= "headerfile") &&(obj != "library") && (obj != "version"))
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    94
		{
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    95
			objectStack.pop();
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    96
			if((v.c_str()[0] == '&')||(v.c_str()[0] == '>')||(v.c_str()[0] == '<'))
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    97
			{
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    98
				string ws = obj.value();
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
    99
				ws.append(v.data());
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   100
				obj.value(ws);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   101
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   102
			}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   103
			else
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   104
			    obj.value(v);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   105
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   106
			objectStack.push(obj);
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   107
		}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   108
	}
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   109
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   110
	size_t size() 
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   111
        { 
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   112
                return objectList.size(); 
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   113
        }
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   114
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   115
        T& root() 	
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   116
        { 
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   117
		//DomainObjectList::iterator start = objectList.begin();
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   118
               // return *start; 
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   119
                 return *(objectList.begin());
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   120
               
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   121
	}	
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   122
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   123
private:
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   124
	DomainObjectStack	objectStack;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   125
	DomainObjectList	objectList;
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   126
};
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   127
638b9c697799 1. Licenses updated to EPL.
noe\swadi
parents:
diff changeset
   128
#endif // XMLDATAMAP