syncmlfw/ds/dsutils/dbcaps/inc/NSmldbcapsSerializer.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  for dbcaps streaming and converting to CSmlDataStoreFormat.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLDBCAPSSERIALIZER_H__
       
    20 #define __NSMLDBCAPSSERIALIZER_H__
       
    21 
       
    22 // ------------------------------------------------------------------------------------------------
       
    23 // Includes
       
    24 // ------------------------------------------------------------------------------------------------
       
    25 #include <SmlDataFormat.h>
       
    26 #include <SmlDataFormat.hrh>
       
    27 
       
    28 // ------------------------------------------------------------------------------------------------
       
    29 // Class forwards
       
    30 // ------------------------------------------------------------------------------------------------
       
    31 class CNSmlDbCaps;
       
    32 class CNSmlDevInfProp;
       
    33 class CNSmlPropParam;
       
    34 class CNSmlDevInfProp;
       
    35 class CNSmlCtCap;
       
    36 class CNSmlFilterCap;
       
    37 struct sml_devinf_propparam_s;
       
    38 struct sml_devinf_property_s;
       
    39 struct sml_devinf_filtercap_s;
       
    40 struct sml_devinf_ctcap_s;
       
    41 struct sml_pcdata_list_s;
       
    42 struct sml_pcdata_s;
       
    43 
       
    44 // ------------------------------------------------------------------------------------------------
       
    45 // TNSmlDbCapsSerializer
       
    46 // Handles internalization and externalization of CNSmlDbCaps to stream, that can
       
    47 // be internalized to and externalized from CSmlDataStoreFormat. 
       
    48 //
       
    49 //	@lib nsmldbcaps.lib
       
    50 // ------------------------------------------------------------------------------------------------
       
    51 class TNSmlDbCapsSerializer
       
    52 	{
       
    53 	private:
       
    54 	
       
    55 		// ------------------------------------------------------------------------------------------------
       
    56 		// CNSmlFilterCapabilityData
       
    57 		// Data for CSmlFilterCapability
       
    58 		//
       
    59 		// @lib nsmldbcaps.lib
       
    60 		// ------------------------------------------------------------------------------------------------
       
    61 		struct CNSmlFilterCapabilityData
       
    62 			{
       
    63 				/**
       
    64 				* constructs CNSmlFilterCapabilityData
       
    65 				* @return CNSmlFilterCapabilityData*. Created instance
       
    66 				*/
       
    67 				static CNSmlFilterCapabilityData* NewLC();
       
    68 				
       
    69 				/**
       
    70 				* C++ Destructor
       
    71 				*/
       
    72 				~CNSmlFilterCapabilityData();
       
    73 				
       
    74 				/**
       
    75 				* fills members from array of filtercapdata
       
    76 				* @param aFilterInfoArr. array of filter capabilities.
       
    77 				*/
       
    78 				void MakeL( const RStringPool& aStringPool, const CArrayFix<TNSmlFilterCapData>& aFilterInfoArr );
       
    79 				
       
    80 			public: //Data
       
    81 			
       
    82 				RPointerArray<CSmlFilterCapability> iFilterCapabilities;
       
    83 				RArray<RString> iKeywordList;
       
    84 				RArray<RString> iPropertyList;
       
    85 				RStringF iMimeVersion;
       
    86 				RStringF iMimeType;
       
    87 			};
       
    88 
       
    89 		// ------------------------------------------------------------------------------------------------
       
    90 		// CNSmlDataFieldFromDbCaps
       
    91 		// inherited from CSmlDataField to have access to protected member variables.
       
    92 		//
       
    93 		// @lib nsmldbcaps.lib
       
    94 		// ------------------------------------------------------------------------------------------------
       
    95 		class CNSmlDataFieldFromDbCaps : public CSmlDataField
       
    96 			{
       
    97 		public:
       
    98 		
       
    99 			/**
       
   100 		    * constructs CSmlDataField from parameters
       
   101 		    * @param aStringPool. string pool to use
       
   102 		    * @param aDisplayName. display name- field
       
   103 		    * @param aPropName. property name- field
       
   104 		    * @param aDataType. datatype name- field
       
   105 		    * @param aValEnums. value enumerations
       
   106 		    * @return CSmlDataField*. created instance.
       
   107 		    */
       
   108 			static CSmlDataField* NewLC(
       
   109 				const RStringPool& aStringPool,
       
   110 				const TPtrC8& aDisplayName, 
       
   111 				const TPtrC8& aPropName,
       
   112 				const TPtrC8& aDataType,
       
   113 				const sml_pcdata_list_s* aValEnums);
       
   114 
       
   115 			};
       
   116 			
       
   117 		// ------------------------------------------------------------------------------------------------
       
   118 		// CNSmlDataPropertyParamFromDbCaps
       
   119 		// inherited from CSmlDataPropertyParam to have access to protected member variables.
       
   120 		//
       
   121 		// @lib nsmldbcaps.lib
       
   122 		// ------------------------------------------------------------------------------------------------
       
   123 		class CNSmlDataPropertyParamFromDbCaps : CSmlDataPropertyParam
       
   124 			{
       
   125 		public:
       
   126 		
       
   127 			/**
       
   128 		    * constructs CSmlDataPropertyParam from parameters
       
   129 		    * @param aStringPool. string pool to use
       
   130 		    * @param aDipp. property parameters
       
   131 		    * @return CSmlDataPropertyParam*. created instance.
       
   132 		    */
       
   133 			static CSmlDataPropertyParam* NewLC( const RStringPool& aStringPool, 
       
   134 				const sml_devinf_propparam_s* aDipp );
       
   135 			};
       
   136 
       
   137 		// ------------------------------------------------------------------------------------------------
       
   138 		// CNSmlDataPropertyFromDbCaps
       
   139 		// inherited from CSmlDataProperty to have access to protected member variables.
       
   140 		//
       
   141 		// @lib nsmldbcaps.lib
       
   142 		// ------------------------------------------------------------------------------------------------
       
   143 		class CNSmlDataPropertyFromDbCaps : CSmlDataProperty
       
   144 			{
       
   145 		public:
       
   146 		
       
   147 			/**
       
   148 		    * constructs CSmlDataProperty from parameters
       
   149 		    * @param aStringPool. string pool to use
       
   150 		    * @param aDipp. properties
       
   151 		    * @return CSmlDataProperty*. created instance.
       
   152 		    */
       
   153 			static CSmlDataProperty* NewLC( const RStringPool& aStringPool, const sml_devinf_property_s* aDipp );
       
   154 			};
       
   155 
       
   156 		// ------------------------------------------------------------------------------------------------
       
   157 		// CNSmlFilterCapabilityFromDbCaps
       
   158 		// inherited from CSmlFilterCapability to have access to protected member variables.
       
   159 		//
       
   160 		// @lib nsmldbcaps.lib
       
   161 		// ------------------------------------------------------------------------------------------------
       
   162 		class CNSmlFilterCapabilityFromDbCaps : CSmlFilterCapability
       
   163 			{
       
   164 		public:
       
   165 		
       
   166 			/**
       
   167 		    * constructs CSmlFilterCapability from parameters
       
   168 		    * @param aStringPool. string pool to use
       
   169 		    * @param aFtCap. filter capabilities
       
   170 		    * @return CSmlFilterCapability*. created instance.
       
   171 		    */
       
   172 			static CSmlFilterCapability* NewLC( const RStringPool& aStringPool, const sml_devinf_filtercap_s* aFtCap );
       
   173 			};
       
   174 
       
   175 		// ------------------------------------------------------------------------------------------------
       
   176 		// CNSmlMimeFormatFromDbCaps
       
   177 		// inherited from CSmlMimeFormat to have access to protected member variables.
       
   178 		//
       
   179 		// @lib nsmldbcaps.lib
       
   180 		// ------------------------------------------------------------------------------------------------
       
   181 		class CNSmlMimeFormatFromDbCaps : CSmlMimeFormat
       
   182 			{
       
   183 		public:
       
   184 
       
   185 			/**
       
   186 		    * constructs CSmlMimeFormat from parameters
       
   187 		    * @param aStringPool. string pool to use
       
   188 		    * @param aDic. ctcap.
       
   189 		    * @return CSmlMimeFormat*. created instance.
       
   190 		    */
       
   191 			static CSmlMimeFormat* NewLC( const RStringPool& aStringPool, const sml_devinf_ctcap_s& aDic );
       
   192 			};
       
   193 		// ------------------------------------------------------------------------------------------------
       
   194 		// CNSmlDataStoreFormatFromDbCaps
       
   195 		// inherited from CSmlDataStoreFormat to have access to protected member variables.
       
   196 		//
       
   197 		// @lib nsmldbcaps.lib
       
   198 		// ------------------------------------------------------------------------------------------------
       
   199 		class CNSmlDataStoreFormatFromDbCaps : CSmlDataStoreFormat
       
   200 			{
       
   201 		public:
       
   202 
       
   203 			/**
       
   204 		    * constructs CSmlDataStoreFormat from parameters
       
   205 		    * @param aStringPool. string pool to use
       
   206 		    * @param aDbCaps. Db caps
       
   207 		    * @return CSmlDataStoreFormat*. created instance.
       
   208 		    */
       
   209 			static CSmlDataStoreFormat* NewLC( const RStringPool& aStringPool, const CNSmlDbCaps& aDbCaps );
       
   210 			};
       
   211 			
       
   212 	public: //Constructor
       
   213 		IMPORT_C TNSmlDbCapsSerializer();
       
   214 
       
   215 		/**
       
   216 		* Internalizes from data store stream to dbcaps instance.
       
   217 		* @param aDataStoreFormatStream. Store format stream.
       
   218 		* @return CNSmlDbCaps*. Instance internalized from stream.
       
   219 		*/
       
   220 		IMPORT_C CNSmlDbCaps* InternalizeL( RReadStream& aDataStoreFormatStream ) const;
       
   221 		
       
   222 		/**
       
   223 		* externalizes from dbcaps to data store stream
       
   224 		* @param aDbCaps. Object to externalize
       
   225 		* @param aDataStoreFormatStream. Stream, where externalized
       
   226 		*/
       
   227 		IMPORT_C void ExternalizeL( const CNSmlDbCaps& aDbCaps, RWriteStream& aDataStoreFormatStream ) const;
       
   228 		/**
       
   229 		* externalizes from dbcaps to data store stream
       
   230 		* @param const CArrayFix<TNSmlFilterCapData>& aFilterInfoArr. filter info to externalize.
       
   231 		* @param aDataStoreFormatStream. Stream, where externalized
       
   232 		*/		
       
   233 		IMPORT_C void ExternalizeL( const CNSmlDbCaps& aDbCaps, const CArrayFix<TNSmlFilterCapData>& aFilterInfoArr, RWriteStream& aDataStoreFormatStream ) const;
       
   234 		
       
   235 		/**
       
   236 		* copies and converts data from aFrom to aTo
       
   237 		* @param aFrom. Source Object
       
   238 		* @param aTo. Destination Object
       
   239 		*/	
       
   240 		IMPORT_C void SetFromL( const CSmlDataProperty& aFrom, CNSmlDevInfProp& aTo ) const;
       
   241 		
       
   242 		/**
       
   243 		* checks for null before returning data pointer
       
   244 		* @param aPcdata. place to extract pointer.
       
   245 		* @return. safe data pointer
       
   246 		*/
       
   247 		static TPtrC8 SafePtr( sml_pcdata_s* aPcdata );
       
   248 		
       
   249 	private:
       
   250 
       
   251 		/**
       
   252 		* copies and converts data from aFrom to aTo
       
   253 		* @param aFrom. Source Object
       
   254 		* @param aTo. Destination Object
       
   255 		*/
       
   256 		void SetFromL( const CSmlDataStoreFormat& aFrom, CNSmlDbCaps& aTo ) const;
       
   257 
       
   258 		/**
       
   259 		* copies and converts data from aFrom to aTo
       
   260 		* @param aFrom. Source Object
       
   261 		* @param aTo. Destination Object
       
   262 		*/
       
   263 		void SetFromL( const CSmlDataPropertyParam& aFrom, CNSmlPropParam& aTo ) const;
       
   264 		
       
   265 		/**
       
   266 		* copies and converts data from aFrom to aTo
       
   267 		* @param aFrom. Source Object
       
   268 		* @param aTo. Destination Object
       
   269 		*/
       
   270 		void SetFromL( const CSmlMimeFormat& aFrom, CNSmlCtCap& aTo ) const;
       
   271 		
       
   272 		/**
       
   273 		* copies and converts data from aFrom to aTo
       
   274 		* @param aFrom. Source Object
       
   275 		* @param aTo. Destination Object
       
   276 		*/
       
   277 		void SetFromL( const CSmlFilterCapability& aFrom, CNSmlFilterCap& aTo ) const;
       
   278 	private:
       
   279 	};
       
   280 	
       
   281 #endif //__NSMLDBCAPSSERIALIZER_H__
       
   282 
       
   283 // End of File