Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

double wxPdfDocument::String2Double ( const wxString &  str ) [static]

Parses a floating point number.

Parameters:
strthe string to be parsed
Returns:
the value of floating point number given by the string representation, 0 if the string could not be parsed.

Definition at line 2118 of file pdfdoc.cpp.

Referenced by PrepareXmlCell(), PrepareXmlTable(), WriteXmlCell(), wxPdfCoonsPatchGradient::wxPdfCoonsPatchGradient(), and wxPdfNumber::wxPdfNumber().

{
  wxString value = str.Strip(wxString::both);
  double result = 0;
  double sign = 1;
  int scale = 0;
  int exponent = 0;
  int expsign = 1;
  int j = 0;
  int jMax = value.Length();
  if (jMax > 0)
  {
    if (value[j] == wxT('+'))
    {
      j++;
    }
    else if (value[j] == wxT('-'))
    {
      sign = -1;
      j++;
    }
    while (j < jMax && wxIsdigit(value[j]))
    {
      result = result*10 + (value[j] - wxT('0'));
      j++;
    }
    if (j < jMax && value[j] == wxT('.'))
    {
      j++;
      while (j < jMax && wxIsdigit(value[j]))
      {
        result = result*10 + (value[j] - wxT('0'));
        scale++;
        j++;
      }
    }
    if (j < jMax && (value[j] == wxT('E') || value[j] == wxT('e')))
    {
      j++;
      if (value[j] == wxT('+'))
      {
        j++;
      }
      else if (value[j] == wxT('-'))
      {
        expsign = -1;
        j++;
      }
      while (j < jMax && wxIsdigit(value[j]))
      {
        exponent = exponent*10 + (value[j] - wxT('0'));
        j++;
      }
      exponent *= expsign;
    }
    result = sign * result * pow(10.0, exponent-scale);
  }
  return result;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index