Exemplo n.º 1
0
bool nwxString::IsInteger(const wxString &s, bool bAllowSign)
{
  const wxChar *p = s.wc_str();
  bool bFoundDigit = false;

  if(bAllowSign && IsSign(*p))
  {
    p++;
  }
  while(IsNumeric(*p))
  {
    p++;
    bFoundDigit = true;
  }
  bool bRtn = bFoundDigit && (!(*p));
  return bRtn;
}
Exemplo n.º 2
0
bool nwxString::IsNumber(const wxString &s, bool bAllowExp)
{
  const wxChar *p = s.wc_str();
  bool bFoundDigit = false;
  bool bRtn = true;
  if(IsSign(*p))
  {
    // optional sign
    p++;
  }
  while(IsNumeric(*p))
  {
    // digits
    bFoundDigit = true;
    p++;
  }
  if((*p) == '.')
  {
    // decimal, optional
    p++;
  }
  while(IsNumeric(*p))
  {
    // digits
    bFoundDigit = true;
    p++;
  }
  if(bAllowExp && bFoundDigit)
  {
    // exp OK if at least one digit found so far
    
    bool bFoundExpDigit = false;
    if((*p) == 'e' || (*p) == 'E')
    {
      p++;
      if(IsSign(*p))
      {
        // optional sign
        p++;
      }
      while(IsNumeric(*p))
      {
        // required numeric
        p++;
        bFoundExpDigit = true;
      }
      if(!bFoundExpDigit)
      {
        // E or e found w/o digits, return false
        bRtn = false;
      }
    }
  }
  if( (*p) || !bFoundDigit )
  {
    // either no digits found 
    // or not at end of string
    bRtn = false;
  }
  return bRtn;
}
Exemplo n.º 3
0
    void SetNegative(bool is_negative) {
      assert(IsSign());

      value = is_negative;
    }
Exemplo n.º 4
0
 constexpr bool IsEditable() const {
   return IsNumber() || IsSign();
 }