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


C++ wxSscanf函数代码示例

本文整理汇总了C++中wxSscanf函数的典型用法代码示例。如果您正苦于以下问题:C++ wxSscanf函数的具体用法?C++ wxSscanf怎么用?C++ wxSscanf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: wxT

bool wxReportImageItem::RetrieveFromXmlNode(const wxXmlNode* node)
{
    long type = -1, ppi = 72;
    double x = -1, y = -1;

    node->GetAttribute(wxT("Type"), wxT("")).ToLong(&type);
    if(type != wxRP_IMAGE) return false;
    if(!this->m_style.RetrieveFromXmlNode(node));
    this->m_sName = node->GetAttribute(wxT("Name"), wxT(""));
    wxString path = node->GetAttribute(wxT("Path"), wxT(""));
    wxImage image;

    if(image.LoadFile(path))
    {
        this->m_sValue = path;
    }
    else return false;

    wxSscanf(node->GetAttribute(wxT("X"), wxT("")), wxT("%lf"), &x);
    wxSscanf(node->GetAttribute(wxT("Y"), wxT("")), wxT("%lf"), &y);

    if(x >= 0 && y >= 0)
        this->m_position = wxRealPoint(x, y);
    else return false;

    wxSscanf(node->GetAttribute(wxT("PPI"), wxT("")), wxT("%d"), &ppi);
    this->m_iPPI = ppi;

    this->m_iWidth = image.GetWidth();
    this->m_iHeight = image.GetHeight();

    return true;
}
开发者ID:stahta01,项目名称:wxCode_components,代码行数:33,代码来源:pageitems.cpp

示例2: wxLogError

/*****************************************************
**
**   Formatter   ---   getDateIntsFromString
**
******************************************************/
bool Formatter::getDateIntsFromString( const wxChar *value, int &day, int &month, int &year, int format )
{
	const int l = LanguageConfig::get()->getLocale()->GetLanguage();
	if ( ! value )
	{
		wxLogError( wxT( "Error: date value is NULL" ));
		return false;
	}
	wxChar *c = (wxChar*)value;
	int sepTokenCount = 0;
	const wxChar septoken = ( l == wxLANGUAGE_GERMAN ? '.' : '-' );

	while ( *c )
	{
		if ( *c == septoken ) sepTokenCount++;
		if ( ! ( isdigit( *c ) || *c == '.' || *c == '-' )) return false;
		c++;
	}
	if ( sepTokenCount > 2 ) return false;

	int ret;
	if ( l == wxLANGUAGE_GERMAN ) // German
		ret = wxSscanf( value, wxT( "%d.%d.%d" ), &day, &month, &year );
	else
		ret = wxSscanf( value, wxT( "%d-%d-%d" ), &year, &month, &day );
	if ( ret != 3 ) return false;

	if (( day < 1 ) || ( day > 31 )) return false;
	if (( month < 1 ) || ( month > 12 )) return false;
	if (( year < -3000 ) || ( year > 6000 )) return false;

	return true;
}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:38,代码来源:Lang.cpp

示例3: wxGetOsVersion

wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro)
{
    // get OS version
    int major = -1, minor = -1, micro = -1;
    wxString release = wxGetCommandOutput(wxT("uname -r"));
    if ( !release.empty() )
    {
        if ( wxSscanf(release.c_str(), wxT("%d.%d.%d"), &major, &minor, &micro ) != 3 )
        {
            micro = 0;
            if ( wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor ) != 2 )
            {
                // failed to get version string or unrecognized format
                major = minor = micro = -1;
            }
        }
    }

    if ( verMaj )
        *verMaj = major;
    if ( verMin )
        *verMin = minor;
    if ( verMicro )
        *verMicro = micro;

    // try to understand which OS are we running
    wxString kernel = wxGetCommandOutput(wxT("uname -s"));
    if ( kernel.empty() )
        kernel = wxGetCommandOutput(wxT("uname -o"));

    if ( kernel.empty() )
        return wxOS_UNKNOWN;

    return wxPlatformInfo::GetOperatingSystemId(kernel);
}
开发者ID:AaronDP,项目名称:wxWidgets,代码行数:35,代码来源:utilsunx.cpp

示例4: wxSscanf

