579 COpaqueNamedParams* self = new (ELeave) COpaqueNamedParams; |
582 COpaqueNamedParams* self = new (ELeave) COpaqueNamedParams; |
580 CleanupStack::PushL(self); |
583 CleanupStack::PushL(self); |
581 return self; |
584 return self; |
582 } |
585 } |
583 |
586 |
584 void COpaqueNamedParams::VerifyExternalizedSizeForNewParamL(TInt aNameSize, TInt aValueSize) const |
587 void COpaqueNamedParams::VerifyExternalizedSizeForNewParamArrayL(TInt aNameSize, TInt aValueSize) const |
585 { |
588 { |
586 const TInt load = 2*sizeof(TInt) + aNameSize + aValueSize; |
589 const TInt load = 2*sizeof(TInt) + aNameSize + aValueSize; |
587 if (aNameSize > KMaxDescriptorLength || aValueSize > KMaxDescriptorLength || |
590 if (aNameSize > KMaxOpaqueParamsDescriptorSize || iExternalizedSize + load > KMaxOpaqueParamsExternalizedSize) |
588 iExternalizedSize + load > KMaxExternalizedSize) |
|
589 { |
591 { |
590 User::Leave(KErrOverflow); |
592 User::Leave(KErrOverflow); |
591 } |
593 } |
592 iExternalizedSize += load; |
594 iExternalizedSize += load; |
593 } |
595 } |
594 |
596 |
595 void COpaqueNamedParams::VerifyExternalizedSizeForExistingParamL(TInt aOldValueSize, TInt aNewValueSize) const |
597 void COpaqueNamedParams::VerifyExternalizedSizeForExistingParamArrayL(TInt aOldValueSize, TInt aNewValueSize) const |
596 { |
598 { |
597 const TInt diff = aNewValueSize - aOldValueSize; |
599 const TInt diff = aNewValueSize - aOldValueSize; |
598 if (aNewValueSize > KMaxDescriptorLength || |
600 if (iExternalizedSize + diff > KMaxOpaqueParamsExternalizedSize) |
599 iExternalizedSize + diff > KMaxExternalizedSize) |
|
600 { |
601 { |
601 User::Leave(KErrOverflow); |
602 User::Leave(KErrOverflow); |
602 } |
603 } |
603 iExternalizedSize += diff; |
604 iExternalizedSize += diff; |
604 } |
605 } |
605 |
606 |
606 EXPORT_C void COpaqueNamedParams::AddStringL(const TDesC& aName, const TDesC& aValue) |
607 EXPORT_C void COpaqueNamedParams::AddStringL(const TDesC& aName, const TDesC& aValue) |
607 { |
608 { |
608 HBufC* value = HBufC::NewLC(aValue.Length()); |
609 CStringItem* stringItem = CStringItem::NewL(aName, aValue); |
609 TPtr bufValue(value->Des()); |
610 CleanupStack::PushL(stringItem); |
610 bufValue.Copy(aValue); |
611 |
|
612 AddOpaqueParamL(stringItem); |
|
613 CleanupStack::Pop(stringItem); |
|
614 } |
|
615 |
|
616 EXPORT_C void COpaqueNamedParams::AddStringArrayL(const TDesC& aName, const RPointerArray<HBufC>& aValueArray) |
|
617 { |
|
618 CStringArrayItem* stringArray = CStringArrayItem::NewL(aName, aValueArray); |
|
619 CleanupStack::PushL(stringArray); |
|
620 |
|
621 AddOpaqueParamL(stringArray); |
|
622 CleanupStack::Pop(stringArray); |
|
623 } |
|
624 |
|
625 EXPORT_C void COpaqueNamedParams::AddIntL(const TDesC& aName, TInt aValue) |
|
626 { |
|
627 CIntegerItem* integer = CIntegerItem::NewL(aName, aValue); |
|
628 CleanupStack::PushL(integer); |
|
629 |
|
630 AddOpaqueParamL(integer); |
|
631 CleanupStack::Pop(integer); |
|
632 } |
|
633 |
|
634 EXPORT_C void COpaqueNamedParams::AddIntArrayL(const TDesC& aName, const RArray<TInt>& aValueArray) |
|
635 { |
|
636 CIntegerArrayItem* integerArray = CIntegerArrayItem::NewL(aName, aValueArray); |
|
637 CleanupStack::PushL(integerArray); |
|
638 |
|
639 AddOpaqueParamL(integerArray); |
|
640 CleanupStack::Pop(integerArray); |
|
641 } |
|
642 |
|
643 void COpaqueNamedParams::AddOpaqueParamL(MOpaqueParam* aItemBase) |
|
644 { |
|
645 const TInt count = iParams.Count(); |
|
646 |
|
647 for (TInt i=0; i<count; ++i) |
|
648 { |
|
649 if (iParams[i]->Name().CompareF(aItemBase->Name()) == 0) |
|
650 { |
|
651 VerifyExternalizedSizeForExistingParamArrayL(iParams[i]->ValueSize(), aItemBase->ValueSize()); |
|
652 |
|
653 delete iParams[i]; |
|
654 iParams[i] = aItemBase; |
|
655 return; |
|
656 } |
|
657 } |
|
658 |
|
659 VerifyExternalizedSizeForNewParamArrayL(aItemBase->Name().Size(), aItemBase->ValueSize()); |
|
660 iParams.AppendL(aItemBase); |
|
661 } |
|
662 |
|
663 EXPORT_C void COpaqueNamedParams::GetNamesL(RPointerArray<HBufC>& aNames) const |
|
664 { |
|
665 InternalizeFromExternalBufferL(); |
611 |
666 |
612 const TInt len = iParams.Count(); |
667 const TInt len = iParams.Count(); |
613 for (TInt i=0; i<len; ++i) |
668 for (TInt i=0; i<len; ++i) |
614 { |
669 { |
615 if (iParams[i].iName->CompareF(aName) == 0) |
670 HBufC* name = iParams[i]->Name().AllocLC(); |
616 { |
|
617 VerifyExternalizedSizeForExistingParamL(iParams[i].iValue->Size(), value->Size()); |
|
618 delete iParams[i].iValue; |
|
619 iParams[i].iValue = value; |
|
620 CleanupStack::Pop(value); |
|
621 return; |
|
622 } |
|
623 } |
|
624 |
|
625 VerifyExternalizedSizeForNewParamL(aName.Size(), aValue.Size()); |
|
626 |
|
627 HBufC* name = HBufC::NewLC(aName.Length()); |
|
628 TPtr bufName(name->Des()); |
|
629 bufName.Copy(aName); |
|
630 |
|
631 TItem item = {name, value}; |
|
632 iParams.AppendL(item); |
|
633 |
|
634 CleanupStack::Pop(2, value); |
|
635 } |
|
636 |
|
637 EXPORT_C void COpaqueNamedParams::AddIntL(const TDesC& aName, TInt aValue) |
|
638 { |
|
639 // Assumption: the code below won't be compiled in __KERNEL_MODE__ so HBufC is always defined as HBufC16 |
|
640 TBuf<sizeof(TInt)/2> buf; |
|
641 buf.Copy(reinterpret_cast<TUint16*>(&aValue), sizeof(TInt)/2); |
|
642 AddStringL(aName, buf); |
|
643 } |
|
644 |
|
645 EXPORT_C void COpaqueNamedParams::GetNamesL(RPointerArray<HBufC>& aNames) const |
|
646 { |
|
647 InternalizeFromExternalBufferL(); |
|
648 |
|
649 const TInt len = iParams.Count(); |
|
650 for (TInt i=0; i<len; ++i) |
|
651 { |
|
652 const TDesC& ref = *iParams[i].iName; |
|
653 HBufC* name = HBufC::NewLC(ref.Length()); |
|
654 TPtr bufName(name->Des()); |
|
655 bufName.Copy(ref); |
|
656 aNames.AppendL(name); |
671 aNames.AppendL(name); |
657 CleanupStack::Pop(name); |
672 CleanupStack::Pop(name); |
658 } |
673 } |
659 } |
674 } |
660 |
675 |
661 EXPORT_C void COpaqueNamedParams::ExternalizeL(RWriteStream& aStream) const |
676 EXPORT_C void COpaqueNamedParams::ExternalizeL(RWriteStream& aStream) const |
662 { |
677 { |
663 InternalizeFromExternalBufferL(); |
678 InternalizeFromExternalBufferL(); |
664 |
679 |
665 TInt len = iParams.Count(); |
680 TInt count = iParams.Count(); |
666 aStream.WriteInt32L(len); |
681 aStream.WriteInt32L(count); |
667 for (TInt i=0; i<len; ++i) |
682 for (TInt i=0; i<count; ++i) |
668 { |
683 { |
669 aStream << *iParams[i].iName; |
684 aStream.WriteInt32L(iParams[i]->Type()); |
670 aStream << *iParams[i].iValue; |
685 iParams[i]->ExternalizeL(aStream); |
671 } |
686 } |
|
687 |
|
688 aStream.WriteInt32L(iExternalizedSize); |
672 } |
689 } |
673 |
690 |
674 EXPORT_C void COpaqueNamedParams::InternalizeL(RReadStream& aStream) |
691 EXPORT_C void COpaqueNamedParams::InternalizeL(RReadStream& aStream) |
675 { |
692 { |
676 Cleanup(); |
|
677 ConstInternalizeL(aStream); |
693 ConstInternalizeL(aStream); |
678 } |
694 } |
679 |
695 |
680 void COpaqueNamedParams::ConstInternalizeL(RReadStream& aStream) const |
696 void COpaqueNamedParams::ConstInternalizeL(RReadStream& aStream) const |
681 { |
697 { |
682 RArray<TItem>& refParams = const_cast<RArray<TItem>&>(iParams); |
698 ConstCleanup(); |
683 |
699 RPointerArray<MOpaqueParam>& refParams = const_cast<RPointerArray<MOpaqueParam>& >(iParams); |
684 TInt len = aStream.ReadInt32L(); |
700 |
685 for (TInt i=0; i<len; ++i) |
701 TInt count = aStream.ReadInt32L(); |
686 { |
702 for (TInt i=0; i<count; ++i) |
687 HBufC* name = HBufC::NewLC(aStream, KMaxDescriptorLength); |
703 { |
688 HBufC* value = HBufC::NewLC(aStream, KMaxDescriptorLength); |
704 MOpaqueParam::TType type = static_cast<MOpaqueParam::TType>(aStream.ReadInt32L()); |
689 |
705 MOpaqueParam* param(0); |
690 // We need to update iExternalizedSize here because its value must correspond to the params beind added from aStream |
706 switch(type) |
691 VerifyExternalizedSizeForNewParamL(name->Size(), value->Size()); |
707 { |
692 |
708 case MOpaqueParam::EString: |
693 TItem item = {name, value}; |
709 param = CStringItem::NewL(aStream); |
694 refParams.AppendL(item); |
710 break; |
695 |
711 |
696 CleanupStack::Pop(2, name); |
712 case MOpaqueParam::EStringArray: |
697 } |
713 param = CStringArrayItem::NewL(aStream); |
|
714 break; |
|
715 |
|
716 case MOpaqueParam::EInteger: |
|
717 param = CIntegerItem::NewL(aStream); |
|
718 break; |
|
719 |
|
720 case MOpaqueParam::EIntegerArray: |
|
721 param = CIntegerArrayItem::NewL(aStream); |
|
722 break; |
|
723 |
|
724 default: |
|
725 User::Leave(KErrCorrupt); |
|
726 } |
|
727 CleanupStack::PushL(param); |
|
728 refParams.AppendL(param); |
|
729 CleanupStack::Pop(param); |
|
730 } |
|
731 |
|
732 iExternalizedSize = aStream.ReadInt32L(); |
698 } |
733 } |
699 |
734 |
700 EXPORT_C void COpaqueNamedParams::PrepareArgumentsForIpcL(TIpcArgs& aIpcArgs, TInt aIndex) const |
735 EXPORT_C void COpaqueNamedParams::PrepareArgumentsForIpcL(TIpcArgs& aIpcArgs, TInt aIndex) const |
701 { |
736 { |
702 delete iExternalBuffer; |
737 delete iExternalBuffer; |
749 |
782 |
750 EXPORT_C const TDesC& COpaqueNamedParams::StringByNameL(const TDesC& aName) const |
783 EXPORT_C const TDesC& COpaqueNamedParams::StringByNameL(const TDesC& aName) const |
751 { |
784 { |
752 InternalizeFromExternalBufferL(); |
785 InternalizeFromExternalBufferL(); |
753 |
786 |
754 const TInt len = iParams.Count(); |
787 const TInt count = iParams.Count(); |
755 for (TInt i=0; i<len; ++i) |
788 for (TInt i=0; i<count; ++i) |
756 { |
789 { |
757 if (iParams[i].iName->CompareF(aName) == 0) |
790 if (iParams[i]->Type() == MOpaqueParam::EString && iParams[i]->Name().CompareF(aName) == 0) |
758 { |
791 { |
759 return *iParams[i].iValue; |
792 CStringItem* string = static_cast<CStringItem*>(iParams[i]); |
|
793 return string->StringValue(); |
760 } |
794 } |
761 } |
795 } |
|
796 |
762 return KNullDesC; |
797 return KNullDesC; |
763 } |
798 } |
764 |
799 |
|
800 EXPORT_C const RPointerArray<HBufC>& COpaqueNamedParams::StringArrayByNameL(const TDesC& aName) const |
|
801 { |
|
802 InternalizeFromExternalBufferL(); |
|
803 |
|
804 const TInt count = iParams.Count(); |
|
805 TInt i; |
|
806 for (i=0; i<count; ++i) |
|
807 { |
|
808 if (iParams[i]->Type() == MOpaqueParam::EStringArray && iParams[i]->Name().CompareF(aName) == 0) |
|
809 { |
|
810 break; |
|
811 } |
|
812 } |
|
813 |
|
814 if(i == count) |
|
815 { |
|
816 User::Leave(KErrNotFound); |
|
817 } |
|
818 CStringArrayItem* stringArray = static_cast<CStringArrayItem*>(iParams[i]); |
|
819 return stringArray->StringArrayValue(); |
|
820 } |
|
821 |
765 EXPORT_C TBool COpaqueNamedParams::GetIntByNameL(const TDesC& aName, TInt& aValue) const |
822 EXPORT_C TBool COpaqueNamedParams::GetIntByNameL(const TDesC& aName, TInt& aValue) const |
766 { |
823 { |
767 InternalizeFromExternalBufferL(); |
824 InternalizeFromExternalBufferL(); |
768 |
825 |
769 const TDesC& value = StringByNameL(aName); |
826 const TInt count = iParams.Count(); |
770 if (value == KNullDesC) |
827 for (TInt i=0; i<count; ++i) |
771 { |
828 { |
772 return EFalse; |
829 if (iParams[i]->Type() == MOpaqueParam::EInteger && iParams[i]->Name().CompareF(aName) == 0) |
773 } |
830 { |
774 aValue = *(reinterpret_cast<const TUint*>(value.Ptr())); |
831 CIntegerItem* integer = static_cast<CIntegerItem*>(iParams[i]); |
775 return ETrue; |
832 aValue = integer->IntegerValue(); |
|
833 return ETrue; |
|
834 } |
|
835 } |
|
836 |
|
837 return EFalse; |
776 } |
838 } |
777 |
839 |
778 EXPORT_C TInt COpaqueNamedParams::IntByNameL(const TDesC& aName) const |
840 EXPORT_C TInt COpaqueNamedParams::IntByNameL(const TDesC& aName) const |
779 { |
841 { |
780 InternalizeFromExternalBufferL(); |
842 InternalizeFromExternalBufferL(); |
799 } |
883 } |
800 |
884 |
801 void COpaqueNamedParams::ConstCleanup() const |
885 void COpaqueNamedParams::ConstCleanup() const |
802 { |
886 { |
803 // Cleanup internal params |
887 // Cleanup internal params |
804 iExternalizedSize = sizeof(TInt); |
888 iExternalizedSize = 2*sizeof(TInt); |
805 |
889 |
806 const TInt len = iParams.Count(); |
890 RPointerArray<MOpaqueParam>& refParams = const_cast<RPointerArray<MOpaqueParam>&>(iParams); |
807 for (TInt i=0; i<len; ++i) |
891 refParams.ResetAndDestroy(); |
808 { |
|
809 delete iParams[i].iName; |
|
810 delete iParams[i].iValue; |
|
811 } |
|
812 RArray<TItem>& refParams = const_cast<RArray<TItem>&>(iParams); |
|
813 refParams.Reset(); |
|
814 } |
892 } |
815 |
893 |
816 void COpaqueNamedParams::CleanupExternalBuffer() const |
894 void COpaqueNamedParams::CleanupExternalBuffer() const |
817 { |
895 { |
818 delete iExternalBuffer; |
896 delete iExternalBuffer; |
819 iExternalBuffer = NULL; |
897 iExternalBuffer = NULL; |
820 iDeferredInternalization = EFalse; |
898 iDeferredInternalization = EFalse; |
821 } |
899 } |
|
900 |
|
901 |
|
902 /* |
|
903 * SifCommon internal classes |
|
904 */ |
|
905 |
|
906 |
|
907 CItemBase::CItemBase(TType aType): |
|
908 iType(aType) |
|
909 { |
|
910 |
|
911 } |
|
912 |
|
913 CItemBase::TType CItemBase::Type() const |
|
914 { |
|
915 return iType; |
|
916 } |
|
917 |
|
918 void CItemBase::SetNameL(const TDesC& aName) |
|
919 { |
|
920 delete iName; |
|
921 iName = aName.AllocL(); |
|
922 } |
|
923 |
|
924 |
|
925 CItemBase::~CItemBase() |
|
926 { |
|
927 delete iName; |
|
928 } |
|
929 |
|
930 const HBufC& CItemBase::Name() const |
|
931 { |
|
932 return *iName; |
|
933 } |
|
934 |
|
935 void CItemBase::SetValueSize(TInt aSize) |
|
936 { |
|
937 iSize = aSize; |
|
938 } |
|
939 |
|
940 TInt CItemBase::ValueSize() const |
|
941 { |
|
942 return iSize; |
|
943 } |
|
944 |
|
945 void CItemBase::VerifyExternalizedSizeForParamL(TUint aValueSize) const |
|
946 { |
|
947 if(aValueSize > KMaxOpaqueParamsDescriptorSize) |
|
948 { |
|
949 User::Leave(KErrOverflow); |
|
950 } |
|
951 } |
|
952 |
|
953 void CItemBase::ExternalizeL(RWriteStream& aStream) const |
|
954 { |
|
955 aStream << Name(); |
|
956 aStream.WriteInt32L(iSize); |
|
957 } |
|
958 |
|
959 void CItemBase::InternalizeL (RReadStream& aStream) |
|
960 { |
|
961 delete iName; |
|
962 iName = HBufC::NewL(aStream, KMaxOpaqueParamsDescriptorSize); |
|
963 iSize = aStream.ReadInt32L(); |
|
964 } |
|
965 |
|
966 /* |
|
967 * CStringItem |
|
968 */ |
|
969 CStringItem::CStringItem(): |
|
970 CItemBase(EString) |
|
971 { |
|
972 |
|
973 } |
|
974 |
|
975 CStringItem* CStringItem::NewL(const TDesC& aName, const TDesC& aValue) |
|
976 { |
|
977 CStringItem* self = new(ELeave)CStringItem(); |
|
978 CleanupStack::PushL(self); |
|
979 self->ConstructL(aName, aValue); |
|
980 CleanupStack::Pop(self); |
|
981 return self; |
|
982 } |
|
983 |
|
984 CStringItem* CStringItem::NewL(RReadStream& aStream) |
|
985 { |
|
986 CStringItem *self = new(ELeave)CStringItem(); |
|
987 CleanupStack::PushL(self); |
|
988 self->InternalizeL(aStream); |
|
989 CleanupStack::Pop(self); |
|
990 return self; |
|
991 } |
|
992 |
|
993 void CStringItem::ConstructL(const TDesC& aName, const TDesC& aValue) |
|
994 { |
|
995 VerifyExternalizedSizeForParamL(aValue.Size()); |
|
996 SetNameL(aName); |
|
997 iString = aValue.AllocL(); |
|
998 SetValueSize(iString->Size()); |
|
999 } |
|
1000 |
|
1001 CStringItem::~CStringItem() |
|
1002 { |
|
1003 delete iString; |
|
1004 } |
|
1005 |
|
1006 void CStringItem::ExternalizeL(RWriteStream& aStream) const |
|
1007 { |
|
1008 CItemBase::ExternalizeL(aStream); |
|
1009 aStream << *iString; |
|
1010 } |
|
1011 |
|
1012 void CStringItem::InternalizeL(RReadStream& aStream) |
|
1013 { |
|
1014 CItemBase::InternalizeL(aStream); |
|
1015 delete iString; |
|
1016 iString = HBufC::NewL(aStream, KMaxOpaqueParamsDescriptorSize); |
|
1017 } |
|
1018 |
|
1019 const TDesC& CStringItem::StringValue() const |
|
1020 { |
|
1021 return *iString; |
|
1022 } |
|
1023 |
|
1024 const HBufC& CStringItem::Name() const |
|
1025 { |
|
1026 return CItemBase::Name(); |
|
1027 } |
|
1028 |
|
1029 MOpaqueParam::TType CStringItem::Type() const |
|
1030 { |
|
1031 return CItemBase::Type(); |
|
1032 } |
|
1033 |
|
1034 TInt CStringItem::ValueSize() const |
|
1035 { |
|
1036 return CItemBase::ValueSize(); |
|
1037 } |
|
1038 /* |
|
1039 * CStringArrayItem |
|
1040 */ |
|
1041 |
|
1042 CStringArrayItem::CStringArrayItem(): |
|
1043 CItemBase(EStringArray) |
|
1044 { |
|
1045 |
|
1046 } |
|
1047 |
|
1048 CStringArrayItem* CStringArrayItem::NewL(const TDesC& aName, const RPointerArray<HBufC>& aValueArray) |
|
1049 { |
|
1050 CStringArrayItem* self = new(ELeave)CStringArrayItem(); |
|
1051 CleanupStack::PushL(self); |
|
1052 self->ConstructL(aName, aValueArray); |
|
1053 CleanupStack::Pop(self); |
|
1054 return self; |
|
1055 } |
|
1056 |
|
1057 CStringArrayItem* CStringArrayItem::NewL(RReadStream& aStream) |
|
1058 { |
|
1059 CStringArrayItem *self = new(ELeave)CStringArrayItem(); |
|
1060 CleanupStack::PushL(self); |
|
1061 self->InternalizeL(aStream); |
|
1062 CleanupStack::Pop(self); |
|
1063 return self; |
|
1064 } |
|
1065 |
|
1066 void CStringArrayItem::ConstructL(const TDesC& aName, const RPointerArray<HBufC>& aValueArray) |
|
1067 { |
|
1068 SetNameL(aName); |
|
1069 for(TInt i=0; i< aValueArray.Count(); ++i) |
|
1070 { |
|
1071 VerifyExternalizedSizeForParamL(aValueArray[i]->Size()); |
|
1072 HBufC* value = aValueArray[i]->AllocLC(); |
|
1073 iStringArray.AppendL(value); |
|
1074 SetValueSize(ValueSize()+ value->Size()); |
|
1075 CleanupStack::Pop(); |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 void CStringArrayItem::ExternalizeL(RWriteStream& aStream) const |
|
1080 { |
|
1081 CItemBase::ExternalizeL(aStream); |
|
1082 ExternalizePointersArrayL(iStringArray, aStream); |
|
1083 } |
|
1084 |
|
1085 void CStringArrayItem::InternalizeL(RReadStream& aStream) |
|
1086 { |
|
1087 CItemBase::InternalizeL(aStream); |
|
1088 iStringArray.ResetAndDestroy(); |
|
1089 InternalizePointersArrayL(iStringArray, aStream); |
|
1090 } |
|
1091 |
|
1092 const RPointerArray<HBufC>& CStringArrayItem:: StringArrayValue() const |
|
1093 { |
|
1094 return iStringArray; |
|
1095 } |
|
1096 |
|
1097 const HBufC& CStringArrayItem::Name() const |
|
1098 { |
|
1099 return CItemBase::Name(); |
|
1100 } |
|
1101 |
|
1102 MOpaqueParam::TType CStringArrayItem::Type() const |
|
1103 { |
|
1104 return CItemBase::Type(); |
|
1105 } |
|
1106 |
|
1107 TInt CStringArrayItem::ValueSize() const |
|
1108 { |
|
1109 return CItemBase::ValueSize(); |
|
1110 } |
|
1111 |
|
1112 CStringArrayItem::~CStringArrayItem() |
|
1113 { |
|
1114 iStringArray.ResetAndDestroy(); |
|
1115 } |
|
1116 |
|
1117 /* |
|
1118 * CIntegerItem |
|
1119 */ |
|
1120 |
|
1121 CIntegerItem::CIntegerItem(TInt aValue): |
|
1122 CItemBase(EInteger), |
|
1123 iInteger(aValue) |
|
1124 { |
|
1125 |
|
1126 } |
|
1127 |
|
1128 CIntegerItem* CIntegerItem::NewL(const TDesC& aName, TInt aValue) |
|
1129 { |
|
1130 CIntegerItem* self = new(ELeave)CIntegerItem(aValue); |
|
1131 CleanupStack::PushL(self); |
|
1132 self->ConstructL(aName); |
|
1133 CleanupStack::Pop(self); |
|
1134 return self; |
|
1135 } |
|
1136 |
|
1137 CIntegerItem* CIntegerItem::NewL(RReadStream& aStream) |
|
1138 { |
|
1139 CIntegerItem *self = new(ELeave)CIntegerItem(0); |
|
1140 CleanupStack::PushL(self); |
|
1141 self->InternalizeL(aStream); |
|
1142 CleanupStack::Pop(self); |
|
1143 return self; |
|
1144 } |
|
1145 |
|
1146 void CIntegerItem::ConstructL(const TDesC& aName) |
|
1147 { |
|
1148 SetNameL(aName); |
|
1149 SetValueSize(sizeof(TInt)); |
|
1150 } |
|
1151 |
|
1152 void CIntegerItem::ExternalizeL(RWriteStream& aStream) const |
|
1153 { |
|
1154 CItemBase::ExternalizeL(aStream); |
|
1155 aStream.WriteInt32L(iInteger); |
|
1156 } |
|
1157 |
|
1158 void CIntegerItem::InternalizeL(RReadStream& aStream) |
|
1159 { |
|
1160 CItemBase::InternalizeL(aStream); |
|
1161 iInteger = aStream.ReadInt32L(); |
|
1162 } |
|
1163 |
|
1164 TInt CIntegerItem::IntegerValue() const |
|
1165 { |
|
1166 return iInteger; |
|
1167 } |
|
1168 |
|
1169 const HBufC& CIntegerItem::Name() const |
|
1170 { |
|
1171 return CItemBase::Name(); |
|
1172 } |
|
1173 |
|
1174 MOpaqueParam::TType CIntegerItem::Type() const |
|
1175 { |
|
1176 return CItemBase::Type(); |
|
1177 } |
|
1178 |
|
1179 TInt CIntegerItem::ValueSize() const |
|
1180 { |
|
1181 return CItemBase::ValueSize(); |
|
1182 } |
|
1183 |
|
1184 CIntegerItem::~CIntegerItem() |
|
1185 { |
|
1186 } |
|
1187 |
|
1188 /* |
|
1189 * CIntegerArrayItem |
|
1190 */ |
|
1191 |
|
1192 CIntegerArrayItem::CIntegerArrayItem(): |
|
1193 CItemBase(EIntegerArray) |
|
1194 { |
|
1195 |
|
1196 } |
|
1197 |
|
1198 CIntegerArrayItem* CIntegerArrayItem::NewL(const TDesC& aName, const RArray<TInt>& aValueArray) |
|
1199 { |
|
1200 CIntegerArrayItem* self = new(ELeave)CIntegerArrayItem(); |
|
1201 CleanupStack::PushL(self); |
|
1202 self->ConstructL(aName, aValueArray); |
|
1203 CleanupStack::Pop(self); |
|
1204 return self; |
|
1205 } |
|
1206 |
|
1207 CIntegerArrayItem* CIntegerArrayItem::NewL(RReadStream& aStream) |
|
1208 { |
|
1209 CIntegerArrayItem *self = new(ELeave)CIntegerArrayItem(); |
|
1210 CleanupStack::PushL(self); |
|
1211 self->InternalizeL(aStream); |
|
1212 CleanupStack::Pop(self); |
|
1213 return self; |
|
1214 } |
|
1215 |
|
1216 |
|
1217 void CIntegerArrayItem::ConstructL(const TDesC& aName, const RArray<TInt>& aValueArray) |
|
1218 { |
|
1219 SetNameL(aName); |
|
1220 |
|
1221 for(TInt i=0; i<aValueArray.Count(); ++i) |
|
1222 { |
|
1223 iIntegerArray.AppendL(aValueArray[i]); |
|
1224 SetValueSize(ValueSize()+sizeof(TInt)); |
|
1225 } |
|
1226 } |
|
1227 |
|
1228 void CIntegerArrayItem::ExternalizeL(RWriteStream& aStream) const |
|
1229 { |
|
1230 CItemBase::ExternalizeL(aStream); |
|
1231 ExternalizeFixedLengthArrayL(iIntegerArray, aStream); |
|
1232 } |
|
1233 |
|
1234 void CIntegerArrayItem::InternalizeL(RReadStream& aStream) |
|
1235 { |
|
1236 CItemBase::InternalizeL(aStream); |
|
1237 iIntegerArray.Reset(); |
|
1238 InternalizeFixedLengthArrayL(iIntegerArray, aStream); |
|
1239 } |
|
1240 |
|
1241 const RArray<TInt>& CIntegerArrayItem::IntegerArrayValue() const |
|
1242 { |
|
1243 return iIntegerArray; |
|
1244 } |
|
1245 |
|
1246 const HBufC& CIntegerArrayItem::Name() const |
|
1247 { |
|
1248 return CItemBase::Name(); |
|
1249 } |
|
1250 |
|
1251 MOpaqueParam::TType CIntegerArrayItem::Type() const |
|
1252 { |
|
1253 return CItemBase::Type(); |
|
1254 } |
|
1255 |
|
1256 TInt CIntegerArrayItem::ValueSize() const |
|
1257 { |
|
1258 return CItemBase::ValueSize(); |
|
1259 } |
|
1260 |
|
1261 CIntegerArrayItem::~CIntegerArrayItem() |
|
1262 { |
|
1263 iIntegerArray.Close(); |
|
1264 } |