示例#1
0
unsigned long wxStrtoul_l(const char* str, char **endptr, int base, const wxXLocale& loc)
{
    wxCHECK( loc.IsOk(), 0 );

    CNumericLocaleSetter locSetter;

    return wxStrtoul(str, endptr, base);
}
示例#2
0
void PluginFilterProcess::ProcessStdErr()
{
//	TRACEUSER("Gerry", _T("PluginFilterProcess::ProcessStdErr"));

	if (IsErrorAvailable())
	{
		wxTextInputStream tis(*GetErrorStream());

		// This assumes that the output is always line buffered
//		while (!GetErrorStream()->Eof())
		while (IsErrorAvailable())
		{
			wxString line;
			line << tis.ReadLine();
//			TRACEUSER("Gerry", _T("(stderr):%s"), line.c_str());

			if (!line.IsEmpty())
			{
				// If line begins "MESSAGE:" then it is a debug message and can be discarded
				wxString rest;
				if (line.StartsWith(_T("MESSAGE:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFDebug:%s"), rest.c_str());
				}
				else if (line.StartsWith(_T("PROGRESS:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFProgress:%s"), rest.c_str());
					if (m_pFilter)
					{
						unsigned long /*TYPENOTE: Correct*/ Val = wxStrtoul(rest.c_str(), NULL, 10);
						if (Val > 0)
						{
//							TRACEUSER("Gerry", _T("Setting progress to %d"), Val);
							m_pFilter->SetProgressBarCount((UINT32)Val);
						}
					}
				}
				else if (line.StartsWith(_T("WARNING:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFWarning:%s"), rest.c_str());
					m_Warnings.Add(rest);
				}
				else if (line.StartsWith(_T("ERROR:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFError:%s"), rest.c_str());
					m_Errors.Add(rest);
				}
				else
				{
//					TRACEUSER("Gerry", _T("Skipping stderr:%s"), line.c_str());
//					m_Errors.Add(line);
				}
			}
		}
	}
}
示例#3
0
wxUint32 wxTextInputStream::Read32(int base)
{
    wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") );
    if(!m_input) return 0;

    wxString word = ReadWord();
    if(word.empty())
        return 0;
    return wxStrtoul(word.c_str(), 0, base);
}
示例#4
0
文件: helpext.cpp 项目: EdgarTx/wx
bool wxExtHelpController::ParseMapFileLine(const wxString& line)
{
    const wxChar *p = line.c_str();

    // skip whitespace
    while ( isascii(*p) && isspace(*p) )
        p++;

    // skip empty lines and comments
    if ( *p == _T('\0') || *p == WXEXTHELP_COMMENTCHAR )
        return true;

    // the line is of the form "num url" so we must have an integer now
    wxChar *end;
    const unsigned long id = wxStrtoul(p, &end, 0);

    if ( end == p )
        return false;

    p = end;
    while ( isascii(*p) && isspace(*p) )
        p++;

    // next should be the URL
    wxString url;
    url.reserve(line.length());
    while ( isascii(*p) && !isspace(*p) )
        url += *p++;

    while ( isascii(*p) && isspace(*p) )
        p++;

    // and finally the optional description of the entry after comment
    wxString doc;
    if ( *p == WXEXTHELP_COMMENTCHAR )
    {
        p++;
        while ( isascii(*p) && isspace(*p) )
            p++;
        doc = p;
    }

    m_MapList->Append(new wxExtHelpMapEntry(id, url, doc));
    m_NumOfEntries++;

    return true;
}
示例#5
0
int wxRegExImpl::Replace(wxString *text,
                         const wxString& replacement,
                         size_t maxMatches) const
{
    wxCHECK_MSG( text, wxNOT_FOUND, wxT("NULL text in wxRegEx::Replace") );
    wxCHECK_MSG( IsValid(), wxNOT_FOUND, wxT("must successfully Compile() first") );

    // the input string
#ifndef WXREGEX_CONVERT_TO_MB
    const wxChar *textstr = text->c_str();
    size_t textlen = text->length();
#else
    const wxWX2MBbuf textstr = WXREGEX_CHAR(*text);
    if (!textstr)
    {
        wxLogError(_("Failed to find match for regular expression: %s"),
                   GetErrorMsg(0, true).c_str());
        return 0;
    }
    size_t textlen = strlen(textstr);
    text->clear();
#endif

    // the replacement text
    wxString textNew;

    // the result, allow 25% extra
    wxString result;
    result.reserve(5 * textlen / 4);

    // attempt at optimization: don't iterate over the string if it doesn't
    // contain back references at all
    bool mayHaveBackrefs =
        replacement.find_first_of(wxT("\\&")) != wxString::npos;

    if ( !mayHaveBackrefs )
    {
        textNew = replacement;
    }

    // the position where we start looking for the match
    size_t matchStart = 0;

    // number of replacement made: we won't make more than maxMatches of them
    // (unless maxMatches is 0 which doesn't limit the number of replacements)
    size_t countRepl = 0;

    // note that "^" shouldn't match after the first call to Matches() so we
    // use wxRE_NOTBOL to prevent it from happening
    while ( (!maxMatches || countRepl < maxMatches) &&
             Matches(
#ifndef WXREGEX_CONVERT_TO_MB
                    textstr + matchStart,
#else
                    textstr.data() + matchStart,
#endif
                    countRepl ? wxRE_NOTBOL : 0
                    WXREGEX_IF_NEED_LEN(textlen - matchStart)) )
    {
        // the string possibly contains back references: we need to calculate
        // the replacement text anew after each match
        if ( mayHaveBackrefs )
        {
            mayHaveBackrefs = false;
            textNew.clear();
            textNew.reserve(replacement.length());

            for ( const wxChar *p = replacement.c_str(); *p; p++ )
            {
                size_t index = (size_t)-1;

                if ( *p == wxT('\\') )
                {
                    if ( wxIsdigit(*++p) )
                    {
                        // back reference
                        wxChar *end;
                        index = (size_t)wxStrtoul(p, &end, 10);
                        p = end - 1; // -1 to compensate for p++ in the loop
                    }
                    //else: backslash used as escape character
                }
                else if ( *p == wxT('&') )
                {
                    // treat this as "\0" for compatbility with ed and such
                    index = 0;
                }

                // do we have a back reference?
                if ( index != (size_t)-1 )
                {
                    // yes, get its text
                    size_t start, len;
                    if ( !GetMatch(&start, &len, index) )
                    {
                        wxFAIL_MSG( wxT("invalid back reference") );

                        // just eat it...
                    }
                    else
                    {
                        textNew += wxString(
#ifndef WXREGEX_CONVERT_TO_MB
                                textstr
#else
                                textstr.data()
#endif
                                + matchStart + start,
                                *wxConvCurrent, len);

                        mayHaveBackrefs = true;
                    }
                }
                else // ordinary character
                {
                    textNew += *p;
                }
            }
        }

        size_t start, len;
        if ( !GetMatch(&start, &len) )
        {
            // we did have match as Matches() returned true above!
            wxFAIL_MSG( wxT("internal logic error in wxRegEx::Replace") );

            return wxNOT_FOUND;
        }

        // an insurance against implementations that don't grow exponentially
        // to ensure building the result takes linear time
        if (result.capacity() < result.length() + start + textNew.length())
            result.reserve(2 * result.length());

#ifndef WXREGEX_CONVERT_TO_MB
        result.append(*text, matchStart, start);
#else
        result.append(wxString(textstr.data() + matchStart, *wxConvCurrent, start));
#endif
        matchStart += start;
        result.append(textNew);

        countRepl++;

        matchStart += len;
    }

#ifndef WXREGEX_CONVERT_TO_MB
    result.append(*text, matchStart, wxString::npos);
#else
    result.append(wxString(textstr.data() + matchStart, *wxConvCurrent));
#endif
    *text = result;

    return countRepl;
}
示例#6
0
unsigned long wxStrtoul_l(const char* str, char **endptr, int base, const wxXLocale& loc)
{
    IMPLEMENT_STRTOX_L_START
    unsigned long ret = wxStrtoul(str, endptr, base);
    IMPLEMENT_STRTOX_L_END
}
示例#7
0
文件: Conf.cpp 项目: tsiru/pcsx2
void LoadConfig()
{
	wxChar szValue[256];
	const wxString iniFile(Path::Combine(s_strIniPath, L"zzogl-pg-cg.ini"));

	memset(&conf, 0, sizeof(conf));
	conf.interlace = 0; // on, mode 1
	conf.mrtdepth = 1;
	conf.zz_options._u32 = 0;
	conf.hacks._u32 = 0;
	conf.bilinear = 1;
	conf.width = 640;
	conf.height = 480;
	conf.SkipDraw = 0;
	conf.disableHacks = 0;

	FILE *fp = wxFopen(iniFile, L"rt");

	if (!fp)
	{
		SysMessage("Unable to open ZZOgl-PG's ini file!");
		CreateDirectory(s_strIniPath, NULL);
		SaveConfig();//save and return
		return ;
	}

	fclose(fp);

	GetPrivateProfileString(L"Settings", L"Interlace", NULL, szValue, 20, iniFile);
	conf.interlace = (u8)wxStrtoul(szValue, NULL, 10);
	GetPrivateProfileString(L"Settings", L"Antialiasing", NULL, szValue, 20, iniFile);
	conf.aa = (u8)wxStrtoul(szValue, NULL, 10);
	GetPrivateProfileString(L"Settings", L"ZZOptions", NULL, szValue, 20, iniFile);
	conf.zz_options._u32 = wxStrtoul(szValue, NULL, 10);
	GetPrivateProfileString(L"Settings", L"AdvancedOptions", NULL, szValue, 20, iniFile);
	conf.hacks._u32 = wxStrtoul(szValue, NULL, 10);
	GetPrivateProfileString(L"Settings", L"Bilinear", NULL, szValue, 20, iniFile);
	conf.bilinear = (u8)wxStrtoul(szValue, NULL, 10);
	GetPrivateProfileString(L"Settings", L"Width", NULL, szValue, 20, iniFile);
	conf.width = wxStrtoul(szValue, NULL, 10);
	GetPrivateProfileString(L"Settings", L"Height", NULL, szValue, 20, iniFile);
	conf.height = wxStrtoul(szValue, NULL, 10);
	GetPrivateProfileString(L"Settings", L"SkipDraw", NULL, szValue, 20, iniFile);
	conf.SkipDraw = wxStrtoul(szValue, NULL, 10);

	if (conf.aa < 0 || conf.aa > 4) conf.aa = 0;

	conf.isWideScreen = (conf.widescreen() != 0);

	switch (conf.zz_options.dimensions)
	{
		case GSDim_640:
			conf.width = 640;
			conf.height = conf.isWideScreen ? 360 : 480;
			break;

		case GSDim_800:
			conf.width = 800;
			conf.height = conf.isWideScreen ? 450 : 600;
			break;

		case GSDim_1024:
			conf.width = 1024;
			conf.height = conf.isWideScreen ? 576 : 768;
			break;

		case GSDim_1280:
			conf.width = 1280;
			conf.height = conf.isWideScreen ? 720 : 960;
			break;
	}

	// turn off all hacks by default
	conf.setWireframe(false);
	conf.setCaptureAvi(false);
	conf.setLoaded(true);

	if (conf.width <= 0 || conf.height <= 0)
	{
		conf.width = 640;
		conf.height = 480;
	}
}