long wxTimeSpinCtrl::GetTextTime()
{
	int t1, t2, t3, t4;
	int scanned = wxSscanf(m_txt->GetValue(), wxT("%d:%d:%d:%d"), &t1, &t2, &t3, &t4);

	switch (scanned)
	{
		case 1:
			if (t1 >= 0)
				return t1;
			break;
		case 2:
			if (t1 >= 0 && t2 >= 0 && t2 < 60)
				return t1 * 60 + t2;
			break;
		case 3:
			if (t1 >= 0 && t2 >= 0 && t2 < 60 && t3 >= 0 && t3 < 60)
				return (t1 * 60 + t2) * 60 + t3;
			break;
		case 4:
			if (t1 >= 0 && t2 >= 0 && t2 < 24 && t3 >= 0 && t3 < 60 && t4 >= 0 && t4 < 60)
				return ((t1 * 24 + t2) * 60 + t3) * 60 + t4;
			break;
		default:
			break;
	}
	return -1;
}
开发者ID:KrisShannon,项目名称:pgadmin3,代码行数:28,代码来源:timespin.cpp

示例5: vTokenizer

bool wxNativeEncodingInfo::FromString( const wxString& rsStr )
{
    wxStringTokenizer               vTokenizer(rsStr, wxT(";"));
    wxString                        sEncid = vTokenizer.GetNextToken();
    long                            lEnc;

    if (!sEncid.ToLong(&lEnc))
        return FALSE;
    encoding = (wxFontEncoding)lEnc;
    facename = vTokenizer.GetNextToken();
    if (!facename)
        return FALSE;

    wxString                        sTmp = vTokenizer.GetNextToken();

    if (!sTmp)
    {
        charset = 850;
    }
    else
    {
        if ( wxSscanf(sTmp, wxT("%u"), &charset) != 1 )
        {
            // should be a number!
            return FALSE;
        }
    }
    return true;
} // end of wxNativeEncodingInfo::FromString
开发者ID:chromylei,项目名称:third_party,代码行数:29,代码来源:fontutil.cpp

示例6: tokenizer

