secureswitools/swisistools/source/xmlparser/xmlparser.h
changeset 60 245df5276b97
parent 25 98b66e4fb0be
child 76 f36d4ce8961e
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
    35 #include <xercesc/parsers/XercesDOMParser.hpp>
    35 #include <xercesc/parsers/XercesDOMParser.hpp>
    36 #include <xercesc/sax/ErrorHandler.hpp>
    36 #include <xercesc/sax/ErrorHandler.hpp>
    37 #include <xercesc/dom/DOM.hpp>
    37 #include <xercesc/dom/DOM.hpp>
    38 
    38 
    39 #include "toolsconf.h"
    39 #include "toolsconf.h"
       
    40 #include "symbiantypes.h"
       
    41 #include "utf8_wrapper.h"
       
    42 
       
    43 // Xerces library uses XMLCh (UTF16 format) as its default character type.
       
    44 // We can store the UTF16 returned form the xerces library in the following
       
    45 // template class.
       
    46 typedef std::basic_string<XMLCh> XercesString;
       
    47 
    40 
    48 
    41 /**
    49 /**
    42 * This template is used to cleanup memory by calling a function as pointed 
    50 * This template is used to cleanup memory by calling a function as pointed 
    43 * by the first parameter as a function parameter. It can be used only used
    51 * by the first parameter as a function parameter. It can be used only used
    44 * with functions which take a pointer to a pointer as an argument. This is 
    52 * with functions which take a pointer to a pointer as an argument. This is 
   142 			std::vector<TLocalizedSoftwareTypeName> iLocalizedSoftwareTypeNames;
   150 			std::vector<TLocalizedSoftwareTypeName> iLocalizedSoftwareTypeNames;
   143 			int iSifPluginUid;
   151 			int iSifPluginUid;
   144             std::wstring iLauncherExecutable;
   152             std::wstring iLauncherExecutable;
   145 			std::vector<TCustomAcessList> iCustomAcessList;
   153 			std::vector<TCustomAcessList> iCustomAcessList;
   146 			std::vector<std::wstring> iMIMEDetails;
   154 			std::vector<std::wstring> iMIMEDetails;
   147 			};
   155 			}; // struct TScrEnvironmentDetails
   148 
   156 
   149 		
   157 		
   150 	class TScrPreProvisionDetail
   158 	class TScrPreProvisionDetail
   151 		{
   159 		{
   152 	public:
   160 	public:
   158 
   166 
   159 		public:
   167 		public:
   160 			TComponentLocalizable()
   168 			TComponentLocalizable()
   161 			:iLocale(0)
   169 			:iLocale(0)
   162 			{}
   170 			{}
   163 			
   171 
       
   172 		public: // public Functions
       
   173 			inline XercesString Name();
       
   174 			inline XercesString Vendor();
       
   175 		
       
   176 		public: // Member variables	
   164 			int iLocale;
   177 			int iLocale;
   165 			std::wstring iName;
   178 			std::wstring iName;
   166 			std::wstring iVendor;
   179 			std::wstring iVendor;
   167 			};
   180 			}; // class TComponentLocalizable
   168 		
   181 		
   169 		class TComponentProperty
   182 		class TComponentProperty
   170 			{
   183 			{
   171 
   184 
   172 		public:
   185 		public:
   174 			:iLocale(0),
   187 			:iLocale(0),
   175 			iIsIntValue(false),
   188 			iIsIntValue(false),
   176 			iIsStr8Bit(false)
   189 			iIsStr8Bit(false)
   177 			{}
   190 			{}
   178 
   191 
   179 		public:
   192 		public: // Member Functions
       
   193 			inline XercesString Name();
       
   194 			inline XercesString Value();
       
   195 
       
   196 		public: // Member variables
   180 			std::wstring iName;
   197 			std::wstring iName;
   181 			int iLocale;
   198 			int iLocale;
   182 			std::wstring iValue;
   199 			std::wstring iValue;
   183 			bool iIsIntValue;
   200 			bool iIsIntValue;
   184 			int iIsStr8Bit;
   201 			int iIsStr8Bit;
   185 			};
   202 			}; // class TComponentProperty
   186 
   203 
   187 		class TComponentDependency
   204 		class TComponentDependency
   188 			{
   205 			{
   189 		public:
   206 		public:
   190 			class TComponentDependencyDetail
   207 			class TComponentDependencyDetail
   191 				{
   208 				{
   192 				public:
   209 				public: // Member Functions
       
   210 					inline XercesString SupplierId();
       
   211 					inline XercesString FromVersion();
       
   212 					inline XercesString ToVersion();
       
   213 
       
   214 				public: // Member Variables
   193 					std::wstring iSupplierId;
   215 					std::wstring iSupplierId;
   194 					std::wstring iFromVersion;
   216 					std::wstring iFromVersion;
   195 					std::wstring iToVersion;
   217 					std::wstring iToVersion;
   196 				};
   218 				}; // class TComponentDependencyDetail
   197 
   219 
   198 			public:
   220 			public: // Member Functions
       
   221 				inline XercesString DependentId();
       
   222 
       
   223 			public: // Member Variables
   199 				std::wstring iDependentId;
   224 				std::wstring iDependentId;
   200 				std::vector<TComponentDependencyDetail>	iComponentDependencyList;
   225 				std::vector<TComponentDependencyDetail>	iComponentDependencyList;
   201 			};
   226 			}; // class TComponentDependency
   202 
   227 
   203 		class TComponentFile
   228 		class TComponentFile
   204 			{
   229 			{
   205 			public:
   230 			public:
   206 			TComponentFile()
   231 			TComponentFile()
   210 				{	
   235 				{	
   211 			public:
   236 			public:
   212 				TFileProperty()
   237 				TFileProperty()
   213 				:iIsIntValue(false)
   238 				:iIsIntValue(false)
   214 				{}
   239 				{}
       
   240 			public: // Member Functions
       
   241 				inline XercesString Name();
       
   242 				inline XercesString Value();
       
   243 	
       
   244 			public: // Member Variables
   215 				std::wstring iName;
   245 				std::wstring iName;
   216 				std::wstring iValue;
   246 				std::wstring iValue;
   217 				bool iIsIntValue;
   247 				bool iIsIntValue;
   218 				};
   248 				}; // struct TFileProperty
   219 
   249 
       
   250 			public: // Member Functions
       
   251 			inline XercesString Location();
       
   252 			
       
   253 			public: // Member Variables
   220 			std::wstring iLocation;
   254 			std::wstring iLocation;
   221 			std::vector<TFileProperty> iFileProperties;
   255 			std::vector<TFileProperty> iFileProperties;
   222 			
   256 			
   223 			};
   257 			}; // class TComponentFile
   224 		
   258 		
   225 		class TComponentDetails
   259 		class TComponentDetails
   226 			{
   260 			{
   227 			public:
   261 			public:
   228 			TComponentDetails()
   262 			TComponentDetails()
   239 				{
   273 				{
   240 			public:
   274 			public:
   241 
   275 
   242 				TVersion()
   276 				TVersion()
   243 				{}
   277 				{}
       
   278 			public:
       
   279 				inline XercesString MajorVersion();
       
   280 				inline XercesString MinorVersion();
       
   281 				inline XercesString BuildVersion();
   244 
   282 
   245 			public:
   283 			public:
   246 				std::wstring iMajor;
   284 				std::wstring iMajor;
   247 				std::wstring iMinor;
   285 				std::wstring iMinor;
   248 				std::wstring iBuild;
   286 				std::wstring iBuild;
   249 				};
   287 				}; // class TVersion
       
   288 
       
   289 			public: // Member Functions
       
   290 			inline XercesString GlobalId();
   250 
   291 
   251 			int iIsRomApplication;
   292 			int iIsRomApplication;
   252 			int iIsRemovable;
   293 			int iIsRemovable;
   253 			__int64 iSize;
   294 			TInt64 iSize;
   254 			int iScomoState;
   295 			int iScomoState;
   255 			std::wstring iGlobalId;
   296 			std::wstring iGlobalId;
   256 			TVersion iVersion;
   297 			TVersion iVersion;
   257 			int iOriginVerified;
   298 			int iOriginVerified;
   258 			int iIsHidden;
   299 			int iIsHidden;
   288 
   329 
   289 				class TOpaqueDataType
   330 				class TOpaqueDataType
   290 					{
   331 					{
   291 					public:
   332 					public:
   292 					TOpaqueDataType()
   333 					TOpaqueDataType()
   293 					:iLocale(0)
   334 					:iLocale(0),
       
   335 					iIsBinary(false)
   294 					{}
   336 					{}
   295 					int iLocale;
   337 					int iLocale;
   296 					int iServiceUid;
   338 					int iServiceUid;
       
   339 					bool iIsBinary; 
   297 					std::wstring iOpaqueData;
   340 					std::wstring iOpaqueData;
   298 					};
   341 					};
   299 
   342 
   300 				class TAppServiceInfo
   343 				class TAppServiceInfo
   301 					{
   344 					{
   385 			std::vector<TComponentProperty>		iComponentProperties;
   428 			std::vector<TComponentProperty>		iComponentProperties;
   386 			std::vector<TComponentFile>			iComponentFiles;
   429 			std::vector<TComponentFile>			iComponentFiles;
   387 			TComponentDependency iComponentDependency;
   430 			TComponentDependency iComponentDependency;
   388 			std::vector<TApplicationRegistrationInfo> iApplicationRegistrationInfo;
   431 			std::vector<TApplicationRegistrationInfo> iApplicationRegistrationInfo;
   389 			TComponentDetails iComponentDetails;
   432 			TComponentDetails iComponentDetails;
   390 			};
   433 			}; // class TComponent
       
   434 
       
   435 		inline XercesString SoftwareTypeName();
   391 
   436 
   392 		std::wstring iSoftwareTypeName;
   437 		std::wstring iSoftwareTypeName;
   393 		std::vector<TComponent> iComponents;
   438 		std::vector<TComponent> iComponents;
   394 		
   439 		
   395 		};
   440 		}; // class TScrPreProvisionDetail
   396 }
   441 }
   397 
   442 
   398 class CScrXmlParser
   443 class CScrXmlParser
   399 	{
   444 	{
   400 
   445 
   510 		void resetErrors ();
   555 		void resetErrors ();
   511 	};
   556 	};
   512 
   557 
   513 XERCES_CPP_NAMESPACE_END
   558 XERCES_CPP_NAMESPACE_END
   514 
   559 
       
   560 // inline function definitions
       
   561 
       
   562 #ifndef _WIN32
       
   563 inline XercesString WStringToXercesString(const std::wstring& aString)
       
   564 	{
       
   565 	XMLCh* buffer = new XMLCh[ (aString.length() + 1) * 2 ];
       
   566 	XMLCh* temp = buffer;
       
   567 	const wchar_t* source = aString.c_str();
       
   568 
       
   569 	ConvertUCS4toUTF16(&source, source + aString.length(), &temp, buffer + aString.length());
       
   570 
       
   571 	// Appending NUL to the converted buffer.
       
   572 	*temp = 0;
       
   573 
       
   574 	XercesString result(buffer);
       
   575 	delete[] buffer;
       
   576 
       
   577 	return result; 
       
   578 	}
       
   579 
       
   580 #else
       
   581 
       
   582 // We need not do anything for WINDOWS, since XercesString
       
   583 // and WString both are same and will be in UTF-16 encoding format.
       
   584 #define WStringToXercesString(aWString) (aWString)
       
   585 
       
   586 #endif // _WIN32
       
   587 
       
   588 
       
   589 //------------------------------------------------------------------------------------------------------------------------------
       
   590 //											UTILITY FUNCTIONS
       
   591 //------------------------------------------------------------------------------------------------------------------------------
       
   592 #ifndef _WIN32
       
   593 
       
   594 inline std::wstring XercesStringToWString(const XercesString& aString)
       
   595 	{
       
   596 	wchar_t* buffer = new wchar_t[aString.length() + 1];
       
   597 	const XMLCh* source = aString.c_str();
       
   598 
       
   599 	// Using a temp variable in place of buffer as ConvertUTF16toUTF8 modifies the source pointer passed.
       
   600 	wchar_t* temp = buffer;
       
   601 
       
   602 	ConvertUTF16toUCS4(&source, source + aString.length(), &temp, temp + aString.length());
       
   603 
       
   604 	// Appending NUL to the converted buffer.
       
   605 	*temp = 0;
       
   606 
       
   607 	std::wstring result(buffer);
       
   608 	delete[] buffer;
       
   609 	return result;
       
   610 	}
       
   611 #else
       
   612 
       
   613 // We need not do anything for WINDOWS, since XercesString
       
   614 // and WString both are same and will be in UTF-16 encoding format.
       
   615 #define XercesStringToWString(aXercesString) (aXercesString)
       
   616 
       
   617 #endif // _WIN32
       
   618 
       
   619 
       
   620 //------------------------------------------------------------------------------------------------------------------------------
       
   621 
       
   622 
       
   623 
       
   624 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::MajorVersion()
       
   625 {
       
   626 #ifdef _WIN32
       
   627 	return iMajor;
       
   628 #else
       
   629 	return WStringToXercesString(iMajor);
       
   630 #endif // _WIN32
       
   631 }
       
   632 
       
   633 
       
   634 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::MinorVersion()
       
   635 {
       
   636 #ifdef _WIN32
       
   637 	return iMinor;
       
   638 #else
       
   639 	return WStringToXercesString(iMinor);
       
   640 #endif // _WIN32
       
   641 }
       
   642 
       
   643 
       
   644 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::BuildVersion()
       
   645 {
       
   646 #ifdef _WIN32
       
   647 	return iBuild;
       
   648 #else
       
   649 	return WStringToXercesString(iBuild);
       
   650 #endif // _WIN32
       
   651 }
       
   652 
       
   653 
       
   654 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::GlobalId()
       
   655 {
       
   656 #ifdef _WIN32
       
   657 	return iGlobalId;
       
   658 #else  
       
   659 	return WStringToXercesString(iGlobalId);
       
   660 #endif // _WIN32
       
   661 }
       
   662 
       
   663 
       
   664 inline XercesString XmlDetails::TScrPreProvisionDetail::SoftwareTypeName()
       
   665 	{
       
   666 #ifdef _WIN32
       
   667 	return iSoftwareTypeName;
       
   668 #else
       
   669 	return WStringToXercesString(iSoftwareTypeName);
       
   670 #endif // _WIN32
       
   671 	}
       
   672 
       
   673 
       
   674 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentLocalizable::Name()
       
   675 	{
       
   676 #ifdef _WIN32
       
   677 	return iName;
       
   678 #else
       
   679 	return WStringToXercesString(iName);
       
   680 #endif // _WIN32
       
   681 	}
       
   682 
       
   683 
       
   684 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentLocalizable::Vendor()
       
   685 	{
       
   686 #ifdef _WIN32
       
   687 	return iVendor;
       
   688 #else
       
   689 	return WStringToXercesString(iVendor);
       
   690 #endif // _WIN32
       
   691 	}
       
   692 
       
   693 
       
   694 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentProperty::Name()
       
   695 	{
       
   696 #ifdef _WIN32
       
   697 	return iName;
       
   698 #else
       
   699 	return WStringToXercesString(iName);
       
   700 #endif // _WIN32
       
   701 	}
       
   702 
       
   703 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentProperty::Value()
       
   704 	{
       
   705 #ifdef _WIN32
       
   706 	return iValue;
       
   707 #else
       
   708 	return WStringToXercesString(iValue);
       
   709 #endif // _WIN32
       
   710 	}
       
   711 
       
   712 
       
   713 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::Location()
       
   714 	{
       
   715 #ifdef _WIN32
       
   716 	return iLocation;
       
   717 #else
       
   718 	return WStringToXercesString(iLocation);
       
   719 #endif // _WIN32
       
   720 	}
       
   721 
       
   722 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty::Name()
       
   723 	{
       
   724 #ifdef _WIN32
       
   725 	return iName;
       
   726 #else
       
   727 	return WStringToXercesString(iName);
       
   728 #endif // _WIN32
       
   729 	}
       
   730 
       
   731 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty::Value()
       
   732 	{
       
   733 #ifdef _WIN32
       
   734 	return iValue;
       
   735 #else
       
   736 	return WStringToXercesString(iValue);
       
   737 #endif // _WIN32
       
   738 	}
       
   739 
       
   740 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::DependentId()
       
   741 	{
       
   742 #ifdef _WIN32
       
   743 	return iDependentId;
       
   744 #else
       
   745 	return WStringToXercesString(iDependentId);
       
   746 #endif // _WIN32
       
   747 	}
       
   748 
       
   749 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::SupplierId()
       
   750 	{
       
   751 #ifdef _WIN32
       
   752 	return iSupplierId;
       
   753 #else
       
   754 	return WStringToXercesString(iSupplierId);
       
   755 #endif // _WIN32
       
   756 	}
       
   757 
       
   758 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::FromVersion()
       
   759 	{
       
   760 #ifdef _WIN32
       
   761 	return iFromVersion;
       
   762 #else
       
   763 	return WStringToXercesString(iFromVersion);
       
   764 #endif // _WIN32
       
   765 	}
       
   766 
       
   767 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::ToVersion()
       
   768 	{
       
   769 #ifdef _WIN32
       
   770 	return iToVersion;
       
   771 #else
       
   772 	return WStringToXercesString(iToVersion);
       
   773 #endif // _WIN32
       
   774 	}
       
   775 
       
   776 
       
   777 
       
   778 
       
   779 
       
   780 
       
   781 
       
   782 
       
   783 
   515 #endif // _XMLPARSER_H
   784 #endif // _XMLPARSER_H