int wxStringFormatter::FindEndOfSymbol(wxString input)
{
	int pos = input.find_first_of(DELIMS);

	if(pos == wxNOT_FOUND)
	{
		return input.Len()-1;
	}
	return pos - 1;
}
예제 #2
0
CSplitRepeaterHeaderData::CSplitRepeaterHeaderData(const wxString& myCall1,  const wxString& myCall2, const wxString& yourCall,
						 const wxString& rptCall1, const wxString& rptCall2, unsigned char flag1,
						 unsigned char flag2, unsigned char flag3) :
m_id(0U),
m_flag1(flag1),
m_flag2(flag2),
m_flag3(flag3),
m_myCall1(NULL),
m_myCall2(NULL),
m_yourCall(NULL),
m_rptCall1(NULL),
m_rptCall2(NULL),
m_address(),
m_port(0U),
m_errors(0U)
{
	m_myCall1  = new unsigned char[LONG_CALLSIGN_LENGTH];
	m_myCall2  = new unsigned char[SHORT_CALLSIGN_LENGTH];
	m_yourCall = new unsigned char[LONG_CALLSIGN_LENGTH];
	m_rptCall1 = new unsigned char[LONG_CALLSIGN_LENGTH];
	m_rptCall2 = new unsigned char[LONG_CALLSIGN_LENGTH];

	::memset(m_myCall1,  ' ', LONG_CALLSIGN_LENGTH);
	::memset(m_myCall2,  ' ', SHORT_CALLSIGN_LENGTH);
	::memset(m_yourCall, ' ', LONG_CALLSIGN_LENGTH);
	::memset(m_rptCall1, ' ', LONG_CALLSIGN_LENGTH);
	::memset(m_rptCall2, ' ', LONG_CALLSIGN_LENGTH);

	for (unsigned int i = 0U; i < myCall1.Len() && i < LONG_CALLSIGN_LENGTH; i++)
		m_myCall1[i] = myCall1.GetChar(i);

	for (unsigned int i = 0U; i < myCall2.Len() && i < SHORT_CALLSIGN_LENGTH; i++)
		m_myCall2[i] = myCall2.GetChar(i);

	for (unsigned int i = 0U; i < yourCall.Len() && i < LONG_CALLSIGN_LENGTH; i++)
		m_yourCall[i] = yourCall.GetChar(i);

	for (unsigned int i = 0U; i < rptCall1.Len() && i < LONG_CALLSIGN_LENGTH; i++)
		m_rptCall1[i] = rptCall1.GetChar(i);

	for (unsigned int i = 0U; i < rptCall2.Len() && i < LONG_CALLSIGN_LENGTH; i++)
		m_rptCall2[i] = rptCall2.GetChar(i);
}
예제 #3
0
void wxVideoTerminal::Process(wxString str)
{
	unsigned int i;
	for (i=0; i<str.Len(); ++i)
		Consume(str.GetChar(i));

	m_counter_blink = 0;
	m_cursor_blink = true;
	Refresh(false);
}
예제 #4
0
Object RaceAnalyzerComm::ParseJSON(wxString &json){

	Object root;
	std::stringstream stream;
	for (size_t i = 0; i < json.Len(); i++){
		stream.put(json.ToAscii()[i]);
	}
	Reader::Read(root, stream);
	return root;
}
예제 #5
0
파일: xml.cpp 프로젝트: 252525fb/rpcs3
// Same as above, but create entities first.
// Translates '<' to "&lt;", '>' to "&gt;" and so on, according to the spec:
// http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
static void OutputEscapedString(wxOutputStream& stream,
                                const wxString& str,
                                wxMBConv *convMem,
                                wxMBConv *convFile,
                                EscapingMode mode)
{
    const size_t len = str.Len();

    wxString escaped;
    escaped.reserve( len );

    for (size_t i = 0; i < len; i++)
    {
        const wxChar c = str.GetChar(i);

        switch ( c )
        {
            case '<':
                escaped.append(wxT("&lt;"));
                break;
            case '>':
                escaped.append(wxT("&gt;"));
                break;
            case '&':
                escaped.append(wxT("&amp;"));
                break;
            case '\r':
                escaped.append(wxT("&#xD;"));
                break;
            default:
                if ( mode == Escape_Attribute )
                {
                    switch ( c )
                    {
                        case '"':
                            escaped.append(wxT("&quot;"));
                            break;
                        case '\t':
                            escaped.append(wxT("&#x9;"));
                            break;
                        case '\n':
                            escaped.append(wxT("&#xA;"));
                            break;
                        default:
                            escaped.append(c);
                    }
                }
                else
                {
                    escaped.append(c);
                }
        }
    }
    OutputString(stream, escaped, convMem, convFile);
}
bool CUtils::StrToItemIntegerType(const wxString & str, long &d)
{
    wxChar *pEnd;

    errno = 0;

    bool bHex = (str.Len() > 2 && str[0] == wxT('0') && (str[1] == wxT('x') || str[1] == wxT('X')));

    d = wxStrtol(str, &pEnd, bHex ? 16 : 10);
    return (errno == 0 && (*pEnd == wxT('\0')));
}
예제 #7
0
bool Utils::ContainsInvalidPathChars(wxString path, bool allowExclamationMark)
{
	for (size_t i = 0; i < path.Len(); i++)
	{
		if (wxFileName::GetForbiddenChars().Contains(path[i]) || !(allowExclamationMark || path[i] != '!'))
		{
			return true;
		}
	}
	return false;
}
예제 #8
0
/****************************************************************************
REMARKS:
None of the Reverse Find functions in wxWindows appear to work in a way that
can be used by our code. This includes the libstr rfind implementations which
do not correctly pass the given return value.
****************************************************************************/
int ReverseFind(
    const wxString &tstr,
    const wxString &str,
    int start = -1)
{
    wxASSERT( str.GetStringData()->IsValid() );

    // TODO could be made much quicker than that
    int p = tstr.Len()-str.Len()-1;
    int p2 = start-str.Len();

    // if the user supplied a valid start point, use it
    if (start != -1 && p > p2) p = p2;
    while ( p >= 0 ) {
        if ( wxStrncmp(tstr.c_str() + p, str.c_str(), str.Len()) == 0 )
            return p;
        p--;
        }
    return -1;
}
예제 #9
0
wxString Utils::RemoveInvalidPathChars(wxString path, wxChar replaceWith, bool allowExclamationMark)
{
	for (size_t i = 0; i < path.Len(); i++)
	{
		if (wxFileName::GetForbiddenChars().Contains(path[i]) || !(allowExclamationMark || path[i] != '!'))
		{
			path[i] = replaceWith;
		}
	}
	return path;
}
예제 #10
0
파일: uimanager.cpp 프로젝트: bihai/fbide
void UiManager::SetTitle (const wxString & title)
{
    wxString newTitle;

    if (title.Len())
        newTitle << _T("FBIde - ") << title;
    else
        newTitle << _T("FBIde");

    m_frame->SetTitle (newTitle);
}
예제 #11
0
wxString GOrgueConfigFileReader::GetNextLine(const wxString& buffer, unsigned &pos)
{
	int newpos = buffer.find(wxT("\n"), pos);
	if (newpos < (int)pos)
		newpos = buffer.Len();
	wxString line = buffer.Mid(pos, newpos - pos);
	pos = newpos + 1;
	if (line.Len() > 0 && line[line.Len() - 1] == wxT('\r'))
		return line.Mid(0, line.Len() - 1);
	return line;
}
예제 #12
0
wxString StringFindReplacer::GetString(const wxString& input, int from, bool search_up)
{
    if (from < 0) {
        from = 0;
    }

    if ( !search_up ) {

        if (from >= (int)input.Len()) {
            return wxEmptyString;
        }
        return input.Mid((size_t)from);

    } else {
        if (from >= (int)input.Len()) {
            from = (int)input.Len();
        }
        return input.Mid(0, (size_t)from);
    }
}
예제 #13
0
/** Does given file contain catalogs in given language?
    Handles these cases:
      - foo/bar/lang.mo
      - foo/lang/bar.mo
      - foo/lang/LC_MESSAGES/bar.mo
    Futhermore, if \a lang is 2-letter code (e.g. "cs"), handles these:
      - foo/bar/lang_??.mo
      - foo/lang_??/bar.mo
      - foo/lang_??/LC_MESSAGES/bar.mo
    and if \a lang is five-letter code (e.g. "cs_CZ"), tries to match its
    first two letters (i.e. country-neutral variant of the language).
 */
