Developer

API Reference

IvParm

Brew Release
Brew MP 1.0.2
See Also
Description
IvParm interface represents a parameter either in vCard/vCalendar
Usage

Example usage,
   Say we have a parameter buffer associated with a property as follows, 

      TYPE=WORK,POSTAL,X-Service

   After parsing we would get a IvParm object pointer pIvParm (say)

   The various operations that can be performed are,

   Note: For our use case we assume the return values from functions are always
         AEE_SUCCESS and pointers passed in or allocated are valid

   void Sample_Parms_Usage1(IvParm *pIvParm)
   {
      int nResult = 0;
      int nNumVals = 0;
      char   *pszBuf = NULL;
      AECHAR *pwszBuf = NULL;
      int nBufSizeReq = 0;
      AEEVParameter nParmId = 0;
      uint32 dwValue = 0;

      nResult = IvParm_GetId(pIvParm, &nParmId);
      //nParmId=AEEVPARM_TYPE

      nResult = IvParm_GetNumberOfValues(pIvParm,&nNumVals);
      //nNumVals=3
      
      //If the user is interested in getting the raw buffer at index 0,
      nResult = IvParm_ParseValue(pIvParm,
                                  FALSE,     //wants raw buffer
                                  0,         //at index 0
                                  &dwValue,
                                  NULL,
                                  0,
                                  &nBufSizeReq);

      //upon return nBufSizeReq=5
      pszBuf = IEnv_ErrMalloc(nBufSizeReq);
      if( NULL == pszBuf ){
         return;
      }

      nResult = IvParm_ParseValue(pIvParm,
                                  FALSE,
                                  0,
                                  &dwValue,
                                  (void *)pszBuf,
                                  nBufSizeReq,
                                  &nBufSizeReq);

      //upon return pBuf="WORK"
      
      //if the user wants parsed value data at index 2 (X-Service)
      nResult = IvParm_ParseValue(pIvParm,
                                  TRUE,
                                  2,
                                  &dwValue,
                                  NULL,
                                  0,
                                  &nBufSizeReq);

      //means we have value which isn't of standard type
      if( AEE_SUCCESS == nResult && 0 == dwValue  ){

         pwszBuf = IEnv_ErrMalloc(pMe->nBufSizeReq);
         if( NULL == pwszBuf ){
            IENV_FREEIF(pMe->pIEnv,pszBuf);
            return;
         }

         nResult = IvParm_ParseValue(pIvParm,
                                     TRUE,
                                     2,
                                     &dwValue,
                                     pwszBuf,
                                     nBufSizeReq,
                                     &nBufSizeReq);

         //upon return pwszBuf would be pointing to  wide string of "X-Service"

      }
      
      //if the user is interested in getting the parsed data at index 1
      nResult = IvParm_ParseValue(pIvParm,
                                  TRUE,
                                  1,
                                  &dwValue,
                                  NULL,
                                  0,
                                  &nBufSizeReq);

      //upon return dwValue= AEEVTYPE_POSTAL


      IENV_FREEIF(pMe->pIEnv,pszBuf);
      IENV_FREEIF(pMe->pIEnv,pwszBuf);

      return;

   }
   
   

   //if the user wants to generate a buffer of the following type in a property
   //then he can do as follows
   //    TYPE=CELL,HOME,X-MyPlace

   void Sample_Parms_Usage2(IEnv *pIEnv)
   {
      IvParm *pIvParm = NULL;
      int nResult = AEE_SUCCESS;
      int nNumVals = 0;
      uint32 dwValue = 0;
      int nBufSizeReq = 0;
      char *pszBuf = "X-MyPlace";
      AECHAR *pwszBuf = NULL;

      if( NULL == pIEnv ) {
         return;
      }

   do {
         nResult = IEnv_CreateInstance(pIEnv, AEECLSID_vParm, (void **)&pIvParm);
         BREAKIF(nResult);

         nResult = IvParm_InitParm(pIvParm,
                                   AEEVPARM_TYPE,
                                   NULL,
                                   AEEVTYPE_CELL,
                                   NULL);
         BREAKIF(nResult);

         nResult = IvParm_AddValue(pIvParm,AEEVTYPE_HOME,NULL);
         BREAKIF(nResult);

         pwszBuf = IEnv_ErrMalloc ( (std_strlen(pszBuf) + 1) * 2 );

         (void)STRTOWSTR(pszBuf, pwszBuf, (std_strlen(pszBuf) + 1)*2 );

         nResult = IvParm_AddValue(pIvParm,0,pwszBuf);
         BREAKIF(nResult);

         //upon return this would be, nNumVals =3
         nResult = IvParm_GetNumberOfValues(pIvParm,&nNumVals);
         BREAKIF(nResult);
         
        //parse value of index 1
        //upon return dwValue = AEEVTYPE_HOME
        nResult = IvParm_ParseValue(pIvParm,
                                    TRUE,
                                    1,
                                    &dwValue,
                                    NULL,
                                    0,
                                    &nBufSizeReq);
        BREAKIF(nResult);


   }while(0);

   RELEASEIF(pIvParm);
   IENV_FREEIF(pMe->pIEnv,pwszBuf);
 }

  • Follow