Example #1
0
wxString CompressedCachePath(wxString path)
{
#if defined(__WXMSW__)
    int colon = path.find(':', 0);
    path.Remove(colon, 1);
#endif
    
    /* replace path separators with ! */
    wxChar separator = wxFileName::GetPathSeparator();
    for(unsigned int pos = 0; pos < path.size(); pos = path.find(separator, pos))
        path.replace(pos, 1, _T("!"));

    //  Obfuscate the compressed chart file name, to (slightly) protect some encrypted raster chart data.
    wxCharBuffer buf = path.ToUTF8();
    unsigned char sha1_out[20];
    sha1( (unsigned char *) buf.data(), strlen(buf.data()), sha1_out );

    wxString sha1;
    for (unsigned int i=0 ; i < 20 ; i++){
        wxString s;
        s.Printf(_T("%02X"), sha1_out[i]);
        sha1 += s;
    }
    
    return g_Platform->GetPrivateDataDir() + separator + _T("raster_texture_cache") + separator + sha1;
    
}
wxArrayString nmeaSendObj::FindStartWithDollarSubSets(wxString FormatStr, wxString AllowdCharStr)
{  //Find pieces of text starting with'$' wich are the variables used
    size_t startpos=2;
    
    wxArrayString ReturnArray;

    {
        while ( (FormatStr.find( wxT("$"), startpos ) != wxNOT_FOUND) &&( startpos < FormatStr.Length() ))
        {
            startpos = FormatStr.find( wxT("$"), startpos );
            size_t i = startpos;
        
            while ( ( AllowdCharStr.find(FormatStr.Mid(i,1)) != (size_t)wxNOT_FOUND ) & 
                    ( i < FormatStr.Length() ) )
            {  
                i++;
            }
            
            wxString SubString= FormatStr.SubString( startpos, i-1 );
            // Check if Substring has a valid value. Should end with a digit
            long test = 0;
            wxString s;
            SplitStringAlphaDigit(SubString, s, test);
            if (( test > 0 ) && (SubString.Length() > 4))
                if ( ReturnArray.Index( SubString ) == wxNOT_FOUND )
                    {
                        ReturnArray.Add( SubString );
                    }
            startpos = i;
        } 
    }
    return ReturnArray;
}
void GetVolumeInfo(const wxString& path)
{
    // extract the volume 'C:\' or '\\tooter\share\' from the path
    wxString vol;
    
    if (path.substr(1, 2) == _T(":\\")) {
        vol = path.substr(0, 3);
    } else {
        if (path.substr(0, 2) == _T("\\\\")) {
            size_t i = path.find(_T('\\'), 2);

            if (i != wxString::npos && i > 2) {
                size_t j = path.find(_T('\\'), ++i);

                if (j != i)
                    vol = path.substr(0, j) + _T("\\");
            }
        }
    }

    // NULL means the current volume
    const wxChar *pVol = vol.empty() ? NULL : vol.c_str();

    if (!::GetVolumeInformation(pVol, NULL, 0, NULL, NULL,
                                &volumeFlags, 
                                volumeType,
                                WXSIZEOF(volumeType)))
        wxLogSysError(_T("GetVolumeInformation() failed"));

    volumeInfoInit = true;
}
Example #4
0
// On Windows, DrawText doesn't work with multiline text. This function also
// should take into account line wrapping.
static int
draw_ml(wxDC &dc, const wxString &text, int x, int y, int width) {
    int height = 0;
    int last_nl_pos = 0;
    int nl_pos = text.find('\n');
    wxString line;
    while (true) {
        line = text.substr(last_nl_pos, nl_pos);
        last_nl_pos = nl_pos + 1;
        
        if (line.empty()) {
            int lw, lh;
            dc.GetTextExtent(wxT("X"), &lw, &lh);
            height += lh;
        } else {
            dc.DrawText(line, x, y + height);
            
            int lw, lh;
            dc.GetTextExtent(line, &lw, &lh);
            height += lh;
        }
        
        if (nl_pos == -1)
            break;
        nl_pos = text.find('\n', last_nl_pos);
    }

    return height;
}
Example #5
0
bool URI::parseURI(const wxString& uri)
{
    wxString::size_type p = uri.find("://");               // find ://
    if (p == wxString::npos)
        return false;
    protocol = uri.substr(0, p);

    wxString::size_type p2 = uri.find("?", p);             // ?
    if (p2 == wxString::npos)
    {
        action = uri.substr(p + 3);
        params.clear();
        return true;
    }

    action = uri.substr(p + 3, p2 - p - 3);
    wxString par = uri.substr(p2 + 1);
    while (true)
    {
        p = par.find("&");
        if (p == wxString::npos)
        {
            addParam(par);
            break;
        }

        addParam(par.substr(0, p));
        par.erase(0, p + 1);
    }

    return true;
}
inline wxString RemoveWarnings(wxString const &input)
{
    wxString::size_type pos = input.find(wxT('\n'));

    if (pos == wxString::npos)
        return input;

    wxString::size_type lastPos = 0;
    wxString result;

    while (pos != wxString::npos)
    {
        wxString const &line = input.substr(lastPos, pos - lastPos);

        if (!line.StartsWith(wxT("warning:")))
        {
            result += line;
            result += wxT('\n');
        }

        lastPos = pos + 1;
        pos = input.find(wxT('\n'), lastPos);
    }

    if (lastPos < input.length())
        result += input.substr(lastPos, input.length() - lastPos);

    return result;
}
Example #7
0
void mmCalcValidator::OnChar(wxKeyEvent& event)
{
    if (!m_validatorWindow)
        return event.Skip();

    int keyCode = event.GetKeyCode();

    // we don't filter special keys and delete
    if (keyCode < WXK_SPACE || keyCode == WXK_DELETE || keyCode >= WXK_START)
        return event.Skip();


    wxString str((wxUniChar)keyCode, 1);
    if (!(wxIsdigit(str[0]) || wxString("+-.,*/ ()").Contains(str)))
    {
        if ( !wxValidator::IsSilent() )
            wxBell();

        return; // eat message
    }
    // only if it's a wxTextCtrl
    mmTextCtrl* text_field = wxDynamicCast(m_validatorWindow, mmTextCtrl);
    if (!m_validatorWindow || !text_field)
        return event.Skip();

    wxChar decChar = text_field->currency_->DECIMAL_POINT[0];
    bool numpad_dec_swap = (wxGetKeyState(wxKeyCode(WXK_NUMPAD_DECIMAL)) && decChar != str);
    
    if (numpad_dec_swap)
        str = wxString(decChar);

    // if decimal point, check if it's already in the string
    if (str == '.' || str == ',')
    {
        const wxString value = text_field->GetValue();
        size_t ind = value.rfind(decChar);
        if (ind < value.Length())
        {
            // check if after last decimal point there is an operation char (+-/*)
            if (value.find('+', ind + 1) >= value.Length() && value.find('-', ind + 1) >= value.Length() &&
                value.find('*', ind + 1) >= value.Length() && value.find('/', ind + 1) >= value.Length())
                return;
        }
    }

    if (numpad_dec_swap)
        return text_field->WriteText(str);
    else
        event.Skip();

}
wxString ExpandBackticks(wxString& str) // backticks are written in-place to str
{
    wxString ret;

    // this function is not windows-only anymore because we parse the backticked command's output
    // for compiler/linker search dirs

    size_t start = str.find(_T('`'));
    if (start == wxString::npos)
        return ret; // no backticks here
    size_t end = str.find(_T('`'), start + 1);
    if (end == wxString::npos)
        return ret; // no ending backtick; error?

    while (start != wxString::npos && end != wxString::npos)
    {
        wxString cmd = str.substr(start + 1, end - start - 1);
        cmd.Trim(true);
        cmd.Trim(false);
        if (cmd.IsEmpty())
            break;

        wxString bt;
        BackticksMap::iterator it = m_Backticks.find(cmd);
        if (it != m_Backticks.end()) // in the cache :)
            bt = it->second;
        else
        {
            Manager::Get()->GetLogManager()->DebugLog(F(_T("Caching result of `%s`"), cmd.wx_str()));
            wxArrayString output;
            if (platform::WindowsVersion() >= platform::winver_WindowsNT2000)
                wxExecute(_T("cmd /c ") + cmd, output, wxEXEC_NODISABLE);
            else
                wxExecute(cmd,                 output, wxEXEC_NODISABLE);
            bt = GetStringFromArray(output, _T(" "), false);
            // add it in the cache
            m_Backticks[cmd] = bt;
            Manager::Get()->GetLogManager()->DebugLog(_T("Cached"));
        }
        ret << bt << _T(' ');
        str = str.substr(0, start) + bt + str.substr(end + 1, wxString::npos);

        // find next occurrence
        start = str.find(_T('`'));
        end = str.find(_T('`'), start + 1);
    }

    return ret; // return a list of the replaced expressions
}
wxString DescriptorFrame::edit_partit(wxString partit)
{
	
	int erase_s=partit.Replace("<partitioning>","");
	int erase_e=partit.Replace("</partitioning>","");


	int erase_start=partit.find("<hostcollocation>");
		while (erase_start>0)
		{
			erase_start=partit.find("<hostcollocation>");
			int erase_end=partit.find("</hostcollocation>")+18;
			if (erase_end>18) 
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}

		} 

		

	erase_start=0;
	erase_start=partit.find("<processcollocation");
		while (erase_start>0)
		{
			erase_start=partit.find("<processcollocation");
			int erase_end=partit.find("</processcollocation>")+21;

			if (erase_end>21)
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}
			
		}	

		
	erase_start=0;
	erase_start=partit.find("<homeplacement");
		while (erase_start>0)
		{
			erase_start=1;
			erase_start=partit.find("<homeplacement");
			int erase_end=partit.find("</homeplacement>")+16;
			if (erase_end>16)
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}
						
		}
		
	
	return partit;

}
Example #10
0
bool StagePanel::DragSymbolTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data)
{
	wxString sType = data.substr(0, data.find(","));
	wxString sIndex = data.substr(data.find(",") + 1);

	long index;
	sIndex.ToLong(&index);

	if (sType == LibraryPanel::SYMBOL_LIST_NAME)
		m_panel->insertSymbol(index, x, y);
	else if (sType == LibraryPanel::SKELETON_LIST_NAME)
		m_panel->insertSkeleton(index, x, y);

	return true;
}
Example #11
0
void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
{
    // For compatibility with other ports (notably wxGTK) and because it's
    // genuinely useful, we allow passing multiline strings to DrawText().
    // However there is no native OSX function to draw them directly so we
    // instead reuse the generic DrawLabel() method to render them. Of course,
    // DrawLabel() itself will call back to us but with single line strings
    // only so there won't be any infinite recursion here.
    if ( str.find('\n') != wxString::npos )
    {
        GetOwner()->DrawLabel(str, wxRect(x, y, 0, 0));
        return;
    }

    wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") );

    if ( str.empty() )
        return;

    if ( !m_logicalFunctionSupported )
        return;

    if ( m_backgroundMode == wxTRANSPARENT )
        m_graphicContext->DrawText( str, x ,y);
    else
        m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush(m_textBackgroundColour) );

    wxCoord w, h;
    GetOwner()->GetTextExtent(str, &w, &h);
    CalcBoundingBox(x, y);
    CalcBoundingBox(x + w, y + h);
}
Example #12
0
void MANFrame::SetDirs(const wxString &dirs)
{
    if (!dirs.IsEmpty())
    {
        m_dirsVect.clear();
        size_t start_pos = 4; // len("man:")

        while (true)
        {
            size_t next_semi = dirs.find(_T(';'), start_pos);

            if ((int)next_semi == wxNOT_FOUND)
            {
                next_semi = dirs.Length();
            }

            m_dirsVect.push_back(dirs.SubString(start_pos, next_semi - 1));

            if (next_semi == dirs.Length())
            {
                break;
            }

            start_pos = next_semi + 1;
        }
    }
}
Example #13
0
void wxNumberFormatter::AddThousandsSeparators(wxString& s)
{
    // Thousands separators for numbers in scientific format are not relevant.
    if ( s.find_first_of("eE") != wxString::npos )
        return;

    wxChar thousandsSep;
    if ( !GetThousandsSeparatorIfUsed(&thousandsSep) )
        return;

    size_t pos = s.find(GetDecimalSeparator());
    if ( pos == wxString::npos )
    {
        // Start grouping at the end of an integer number.
        pos = s.length();
    }

    // End grouping at the beginning of the digits -- there could be at a sign
    // before their start.
    const size_t start = s.find_first_of("0123456789");

    // We currently group digits by 3 independently of the locale. This is not
    // the right thing to do and we should use lconv::grouping (under POSIX)
    // and GetLocaleInfo(LOCALE_SGROUPING) (under MSW) to get information about
    // the correct grouping to use. This is something that needs to be done at
    // wxLocale level first and then used here in the future (TODO).
    const size_t GROUP_LEN = 3;

    while ( pos > start + GROUP_LEN )
    {
        pos -= GROUP_LEN;
        s.insert(pos, thousandsSep);
    }
}
Example #14
0
wxString wxTarOutputStream::PaxHeaderPath(const wxString& format,
                                          const wxString& path)
{
    wxString d = path.BeforeLast(wxT('/'));
    wxString f = path.AfterLast(wxT('/'));
    wxString ret;

    if (d.empty())
        d = wxT(".");

    ret.reserve(format.length() + path.length() + 16);

    size_t begin = 0;

    for (;;) {
        size_t end;
        end = format.find('%', begin);
        if (end == wxString::npos || end + 1 >= format.length())
            break;
        ret << format.substr(begin, end - begin);
        switch ( format[end + 1].GetValue() ) {
            case 'd': ret << d; break;
            case 'f': ret << f; break;
            case 'p': ret << wxGetProcessId(); break;
            case '%': ret << wxT("%"); break;
        }
        begin = end + 2;
    }

    ret << format.substr(begin);

    return ret;
}
Example #15
0
void wxNumberFormatter::AddThousandsSeparators(wxString& s)
{
    wxChar thousandsSep;
    if ( !GetThousandsSeparatorIfUsed(&thousandsSep) )
        return;

    size_t pos = s.find(GetDecimalSeparator());
    if ( pos == wxString::npos )
    {
        // Start grouping at the end of an integer number.
        pos = s.length();
    }

    // We currently group digits by 3 independently of the locale. This is not
    // the right thing to do and we should use lconv::grouping (under POSIX)
    // and GetLocaleInfo(LOCALE_SGROUPING) (under MSW) to get information about
    // the correct grouping to use. This is something that needs to be done at
    // wxLocale level first and then used here in the future (TODO).
    const size_t GROUP_LEN = 3;

    while ( pos > GROUP_LEN )
    {
        pos -= GROUP_LEN;
        s.insert(pos, thousandsSep);
    }
}
bool UserVariableManager::Exists(const wxString& variable) const
{
    if (variable.find(_T('#')) == wxString::npos)
        return false;

    wxString member(variable.AfterLast(wxT('#')).BeforeFirst(wxT('.')).BeforeFirst(wxT(')')).MakeLower());
    return !m_CfgMan->Exists(cSets + m_ActiveSet + _T('/') + member + _T("/base"));
}
Example #17
0
//! pair has format: name=value
void URI::addParam(const wxString& pair)
{
    wxString::size_type p = pair.find("=");
    if (p == wxString::npos)
        params[pair] = "";
    else
        params[pair.substr(0, p)] = pair.substr(p + 1);
}
inline void RemoveBefore(wxString &str, const wxString &s)
{
    wxString::size_type pos = str.find(s);
    if (pos != wxString::npos)
    {
        str.Remove(0, pos+s.length());
        str.Trim(false);
    }
}
Example #19
0
bool ToolbarPanel::DropTarget::
OnDropText(wxCoord x, wxCoord y, const wxString& data)
{
	wxString sType = data.substr(0, data.find(","));
	wxString sIndex = data.substr(data.find(",") + 1);

	long index;
	sIndex.ToLong(&index);

	auto sym = m_library->GetSymbol(index);
	if (sym)
	{
		m_toolbar->OnAddChild(wxCommandEvent(), sym);
		m_stage->m_ps->Start();
	}

	return true;
}
Example #20
0
FileNameParser::Type FileNameParser::getFileType(const wxString& filename)
{
	if (filename.empty()) return e_unknown;

	int pos = filename.rfind('.');
	if (pos == -1) return e_unknown;

	std::string extension = filename.substr(pos);
	if (extension == ".txt")
	{
		const wxString txtName = filename.substr(0, filename.find_last_of('.'));
		if (txtName.find('_') == -1) return e_unknown;

		const wxString txtExtension = txtName.substr(txtName.find_last_of('_') + 1);

		if (txtExtension == TAG_POLYLINE) return e_polyline;
		else if (txtExtension == TAG_CIRCLE) return e_circle;
		else if (txtExtension == TAG_POLYGON) return e_polygon;
		else if (txtExtension == TAG_MESH) return e_mesh;
		else if (txtExtension == TAG_COMBINATION) return e_combination;
		else return e_unknown;
	}
	else if (extension == ".json")
	{
		const wxString jsonName = filename.substr(0, filename.find_last_of('.'));
		if (jsonName.find('_') == -1) return e_unknown;

		const wxString jsonExtension = jsonName.substr(jsonName.find_last_of('_') + 1);

		if (jsonExtension == TAG_SHAPE) return e_shape;
		else if (jsonExtension == TAG_COMPLEX) return e_complex;
		else if (jsonExtension == TAG_ANIM) return e_anim;
		else if (jsonExtension == TAG_PATCH) return e_9patch;
		else if (jsonExtension == TAG_FONTBLANK) return e_fontblank;
		else return e_unknown;
	}
	else
	{
		StringTools::toLower(extension);
		if (extension == ".jpg" || extension == ".png" || extension == ".bmp") return e_image;
		else return e_unknown;
	}
}
Example #21
0
wxFontWeight wxNativeFontInfo::GetWeight() const
{
    const wxString s = GetXFontComponent(wxXLFD_WEIGHT).MakeLower();
    if ( s.find(wxT("bold")) != wxString::npos || s == wxT("black") )
        return wxFONTWEIGHT_BOLD;
    else if ( s == wxT("light") )
        return wxFONTWEIGHT_LIGHT;

    return wxFONTWEIGHT_NORMAL;
}
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;
}
Example #23
0
void GLIShaders::SetShaderListData( const wxString &dataStr)
{
  //If there is no control, return
  if(!shaderListCtrl)
  {
    return;
  }

  //Reset the selected shader
  SetSelectedShader(-1);

  //To speed up inserting, hide the control temporarily
  shaderListCtrl->Hide();

  //Clear all the rows
  shaderListCtrl->DeleteAllItems();

  //Extract each row of data
  int startPos = 0;
  int endPos   = dataStr.find('*');

  while (endPos > 0)
  {
    //Extract a single shaders data
    wxString shaderData = dataStr.SubString(startPos, endPos-1);

    //Add a shader row
    AddShaderRow(0, shaderData);

    //Get the next start values
    startPos = endPos + 1;
    endPos   = dataStr.find('*',startPos);
  }

  //Re-show the control
  shaderListCtrl->Show();

  //Sort the data by the selected column
  SortList();

}
Example #24
0
// メッセージ中にキーワードが含まれているか
bool CIRCUser::isCalled(const wxString& message) const
{
	size_t size = m_keywords.size();
	for (size_t i = 0; i < size; i++){

		if (message.find(m_keywords[i]) != wxString::npos){
			return true;
		}
	}

	return false;
}
bool ThreadSearch::GetCursorWord(wxString& sWord)
{
    bool wordFound = false;
    sWord = wxEmptyString;

    // Gets active editor
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if ( ed != NULL )
    {
        cbStyledTextCtrl* control = ed->GetControl();

        sWord = control->GetSelectedText();
        if (sWord != wxEmptyString)
        {
            sWord.Trim(true);
            sWord.Trim(false);

            wxString::size_type pos = sWord.find(wxT('\n'));
            if (pos != wxString::npos)
            {
                sWord.Remove(pos, sWord.length() - pos);
                sWord.Trim(true);
                sWord.Trim(false);
            }

            return !sWord.IsEmpty();
        }

        // Gets word under cursor
        int pos = control->GetCurrentPos();
        int ws  = control->WordStartPosition(pos, true);
        int we  = control->WordEndPosition(pos, true);
        const wxString word = control->GetTextRange(ws, we);
        if (!word.IsEmpty()) // Avoid empty strings
        {
            sWord.Clear();
            while (--ws > 0)
            {
                const wxChar ch = control->GetCharAt(ws);
                if (ch <= _T(' '))
                    continue;
                else if (ch == _T('~'))
                    sWord << _T("~");
                break;
            }
            // m_SearchedWord will be used if 'Find occurrences' ctx menu is clicked
            sWord << word;
            wordFound = true;
        }
    }

    return wordFound;
}
Example #26
0
bool SpritesPanelImpl::DragSymbolTarget::
OnDropText(wxCoord x, wxCoord y, const wxString& data)
{
	wxString sType = data.substr(0, data.find(","));
	wxString sIndex = data.substr(data.find(",") + 1);

	long index;
	sIndex.ToLong(&index);

	ISymbol* symbol = m_panelImpl->m_libraryPanel->getSymbol(index);
	if (symbol)
	{
		Vector pos = m_panelImpl->m_editPanel->transPosScreenToProject(x, y);
		ISprite* sprite = SpriteFactory::create(symbol);
		sprite->translate(pos);
		m_panelImpl->insertSprite(sprite);
		sprite->release();
	}

	return true;
}
Example #27
0
MyFrame::MyFrame( bool stereoWindow )
       : wxFrame(NULL, wxID_ANY, "wxWidgets OpenGL Cube Sample")
{
    int stereoAttribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO, 0 };

    new TestGLCanvas(this, stereoWindow ? stereoAttribList : NULL);

    SetIcon(wxICON(sample));

    // Make a menubar
    wxMenu *menu = new wxMenu;
    menu->Append(wxID_NEW);
    menu->Append(NEW_STEREO_WINDOW, "New Stereo Window");
    menu->AppendSeparator();
    menu->Append(wxID_CLOSE);
    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append(menu, "&Cube");

    SetMenuBar(menuBar);

    CreateStatusBar();

    SetClientSize(400, 400);
    Show();

    // test IsDisplaySupported() function:
    static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
    wxLogStatus("Double-buffered display %s supported",
                wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");

    if ( stereoWindow )
    {
        const wxString vendor = glGetwxString(GL_VENDOR).Lower();
        const wxString renderer = glGetwxString(GL_RENDERER).Lower();
        if ( vendor.find("nvidia") != wxString::npos &&
                renderer.find("quadro") == wxString::npos )
            ShowFullScreen(true);
    }
}
void UserVariableManager::Preempt(const wxString& variable)
{
    if (variable.find(_T('#')) == wxString::npos)
        return;

    wxString member(variable.AfterLast(wxT('#')).BeforeFirst(wxT('.')).BeforeFirst(wxT(')')).MakeLower());

    if (!m_CfgMan->Exists(cSets + m_ActiveSet + _T('/') + member + _T("/base")) &&
            m_Preempted.Index(member) == wxNOT_FOUND)
    {
        m_Preempted.Add(member);
    }
}
Example #29
0
wxString CCodeParser::ParseBrackets(wxString code, int& functionStart)
{
    int openingBrackets = 0;
    int closingBrackets = 0;
    int index = 0;
    wxString Str;

    int functionLength = 0;
    index = code.find('{', functionStart);
    if (index != wxNOT_FOUND)
    {
        openingBrackets++;
        index++;
        functionStart = index;
        int loop = 0;
        while (openingBrackets > closingBrackets)
        {
            index = code.find_first_of(wxT("{}"), index);
            if (index == wxNOT_FOUND)
            {
                Str = code.Mid(functionStart, index);
                functionStart = index;
                return Str;
            }
            if (code.GetChar(index) == '{')
            {
                index++;
                openingBrackets++;
            }
            else
            {
                index++;
                closingBrackets++;
            }
            if (loop == 100)
            {
                return wxT("");
            }
            loop++;
        }
        index--;
        functionLength = index - functionStart;
    }
    else
    {
        wxMessageBox(wxT("no brackets found"));
    }
    Str = code.Mid(functionStart, functionLength);
    functionStart = functionStart + functionLength + 1;
    return Str;
}
Example #30
0
void CCodeParser::ParseCInclude(wxString code)
{
    int userIncludeEnd;
    m_userInclude = wxT("");

    //find the begining of the user include
    int userIncludeStart = code.Find(wxT("//// end generated include"));
    if (userIncludeStart != wxNOT_FOUND)
    {
        userIncludeStart = code.find(wxT('\n'), userIncludeStart);
        if (userIncludeStart != wxNOT_FOUND)
        {
            //find the end of the user include
            userIncludeEnd = code.find(wxT("\n/** Implementing "), userIncludeStart);

            if (userIncludeEnd != wxNOT_FOUND)
            {
                userIncludeStart++;
                m_userInclude = code.substr(userIncludeStart, userIncludeEnd - userIncludeStart);
            }
        }
    }
}