static inline bool IsForLang(const wxString& filename, const wxString& lang,
                             bool variants = true)
{
#ifdef __WINDOWS__
    #define LC_MESSAGES_STR "/lc_messages"
#else
    #define LC_MESSAGES_STR "/LC_MESSAGES"
#endif
    wxString base, dir;
    wxSplitPath(filename, &dir, &base, NULL);
    dir.Replace(wxString(wxFILE_SEP_PATH), "/");
    return base.Matches(lang) ||
           dir.Matches("*/" + lang) ||
           dir.Matches("*/" + lang + LC_MESSAGES_STR) ||
           (variants && lang.Len() == 5 && lang[2] == _T('_') && 
                IsForLang(filename, lang.Mid(0, 2), false)) ||
           (variants && lang.Len() == 2 && 
                IsForLang(filename, lang + "_??", false));
    #undef LC_MESSAGES_STR
}
예제 #14
0
bool ecUtils::StrToItemIntegerType(const wxString & str, long &d)
{
	wxChar* pEnd;
	bool rc;
	errno=0;
	bool bHex=(str.Len() > 2 && str[0]==wxT('0') && (str[1]==wxT('x')||str[1]==wxT('X')));
	//d=_tcstol(str,&pEnd,bHex?16:10);
	d=wxStrtol(str,&pEnd,bHex?16:10);
	rc=(0==errno && (*pEnd==wxT('\0')));
	return rc;
}
예제 #15
0
INLINE 
void wxeReturn::add(const wxString s) {
    int strLen = s.Len();
    wxCharBuffer resultCB = s.mb_str(utfConverter);
    int * resultPtr = (int *) resultCB.data();

    for (int i = 0; i < strLen; i++, resultPtr++) {
        addInt(*resultPtr);
    }
    endList(strLen);       
}
예제 #16
0
wxString FbGenres::DecodeList(const wxString &genres)
{
	wxCriticalSectionLocker locker(sm_section);
	wxString result;
	for (size_t i = 0; i<genres.Len(); i += 2) {
		if (i) result << wxT(',') << wxT(' ');
		wxString code = genres.SubString(i, i + 1);
		result << sm_names[code];
	}
	return result;
}
예제 #17
0
파일: cmdline.cpp 프로젝트: mark711/Cafu
    wxCmdLineOption(wxCmdLineEntryType k,
                    const wxString& shrt,
                    const wxString& lng,
                    const wxString& desc,
                    wxCmdLineParamType typ,
                    int fl)
    {
        // wxCMD_LINE_USAGE_TEXT uses only description, shortName and longName is empty
        if ( k != wxCMD_LINE_USAGE_TEXT )
        {
            wxASSERT_MSG
            (
                !shrt.empty() || !lng.empty(),
                 wxT("option should have at least one name")
            );

            wxASSERT_MSG
            (
                GetShortOptionName(shrt.begin(), shrt.end()).Len() == shrt.Len(),
                wxT("Short option contains invalid characters")
            );

            wxASSERT_MSG
            (
                GetLongOptionName(lng.begin(), lng.end()).Len() == lng.Len(),
                wxT("Long option contains invalid characters")
            );
        }

        kind = k;

        shortName = shrt;
        longName = lng;
        description = desc;

        type = typ;
        flags = fl;

        m_hasVal = false;
        m_isNegated = false;
    }
