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 |
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() |
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 |