bool wxNativeEncodingInfo::FromString(const wxString& s)
{
    wxStringTokenizer tokenizer(s, _T(";"));

    facename = tokenizer.GetNextToken();
    if ( !facename )
        return FALSE;

    wxString tmp = tokenizer.GetNextToken();
    if ( !tmp )
    {
        // default charset (don't use DEFAULT_CHARSET though because of subtle
        // Windows 9x/NT differences in handling it)
        charset = 0;
    }
    else
    {
        if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
        {
            // should be a number!
            return FALSE;
        }
    }

    return TRUE;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:26,代码来源:fontutil.cpp

示例7: GetParam

int wxHtmlTag::ScanParam(const wxString& par,
                         const wchar_t *format,
                         void *param) const
{
    wxString parval = GetParam(par);
    return wxSscanf(parval, format, param);
}
开发者ID:beanhome,项目名称:dev,代码行数:7,代码来源:htmltag.cpp

示例8: GetFloatValue

float FloatConfigControl::GetFloatValue()
{
    float f_value;
    if( (wxSscanf(textctrl->GetValue(), wxT("%f"), &f_value) == 1) )
        return f_value;
    else return 0.0;
}
开发者ID:forthyen,项目名称:SDesk,代码行数:7,代码来源:preferences_widgets.cpp

示例9: input

void VarArgTestCase::Sscanf()
{
    int i = 0;
    char str[20];
    wchar_t wstr[20];

    wxString input("42 test");

    wxSscanf(input, "%d %s", &i, &str);
    CPPUNIT_ASSERT( i == 42 );
    CPPUNIT_ASSERT( wxStrcmp(str, "test") == 0 );

    i = 0;
    wxSscanf(input, L"%d %s", &i, &wstr);
    CPPUNIT_ASSERT( i == 42 );
    CPPUNIT_ASSERT( wxStrcmp(wstr, "test") == 0 );
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:17,代码来源:vararg.cpp

示例10: strutil_decrypt

String
strutil_decrypt(const String &original)
{
   if(original.Length() == 0)
      return wxEmptyString;

   if(! strutil_encrypt_initialised)
      strutil_encrypt_initialise();

   if(original[0] == '-')
      return strutil_decrypt_tf(original);

   // the encrypted string always has a length divisible by 4
   if ( original.length() % 4 )
   {
      wxLogWarning(_("Decrypt function called with illegal string."));

      return wxEmptyString;
   }

   String
      tmpstr,
      newstr;
   const wxChar
      *cptr = original.c_str();

   unsigned char pair[2];
   unsigned int i;
   while(*cptr)
   {
      tmpstr = wxEmptyString;
      tmpstr << *cptr << *(cptr+1);
      cptr += 2;
      wxSscanf(tmpstr.c_str(), _T("%02x"), &i);
      pair[0] = (unsigned char) i;
      tmpstr = wxEmptyString;
      tmpstr << *cptr << *(cptr+1);
      cptr += 2;
      wxSscanf(tmpstr.c_str(), _T("%02x"), &i);
      pair[1] = (unsigned char) i;
      strutil_encrypt_pair(pair);
      newstr << (char) pair[0] << (char) pair[1];
   }
   return newstr;
}
开发者ID:vadz,项目名称:mahogany,代码行数:45,代码来源:strutil.cpp

示例11: wxAtoi

bool wxRichTextFormattingDialog::ConvertFromString(const wxString& str, int& ret, int unit)
{
    if (unit == wxTEXT_ATTR_UNITS_PIXELS)
    {
        ret = wxAtoi(str);
        return true;
    }
    else if (unit == wxTEXT_ATTR_UNITS_TENTHS_MM)
    {
        float value = 0.0;
        wxSscanf(str.c_str(), wxT("%f"), &value);
        // Convert from cm
        // Do this in two steps, since using one step causes strange rounding error for VS 2010 at least.
        float v = (value * 100.0);
        ret = (int) (v);
        return true;
    }
    else if (unit == wxTEXT_ATTR_UNITS_PERCENTAGE)
    {
        ret = wxAtoi(str);
        return true;
    }
    else if (unit == wxTEXT_ATTR_UNITS_HUNDREDTHS_POINT)
    {
        float value = 0.0;
        wxSscanf(str.c_str(), wxT("%f"), &value);
        float v = (value * 100.0);
        ret = (int) (v);
    }
    else if (unit == wxTEXT_ATTR_UNITS_POINTS)
    {
        ret = wxAtoi(str);
        return true;
    }
    else
    {
        ret = 0;
        return false;
    }

    return true;
}
开发者ID:HanruZhou,项目名称:wxWidgets,代码行数:42,代码来源:richtextformatdlg.cpp

示例12: GetOption

int wxOptionValue::GetOption(const wxString& name, const wxChar *format, ...) const
{
    wxString n = GetOption(name);
    if (n.IsEmpty()) return 0;
    va_list argptr;
    va_start(argptr, format);
//  int i = wxVsscanf(n.c_str(), format, argptr); // VisualStudio doesn't have this
    int i = wxSscanf(n.c_str(), format, argptr);
    va_end(argptr);
    return i;
}
开发者ID:DowerChest,项目名称:codeblocks,代码行数:11,代码来源:optvalue.cpp

示例13: wxSscanf

void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale)
{
    if (tag.HasParam(wxT("WIDTH")))
    {
        int wdi;
        wxString wd = tag.GetParam(wxT("WIDTH"));

        if (wd[wd.Length()-1] == wxT('%'))
        {
            wxSscanf(wd.c_str(), wxT("%i%%"), &wdi);
            SetWidthFloat(wdi, wxHTML_UNITS_PERCENT);
        }
        else
        {
            wxSscanf(wd.c_str(), wxT("%i"), &wdi);
            SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS);
        }
        m_LastLayout = -1;
    }
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:20,代码来源:htmlcell.cpp

示例14: tokenizer

bool wxNativeEncodingInfo::FromString(const wxString& s)
{
    wxStringTokenizer tokenizer(s, wxT(";"));

    wxString encid = tokenizer.GetNextToken();

    // we support 2 formats: the old one (and still used if !wxUSE_FONTMAP)
    // used the raw encoding values but the new one uses the encoding names
    long enc;
    if ( encid.ToLong(&enc) )
    {
        // old format, intepret as encoding -- but after minimal checks
        if ( enc < 0 || enc >= wxFONTENCODING_MAX )
            return false;

        encoding = (wxFontEncoding)enc;
    }
    else // not a number, interpret as an encoding name
    {
#if wxUSE_FONTMAP
        encoding = wxFontMapper::GetEncodingFromName(encid);
        if ( encoding == wxFONTENCODING_MAX )
#endif // wxUSE_FONTMAP
        {
            // failed to parse the name (or couldn't even try...)
            return false;
        }
    }

    facename = tokenizer.GetNextToken();

    wxString tmp = tokenizer.GetNextToken();
    if ( tmp.empty() )
    {
        // default charset: but don't use DEFAULT_CHARSET here because it might
        // be different from the machine on which the file we had read this
        // encoding desc from was created
        charset = ANSI_CHARSET;
    }
    else
    {
        if ( wxSscanf(tmp, wxT("%u"), &charset) != 1 )
        {
            // should be a number!
            return false;
        }
    }

    return true;
}
开发者ID:Richard-Ni,项目名称:wxWidgets,代码行数:50,代码来源:fontutil.cpp

示例15: wxGetWindowText

int wxSpinCtrl::GetValue() const
{
    wxString val = wxGetWindowText(m_hwndBuddy);

    long n;
    if ( (wxSscanf(val, wxT("%ld"), &n) != 1) )
        n = INT_MIN;

    if ( n < m_min )
        n = m_min;
    if ( n > m_max )
        n = m_max;

    return n;
}
开发者ID:georgemoralis,项目名称:jpcsp2c,代码行数:15,代码来源:spinctrl.cpp


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