예제 #18
0
파일: vfsDevice.cpp 프로젝트: Ailick/rpcs3
u32 vfsDevice::CmpLocalPath(const wxString& local_path)
{
	const u32 lim = min(m_local_path.Len(), local_path.Len());
	u32 ret = 0;

	for(u32 i=0; i<lim; ++i, ++ret)
	{
		if(m_local_path[i] != local_path[i]) break;
	}

	return ret;
}
예제 #19
0
void RaceAnalyzerComm::SwapCharsInsideQuotes(wxString &data, char find,char replace){
	bool insideQuotes = false;
	int len = data.Len();
	for (int index = 0; index < len; index++){
		if (data[index] == '"'){
			insideQuotes = !insideQuotes;
		}
		else if (data[index] == find && insideQuotes){
			data[index] = replace;
		}
	}
}
예제 #20
0
    EFileType FileType(const wxString& filename, bool force_refresh)
    {
        static bool          cfg_read  = false;
        static bool          empty_ext = true;
        static wxArrayString header_ext;
        static wxArrayString source_ext;

        if (!cfg_read || force_refresh)
        {
            ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
            empty_ext               = cfg->ReadBool(_T("/empty_ext"), true);
            wxString header_ext_str = cfg->Read(_T("/header_ext"), _T("h,hpp,tcc,xpm"));
            wxString source_ext_str = cfg->Read(_T("/source_ext"), _T("c,cpp,cxx,cc,c++"));

            header_ext.Clear();
            wxStringTokenizer header_ext_tknzr(header_ext_str, _T(","));
            while (header_ext_tknzr.HasMoreTokens())
                header_ext.Add(header_ext_tknzr.GetNextToken().Trim(false).Trim(true).Lower());

            source_ext.Clear();
            wxStringTokenizer source_ext_tknzr(source_ext_str, _T(","));
            while (source_ext_tknzr.HasMoreTokens())
                source_ext.Add(source_ext_tknzr.GetNextToken().Trim(false).Trim(true).Lower());

            cfg_read = true; // caching done
        }

        if (filename.IsEmpty())
            return ParserCommon::ftOther;

        const wxString file = filename.AfterLast(wxFILE_SEP_PATH).Lower();
        const int      pos  = file.Find(_T('.'), true);
        wxString       ext;
        if (pos != wxNOT_FOUND)
            ext = file.SubString(pos + 1, file.Len());

        if (empty_ext && ext.IsEmpty())
            return ParserCommon::ftHeader;

        for (size_t i=0; i<header_ext.GetCount(); ++i)
        {
            if (ext==header_ext[i])
                return ParserCommon::ftHeader;
        }

        for (size_t i=0; i<source_ext.GetCount(); ++i)
        {
            if (ext==source_ext[i])
                return ParserCommon::ftSource;
        }

        return ParserCommon::ftOther;
    }
