当前位置: 首页>>代码示例>>C++>>正文


C++ wxString::ToCDouble方法代码示例

本文整理汇总了C++中wxString::ToCDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ wxString::ToCDouble方法的具体用法?C++ wxString::ToCDouble怎么用?C++ wxString::ToCDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxString的用法示例。


在下文中一共展示了wxString::ToCDouble方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

static inline long parseInt( const wxString& aValue, double aScalar )
{
    double value = LONG_MAX;

    /*
     * In 2011 gEDA/pcb introduced values with units, like "10mm" or "200mil".
     * Unit-less values are still centimils (100000 units per inch), like with
     * the previous format.
     *
     * Distinction between the even older format (mils, 1000 units per inch)
     * and the pre-2011 format is done in ::parseMODULE already; the
     * distinction is by wether an object definition opens with '(' or '['.
     * All values with explicite unit open with a '[' so there's no need to
     * consider this distinction when parsing them.
     *
     * The solution here is to watch for a unit and, if present, convert the
     * value to centimils. All unit-less values are read unaltered. This way
     * the code below can contine to consider all read values to be in mils or
     * centimils. It also matches the strategy gEDA/pcb uses for backwards
     * compatibility with its own layouts.
     *
     * Fortunately gEDA/pcb allows only units 'mil' and 'mm' in files, see
     * definition of ALLOW_READABLE in gEDA/pcb's pcb_printf.h. So we don't
     * have to test for all 11 units gEDA/pcb allows in user dialogs.
     */
    if( aValue.EndsWith( wxT( "mm" ) ) )
    {
        aScalar *= 100000.0 / 25.4;
    }
    else if( aValue.EndsWith( wxT( "mil" ) ) )
    {
        aScalar *= 100.;
    }

    // This conversion reports failure on strings as simple as "1000", still
    // it returns the right result in &value. Thus, ignore the return value.
    aValue.ToCDouble(&value);
    if( value == LONG_MAX ) // conversion really failed
    {
        THROW_IO_ERROR( wxString::Format( _( "Cannot convert \"%s\" to an integer" ),
                                          aValue.GetData() ) );
        return 0;
    }

    return KiROUND( value * aScalar );
}
开发者ID:corecode,项目名称:kicad-source-mirror,代码行数:46,代码来源:gpcb_plugin.cpp

示例2: TryParseGPR

bool CRegTable::TryParseGPR(wxString str, FormatSpecifier format, u32* value)
{
  if (format == FormatSpecifier::Hex8)
  {
    unsigned long val;
    if (str.ToCULong(&val, 16))
    {
      *value = static_cast<u32>(val);
      return true;
    }
    return false;
  }
  if (format == FormatSpecifier::Int)
  {
    long signed_val;
    if (str.ToCLong(&signed_val))
    {
      *value = static_cast<u32>(signed_val);
      return true;
    }
    return false;
  }
  if (format == FormatSpecifier::UInt)
  {
    unsigned long val;
    if (str.ToCULong(&val))
    {
      *value = static_cast<u32>(val);
      return true;
    }
    return false;
  }
  if (format == FormatSpecifier::Float)
  {
    double double_val;
    if (str.ToCDouble(&double_val))
    {
      float float_val = static_cast<float>(double_val);
      std::memcpy(value, &float_val, sizeof(float));
      return true;
    }
    return false;
  }
  return false;
}
开发者ID:spxtr,项目名称:dolphin,代码行数:45,代码来源:RegisterView.cpp

示例3: TryParseFPR

bool CRegTable::TryParseFPR(wxString str, FormatSpecifier format, unsigned long long* value)
{
  if (format == FormatSpecifier::Hex16)
  {
    return str.ToULongLong(value, 16);
  }
  if (format == FormatSpecifier::Double)
  {
    double double_val;
    if (str.ToCDouble(&double_val))
    {
      std::memcpy(value, &double_val, sizeof(u64));
      return true;
    }
    return false;
  }
  return false;
}
开发者ID:spxtr,项目名称:dolphin,代码行数:18,代码来源:RegisterView.cpp


注:本文中的wxString::ToCDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。