Minor corrections for sake of completeness:

FUNCTION Serialize( xValue )

   SWITCH ValType( xValue )
      CASE 'A'
         RETURN SerializeArray( xValue )

      CASE 'C'
         RETURN '"' + xValue + '"'

      CASE 'N'
         RETURN LTrim( Str( xValue ) )

      CASE 'D'
         RETURN 'STOD("' + DTOS( xValue ) + '")'

      CASE 'L'
         RETURN IF( xValue, ".T.", ".F." )
      END

   Alert( "Unsupported type!" )

RETURN ""

FUNCTION SerializeArray( aArray )

   LOCAL sList := "{", xValue

   IF Empty( aArray )
      RETURN "{}"
   ENDIF

   FOR EACH xValue IN aArray
      sList += Serialize( xValue ) + ","
   NEXT

   sList[-1] := "}"

RETURN sList

FUNCTION DeSerialize( sValue )

   LOCAL sList, sToken, aArray

   IF sValue[1] == '{'
      sList := SubStr( sValue, 2, Len( sValue ) - 2 )
      aArray := {}

      FOR EACH sToken IN hb_aTokens( sList, ",", .T. )
         aAdd( aArray, DeSerialize( sToken ) )
      NEXT

      RETURN aArray
   ENDIF

RETURN &( sValue )
 

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to