예제 #21
0
파일: vfsDevice.cpp 프로젝트: Ailick/rpcs3
u32 vfsDevice::CmpPs3Path(const wxString& ps3_path)
{
	const u32 lim = min(m_ps3_path.Len(), ps3_path.Len());
	u32 ret = 0;

	for(u32 i=0; i<lim; ++i, ++ret)
	{
		if(m_ps3_path[i] != ps3_path[i]) break;
	}

	return ret;
}
/* static */ bool IStateStore::SaveString(wxOutputStream& output, const wxString& txt)
{
	wxInt32 len = txt.Len();

	if ( SaveSimpleType<wxInt32>(output, len) )
	{
		len *= sizeof(wchar_t);
		output.Write(txt.c_str().AsWChar(), len );
		return CheckLastWrite(output, len);
	}
	return false;
}
예제 #23
0
void Function::SetContents(wxString contents)
{
    if(contents.Left(1) == '\n')
    {
        contents.Remove(0, 1);
    }
    if(contents.Right(1) == '\n')
    {
        contents.Remove(contents.Len() -1, 1);
    }
    m_functionContents = contents;
}
예제 #24
0
파일: util.cpp 프로젝트: codegooglecom/wtfu
void wtfMakeFilesList(const wxString& text, wxArrayString *list)
{
    size_t i = 0;
    size_t j;
    wxString filename;

    while (i < text.Len())
    {
        while ((text.Mid(i, 1) == wxT(" ")) || (text.Mid(i, 1) == wxT(",")))
        {
            i++;
        }
        if (text.Mid(i, 1) == wxT("\""))
        {
            i++;
            if (i >= text.Len())
            {
                break;
            }
            j = text.Mid(i).Find(wxT("\""));
        } else {
            j = text.Mid(i).Find(wxT(","));
        }
        if (j == (size_t) wxNOT_FOUND)
        {
            filename = text.Mid(i);
            i = text.Len();
        } else {
            filename = text.Mid(i, j);
            i += j + 1;
        }
        filename.Trim(false);
        filename.Trim(true);
        if (filename.Len() > 0)
        {
            list->Add(filename);
        }
    }
    filename.Clear();
}
예제 #25
0
PreprocessorType Tokenizer::GetPreprocessorType()
{
    const unsigned int undoIndex = m_TokenIndex;
    const unsigned int undoLine = m_LineNumber;

    MoveToNextChar();
    while (SkipWhiteSpace() || SkipComment())
        ;

    const wxString token = DoGetToken();

    switch (token.Len())
    {
    case 2:
        if (token == TokenizerConsts::kw_if)
            return ptIf;
        break;

    case 4:
        if (token == TokenizerConsts::kw_else)
            return ptElse;
        else if (token == TokenizerConsts::kw_elif)
            return ptElif;
        break;

    case 5:
        if (token == TokenizerConsts::kw_ifdef)
            return ptIfdef;
        else if (token == TokenizerConsts::kw_endif)
            return ptEndif;
        break;

    case 6:
        if (token == TokenizerConsts::kw_ifndef)
            return ptIfndef;
        break;

    case 7:
        if (token == TokenizerConsts::kw_elifdef)
            return ptElifdef;
        break;

    case 8:
        if (token == TokenizerConsts::kw_elifndef)
            return ptElifndef;
        break;
    }

    m_TokenIndex = undoIndex;
    m_LineNumber = undoLine;
    return ptOthers;
}
예제 #26
0
static size_t FirstSpecialChar(const wxString& str)
{
	for (size_t pos = 0; pos < str.Len(); pos++) {
		if (!str.GetChar(pos).IsAscii()) {
			continue;
		}
		const unsigned char uc = str.GetChar(pos);
		if (uc == 0x1f || uc == 0x1d || uc == 0x03 || uc == 0x02 || uc == 0x016 || uc == 0x0F) { //get all text until first irc color is found
			return pos;
		}
	}
	return -1;
}
/* static */ bool IStateStore::WriteLine(wxOutputStream& output, const wxString& txt)
{
	wxInt32 len = txt.Len();
	output.Write(txt.c_str(), len );
	bool ret = CheckLastWrite(output, len);
	
	if (ret)
	{
		output.Write("\r", 1); 
	}
	
	return ret;
}
예제 #28
0
void eventos_negacion::limpia_espacios(wxString &tex){
	int i=0;
	unsigned int selector= tex.Len();
	wxString tex2;
	wxString blanco=wxT(" ");
	for(unsigned int j=0;j<=selector;j++){
		if (tex[j]!=blanco){
			tex2+=tex[j];
			i++;
		}
	}
	tex=tex2;
}
예제 #29
0
static wxString Shorten(const wxString &filename, int length)
{
	if (filename.Len() <= (size_t)length) return filename;

	wxString ext;
	int pos = filename.Find(wxT('.'), true);
	if (pos != wxNOT_FOUND) ext = filename.Mid(pos);

	FbString result = filename;
	result.Truncate(pos);
	result = result.AfterLast(wxT('/'));
	return result.Shorten(length) << ext;
}
예제 #30
0
파일: misc.cpp 프로젝트: swflb/pgadmin3
static bool needsQuoting(wxString &value, bool forTypes)
{
	// Is it a number?
	if (value.IsNumber())
		return true;
	else
	{
		// certain types should not be quoted even though it contains a space. Evilness.
		wxString valNoArray;
		if (forTypes && value.Right(2) == wxT("[]"))
			valNoArray = value.Mid(0, value.Len() - 2);
		else
			valNoArray = value;

		if (forTypes &&
		        (!valNoArray.CmpNoCase(wxT("character varying")) ||
		         !valNoArray.CmpNoCase(wxT("\"char\"")) ||
		         !valNoArray.CmpNoCase(wxT("bit varying")) ||
		         !valNoArray.CmpNoCase(wxT("double precision")) ||
		         !valNoArray.CmpNoCase(wxT("timestamp without time zone")) ||
		         !valNoArray.CmpNoCase(wxT("timestamp with time zone")) ||
		         !valNoArray.CmpNoCase(wxT("time without time zone")) ||
		         !valNoArray.CmpNoCase(wxT("time with time zone")) ||
		         !valNoArray.CmpNoCase(wxT("\"trigger\"")) ||
		         !valNoArray.CmpNoCase(wxT("\"unknown\""))))
			return false;

		int pos = 0;
		while (pos < (int)valNoArray.length())
		{
			wxChar c = valNoArray.GetChar(pos);
			if (!((pos > 0) && (c >= '0' && c <= '9')) &&
			        !(c >= 'a' && c  <= 'z') &&
			        !(c == '_'))
			{
				return true;
			}
			pos++;
		}
	}

	// is it a keyword?
	const ScanKeyword *sk = ScanKeywordLookup(value.ToAscii());
	if (!sk)
		return false;
	if (sk->category == UNRESERVED_KEYWORD)
		return false;
	if (forTypes && sk->category == COL_NAME_KEYWORD)
		return false;
	return true;
}