-// -----------------------------------------------------------------------
-// wxVariant helpers
-// -----------------------------------------------------------------------
-
-long wxPGVariantToInt( const wxVariant& variant, long defVal )
-{
- if ( variant.IsNull() )
- return defVal;
-
- if ( variant.GetType() == wxS("long") )
- return variant.GetLong();
-
- if ( variant.GetType() == wxS("bool") )
- return variant.GetBool() ? 1 : 0;
-
- if ( variant.GetType() == wxS("wxLongLong") )
- {
- wxLongLong ll;
- ll << variant;
- if ( ll >= LONG_MAX )
- return LONG_MAX;
- else if ( ll <= LONG_MIN )
- return LONG_MIN;
- return ll.ToLong();
- }
-
- long l = defVal;
-
- if ( variant.GetType() == wxPG_VARIANT_TYPE_STRING )
- variant.GetString().ToLong(&l, 0);
-
- return l;
-}
-
-// -----------------------------------------------------------------------
-
-bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult )
-{
- if ( variant.IsNull() )
- return false;
-
- wxString variantType = variant.GetType();
-
- if ( variantType == wxPG_VARIANT_TYPE_LONG )
- {
- *pResult = variant.GetLong();
- return true;
- }
-
- if ( variantType == wxLongLong_VariantType )
- {
- // NOTE: << operator uses this functions, so we can't use it here
- *pResult = wxLongLongRefFromVariant(variant).GetValue();
- return true;
- }
-
- return false;
-}
-
-// -----------------------------------------------------------------------
-
-bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult )
-{
- if ( variant.IsNull() )
- return false;
-
- wxString variantType = variant.GetType();
-
- if ( variantType == wxPG_VARIANT_TYPE_LONG )
- {
- *pResult = (unsigned long)variant.GetLong();
- return true;
- }
-
- if ( variantType == wxULongLong_VariantType )
- {
- // NOTE: << operator uses this functions, so we can't use it here
- *pResult = wxULongLongRefFromVariant(variant).GetValue();
- return true;
- }
-
- return false;
-}
-
-// -----------------------------------------------------------------------
-
-bool wxPGVariantToDouble( const wxVariant& variant, double* pResult )
-{
- if ( variant.IsNull() )
- return false;
-
- wxString variantType = variant.GetType();
-
- if ( variantType == wxPG_VARIANT_TYPE_DOUBLE )
- {
- *pResult = variant.GetDouble();
- return true;
- }
-
- if ( variantType == wxPG_VARIANT_TYPE_LONG )
- {
- *pResult = (double)variant.GetLong();
- return true;
- }
-
- if ( variantType == wxLongLong_VariantType )
- {
- wxLongLong ll;
- ll << variant;
- *pResult = ll.ToDouble();
- return true;
- }
-
- if ( variantType == wxPG_VARIANT_TYPE_STRING )
- if ( variant.GetString().ToDouble(pResult) )
- return true;
-
- return false;
-}
-