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; |
426 std::vector<TComponentProperty> iComponentProperties; |
386 std::vector<TComponentFile> iComponentFiles; |
427 std::vector<TComponentFile> iComponentFiles; |
387 TComponentDependency iComponentDependency; |
428 TComponentDependency iComponentDependency; |
388 std::vector<TApplicationRegistrationInfo> iApplicationRegistrationInfo; |
429 std::vector<TApplicationRegistrationInfo> iApplicationRegistrationInfo; |
389 TComponentDetails iComponentDetails; |
430 TComponentDetails iComponentDetails; |
390 }; |
431 }; // class TComponent |
|
432 |
|
433 inline XercesString SoftwareTypeName(); |
391 |
434 |
392 std::wstring iSoftwareTypeName; |
435 std::wstring iSoftwareTypeName; |
393 std::vector<TComponent> iComponents; |
436 std::vector<TComponent> iComponents; |
394 |
437 |
395 }; |
438 }; // class TScrPreProvisionDetail |
396 } |
439 } |
397 |
440 |
398 class CScrXmlParser |
441 class CScrXmlParser |
399 { |
442 { |
400 |
443 |
510 void resetErrors (); |
553 void resetErrors (); |
511 }; |
554 }; |
512 |
555 |
513 XERCES_CPP_NAMESPACE_END |
556 XERCES_CPP_NAMESPACE_END |
514 |
557 |
|
558 // inline function definitions |
|
559 |
|
560 #ifndef _WIN32 |
|
561 inline XercesString WStringToXercesString(const std::wstring& aString) |
|
562 { |
|
563 XMLCh* buffer = new XMLCh[ (aString.length() + 1) * 2 ]; |
|
564 XMLCh* temp = buffer; |
|
565 const wchar_t* source = aString.c_str(); |
|
566 |
|
567 ConvertUCS4toUTF16(&source, source + aString.length(), &temp, buffer + aString.length()); |
|
568 |
|
569 // Appending NUL to the converted buffer. |
|
570 *temp = 0; |
|
571 |
|
572 XercesString result(buffer); |
|
573 delete[] buffer; |
|
574 |
|
575 return result; |
|
576 } |
|
577 |
|
578 #else |
|
579 |
|
580 // We need not do anything for WINDOWS, since XercesString |
|
581 // and WString both are same and will be in UTF-16 encoding format. |
|
582 #define WStringToXercesString(aWString) (aWString) |
|
583 |
|
584 #endif // _WIN32 |
|
585 |
|
586 |
|
587 //------------------------------------------------------------------------------------------------------------------------------ |
|
588 // UTILITY FUNCTIONS |
|
589 //------------------------------------------------------------------------------------------------------------------------------ |
|
590 #ifndef _WIN32 |
|
591 |
|
592 inline std::wstring XercesStringToWString(const XercesString& aString) |
|
593 { |
|
594 wchar_t* buffer = new wchar_t[aString.length() + 1]; |
|
595 const XMLCh* source = aString.c_str(); |
|
596 |
|
597 // Using a temp variable in place of buffer as ConvertUTF16toUTF8 modifies the source pointer passed. |
|
598 wchar_t* temp = buffer; |
|
599 |
|
600 ConvertUTF16toUCS4(&source, source + aString.length(), &temp, temp + aString.length()); |
|
601 |
|
602 // Appending NUL to the converted buffer. |
|
603 *temp = 0; |
|
604 |
|
605 std::wstring result(buffer); |
|
606 delete[] buffer; |
|
607 return result; |
|
608 } |
|
609 #else |
|
610 |
|
611 // We need not do anything for WINDOWS, since XercesString |
|
612 // and WString both are same and will be in UTF-16 encoding format. |
|
613 #define XercesStringToWString(aXercesString) (aXercesString) |
|
614 |
|
615 #endif // _WIN32 |
|
616 |
|
617 |
|
618 //------------------------------------------------------------------------------------------------------------------------------ |
|
619 |
|
620 |
|
621 |
|
622 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::MajorVersion() |
|
623 { |
|
624 #ifdef _WIN32 |
|
625 return iMajor; |
|
626 #else |
|
627 return WStringToXercesString(iMajor); |
|
628 #endif // _WIN32 |
|
629 } |
|
630 |
|
631 |
|
632 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::MinorVersion() |
|
633 { |
|
634 #ifdef _WIN32 |
|
635 return iMinor; |
|
636 #else |
|
637 return WStringToXercesString(iMinor); |
|
638 #endif // _WIN32 |
|
639 } |
|
640 |
|
641 |
|
642 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::BuildVersion() |
|
643 { |
|
644 #ifdef _WIN32 |
|
645 return iBuild; |
|
646 #else |
|
647 return WStringToXercesString(iBuild); |
|
648 #endif // _WIN32 |
|
649 } |
|
650 |
|
651 |
|
652 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::GlobalId() |
|
653 { |
|
654 #ifdef _WIN32 |
|
655 return iGlobalId; |
|
656 #else |
|
657 return WStringToXercesString(iGlobalId); |
|
658 #endif // _WIN32 |
|
659 } |
|
660 |
|
661 |
|
662 inline XercesString XmlDetails::TScrPreProvisionDetail::SoftwareTypeName() |
|
663 { |
|
664 #ifdef _WIN32 |
|
665 return iSoftwareTypeName; |
|
666 #else |
|
667 return WStringToXercesString(iSoftwareTypeName); |
|
668 #endif // _WIN32 |
|
669 } |
|
670 |
|
671 |
|
672 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentLocalizable::Name() |
|
673 { |
|
674 #ifdef _WIN32 |
|
675 return iName; |
|
676 #else |
|
677 return WStringToXercesString(iName); |
|
678 #endif // _WIN32 |
|
679 } |
|
680 |
|
681 |
|
682 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentLocalizable::Vendor() |
|
683 { |
|
684 #ifdef _WIN32 |
|
685 return iVendor; |
|
686 #else |
|
687 return WStringToXercesString(iVendor); |
|
688 #endif // _WIN32 |
|
689 } |
|
690 |
|
691 |
|
692 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentProperty::Name() |
|
693 { |
|
694 #ifdef _WIN32 |
|
695 return iName; |
|
696 #else |
|
697 return WStringToXercesString(iName); |
|
698 #endif // _WIN32 |
|
699 } |
|
700 |
|
701 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentProperty::Value() |
|
702 { |
|
703 #ifdef _WIN32 |
|
704 return iValue; |
|
705 #else |
|
706 return WStringToXercesString(iValue); |
|
707 #endif // _WIN32 |
|
708 } |
|
709 |
|
710 |
|
711 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::Location() |
|
712 { |
|
713 #ifdef _WIN32 |
|
714 return iLocation; |
|
715 #else |
|
716 return WStringToXercesString(iLocation); |
|
717 #endif // _WIN32 |
|
718 } |
|
719 |
|
720 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty::Name() |
|
721 { |
|
722 #ifdef _WIN32 |
|
723 return iName; |
|
724 #else |
|
725 return WStringToXercesString(iName); |
|
726 #endif // _WIN32 |
|
727 } |
|
728 |
|
729 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty::Value() |
|
730 { |
|
731 #ifdef _WIN32 |
|
732 return iValue; |
|
733 #else |
|
734 return WStringToXercesString(iValue); |
|
735 #endif // _WIN32 |
|
736 } |
|
737 |
|
738 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::DependentId() |
|
739 { |
|
740 #ifdef _WIN32 |
|
741 return iDependentId; |
|
742 #else |
|
743 return WStringToXercesString(iDependentId); |
|
744 #endif // _WIN32 |
|
745 } |
|
746 |
|
747 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::SupplierId() |
|
748 { |
|
749 #ifdef _WIN32 |
|
750 return iSupplierId; |
|
751 #else |
|
752 return WStringToXercesString(iSupplierId); |
|
753 #endif // _WIN32 |
|
754 } |
|
755 |
|
756 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::FromVersion() |
|
757 { |
|
758 #ifdef _WIN32 |
|
759 return iFromVersion; |
|
760 #else |
|
761 return WStringToXercesString(iFromVersion); |
|
762 #endif // _WIN32 |
|
763 } |
|
764 |
|
765 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::ToVersion() |
|
766 { |
|
767 #ifdef _WIN32 |
|
768 return iToVersion; |
|
769 #else |
|
770 return WStringToXercesString(iToVersion); |
|
771 #endif // _WIN32 |
|
772 } |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
515 #endif // _XMLPARSER_H |
782 #endif // _XMLPARSER_H |