wxArrayString ParseQueries(const wxString& strQuery)
{
  wxArrayString returnArray;
  bool bInQuote = false;
  int nLast = 0;

  for ( int i=0; i<(int)strQuery.Length(); i++ )
  {
      if ( strQuery.SubString(i, i) == _T("'") )
          bInQuote = !bInQuote;
      else if ( strQuery.SubString(i, i) == _T(";") && !bInQuote )
      {
          wxString str;
          str << strQuery.SubString(nLast, i);
          if (!IsEmptyQuery(str))
            returnArray.Add( str );

          nLast = i + 1;
      }
  }

  if ( nLast < (int)strQuery.Length() -1 )
  {
      wxString str;
      str << strQuery.SubString(nLast, strQuery.Length() - 1) << _T(";");
      if (!IsEmptyQuery(str))
        returnArray.Add( str );
  }

  return returnArray;
}
Esempio n. 2
0
TMotion::TMotion(const wxString& type, const wxString& length)
{
    // In case of an error, default to linear growth across one second.
    duration = 1000;
    this->type = Linear;

    if (type == "" || type == "linear")
        this->type = Linear;
    else if (type == "exponential")
        this->type = Exponential;
    else if (type == "logarthmic")
        this->type = Logarithmic;
    else
        wxGetApp().Errorf("Unrecognized motion type '%s'.\n", type.c_str());

    if (length == "") {
        wxGetApp().Errorf("Motion length not specified.\n");
    } else if (length.Contains("ms")) { // milliseconds
        if (!length.SubString(0, length.Length() - 3).ToULong((unsigned long*) &duration))
            wxGetApp().Errorf("Invalid number: '%s'.\n", length.c_str());
    } else if (length.Contains("s")) { // seconds
        if (!length.SubString(0, length.Length() - 2).ToULong((unsigned long*) &duration))
            wxGetApp().Errorf("Invalid number: '%s'.\n", length.c_str());
        else
            duration *= 1000;
    } else if (length.Contains("min")) { // minutes
        if (!length.SubString(0, length.Length() - 4).ToULong((unsigned long*) &duration))
            wxGetApp().Errorf("Invalid number: '%s'.\n", length.c_str());
        else
            duration *= 1000 * 60;
    } else {
        wxGetApp().Errorf("Motion length must be end in one of : {s, ms, min}.\n");
    }
}
Esempio n. 3
0
void GroupWindow::ProcessGroupData( wxString text )
{
    wxString outText;

    int numMembers = 0;
    while(1)
    {
        int pos = text.Find(wxChar(':'));
        if( pos == wxNOT_FOUND || pos == 0 )
		    break;
        outText = text.SubString(0, (pos-1));
	    ProcessGroupMember(outText); // Could crash if we didn't allocate enough lines.
	    text = text.SubString((pos+1), (text.Length() - 1));
        numMembers++;
    }
    if( numMembers < 8 )
    {
        for( int x = numMembers; x < 8; x++ )
        {
            ShowMember(x, false);
        }
    }
    Refresh();
    return;
}
polinomio interprete::StringAPoli(wxString poli)//Pasar a hugomat?
{
    NumeroComp parteN1, parteN2;
    polinomio resultado;
    wxString parte1;
    //Mire a ver donde esta el + o el -
    int cantidad=ObtenerNumDeOperacion(poli),temporal;
    int numChar=ObtenerNumCharsOperacion(poli);//FIXME!!!!!!
    //Hasta ese punto seleccione
    parte1=poli.SubString(0,numChar);
    //Lo envie a StringAComp
    parteN1=StringAComp(parte1);
    resultado.CambiarFactorA(parteN1);
    //Asi con todas las partes del polinomio
    if(cantidad>1)
    {
        temporal=numChar;
        int signo=1;
        usi otroChar=ObtenerNumCharsOperacion(poli,poli.length());
        if(poli.GetChar(numChar+1)=='-')
        {
            resultado.CambiarSignoB(false);
            parteN2.CambiarSigno(false);
            signo=0;
        }
        wxString parte2=poli.SubString(numChar+2,otroChar);
        parteN2=StringAComp(parte2);
        if(signo==0)
        {
            parteN2.CambiarSigno(false);
        }
        resultado.CambiarFactorB(parteN2);
    }
    return resultado;
}
Esempio n. 5
0
// convert a Timestring HH:MM into a double
double CDlgAdvPreferences::TimeStringToDouble(wxString timeStr) {
    double hour;
    double minutes;
    timeStr.SubString(0,timeStr.First(':')).ToDouble(&hour);
    timeStr.SubString(timeStr.First(':')+1,timeStr.Length()).ToDouble(&minutes);
    minutes = minutes/60.0;
    return hour + minutes;
}
wxString FindTab(wxString &line) {
    for (int x = 0; x < line.size(); x++) {
        if (line[x] == '\t') {
            wxString first = line.SubString(0, x - 1);
            line = line.SubString(x+1, line.size());
            return first;
        }
    }
    return line;
}
Esempio n. 7
0
std::vector<wxString> tokenize(const wxString &text) {
	std::vector<wxString> paramList;
	paramList.reserve(6);

	if (text.empty()) {
		return paramList;
	}
	if (text[0] != '(') {
		// There's just one parameter (because there's no parentheses)
		// This means text is all our parameters
		wxString param(text);
		paramList.push_back(param.Trim(true).Trim(false));
		return paramList;
	}

	// Ok, so there are parentheses used here, so there may be more than one parameter
	// Enter fullscale parsing!
	size_t i = 0, textlen = text.size();
	size_t start = 0;
	int parDepth = 1;
	while (i < textlen && parDepth > 0) {
		// Just skip until next ',' or ')', whichever comes first
		// (Next ')' is achieved when parDepth == 0)
		start = ++i;
		while (i < textlen && parDepth > 0) {
			wxChar c = text[i];
			// parDepth 1 is where we start, and the tag-level we're interested in parsing on
			if (c == ',' && parDepth == 1) break;
			if (c == '(') parDepth++;
			else if (c == ')') {
				parDepth--;
				if (parDepth < 0) {
					wxLogWarning("Unmatched parenthesis near '%s'!\nTag-parsing incomplete.", text.SubString(i, 10));
					return paramList;
				}
				else if (parDepth == 0) {
					// We just ate the parenthesis ending this parameter block
					// Make sure it doesn't get included in the parameter text
					break;
				}
			}
			i++;
		}
		// i now points to the first character not member of this parameter
		paramList.push_back(text.SubString(start, i-1).Trim(true).Trim(false));
	}

	if (i+1 < textlen) {
		// There's some additional garbage after the parentheses
		// Just add it in for completeness
		paramList.push_back(text.Mid(i+1));
	}
	return paramList;
}
Esempio n. 8
0
void GroupWindow::ProcessGroupMember( wxString text )
{
    int num = 0;
    int line = 0;
    wxString outText;
    while(1)
    {
        int pos = text.Find(wxChar(','));
        if( pos == wxNOT_FOUND || pos == 0 || num > (MAX_GROUP - 1))
		    break;
        outText = text.SubString(0, (pos-1));
        switch( num )
        {
        case 0:
            line = atoi(outText.ToAscii());
            break;
        case 1:
            _txtLevel[line]->SetLabel(outText);
            break;
        case 2:
            _txtClass[line]->SetLabel(outText);
            break;
        case 3:
            _txtName[line]->SetLabel(outText);
            ShowMember(line, true);
            break;
        case 4:
            _hit[line] = atoi(outText.ToAscii());
            break;
        case 5:
            _maxHit[line] = atoi(outText.ToAscii());
            break;
        case 6:
            _mana[line] = atoi(outText.ToAscii());
            break;
        case 7:
            _maxMana[line] = atoi(outText.ToAscii());
            break;
        case 8:
            _move[line] = atoi(outText.ToAscii());
            break;
        case 9:
            _maxMove[line] = atoi(outText.ToAscii());
            break;
        }
	    text = text.SubString((pos+1), (text.Length() - 1));
        ++num;
    }
    return;    
}
void splitStringToArray(wxString &strLines, wxArrayString *ptArray)
{
	wxString strLine;
	size_t sizLineStart;
	size_t sizPos;
	size_t sizLen;
	wxChar c;


	sizPos = sizLineStart = 0;
	sizLen = strLines.Len();
	while( sizPos<sizLen )
	{
		// find next break
		c = strLines.GetChar(sizPos);
		++sizPos;
		if( c==wxT('\n') || c== wxT('\r') )
		{
			// found line end
			strLine = strLines.SubString(sizLineStart, sizPos);
			// trim string from both sides
			strLine.Trim(true);
			strLine.Trim(false);
			// add string to the array
			if( strLine.IsEmpty()==false )
			{
				ptArray->Add(strLine);
				wxLogMessage(wxT("romloader_openocd(") + plugin_desc.strPluginId + wxT(") : ") + strLine);
			}
			// new line starts after eol
			sizLineStart = sizPos;
		}
	}

	// chars left without newline?
	if( sizLineStart<sizPos )
	{
		strLine = strLines.SubString(sizLineStart, sizPos);
		// trim string from both sides
		strLine.Trim(true);
		strLine.Trim(false);
		if( strLine.IsEmpty()==false )
		{
			ptArray->Add(strLine);
			wxLogMessage(wxT("romloader_openocd(") + plugin_desc.strPluginId + wxT(") : ") + strLine);
		}
	}
}
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;
}
Esempio n. 11
0
/**
 * HTMLノード内(<dd>~~~</dd>)に引数の要素があるか調べる
 * @param  const htmlNodePtr ptr	スレッドのHTML
 * @param  const wxString& target	     抽出対象のレス番号
 * @return true: あり, false: なし
 */
bool XrossBoardUtil::DDNodeHasTarget(const htmlNodePtr dd, const wxString& target)
{
     for (htmlNodePtr ptr = dd->children; ptr != NULL; ptr = ptr->next) 
     {
	  if (ptr->type == XML_ELEMENT_NODE && 
	      xmlStrcasecmp(ptr->name, (const xmlChar*) "a") == 0)
	  {
	       xmlAttr* attribute = ptr->properties;
	       while(attribute && attribute->name && attribute->children)
	       {
		    xmlChar* value = xmlNodeListGetString(ptr->doc, attribute->children, 1);
		    //do something with value
		    if (xmlStrcasecmp(value, (const xmlChar*) "_blank") == 0)
		    {
			 // >>xxx (= ptr->children->content) データは実体参照ではない ">>12"
			 const wxString anchor = wxString::FromUTF8(reinterpret_cast<const char*>(ptr->children->content));
			 const wxString number = anchor.SubString(2, anchor.Len() - 1);

			 if (number.IsSameAs(target))
			 {
			      return true;
			 }
		    }
					
		    xmlFree(value); 
		    attribute = attribute->next;
	       }
	  }
     }

     return false;
}
Esempio n. 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;
        }
    }
}
Esempio n. 13
0
void ctlDefaultPrivilegesPanel::Update(wxString strDefPrivs)
{
	unsigned int index = 0;

	cbGroups->Clear();
	lbPrivileges->DeleteAllItems();

	m_privileges.clear();

	cbGroups->Append(wxT("public"));

	for (; index < m_defSecurityPanel->m_groups.GetCount(); index++)
		cbGroups->Append(m_defSecurityPanel->m_groups[index]);

	if (!strDefPrivs.IsEmpty())
	{
		wxString strRole, strPriv;
		strDefPrivs.Replace(wxT("\\\""), wxT("\""), true);
		strDefPrivs.Replace(wxT("\\\\"), wxT("\\"), true);

		// Removing starting brace '{' and ending brace '}'
		strDefPrivs = strDefPrivs.SubString(1, strDefPrivs.Length() - 1);

		long pos = 0;

		while (pgObject::findUserPrivs(strDefPrivs, strRole, strPriv))
		{
			int icon;
			if (strRole.IsSameAs(wxT("public"), true))
				icon = PGICON_PUBLIC;
			else if (cbGroups->FindString(strRole) != wxNOT_FOUND)
				icon = userFactory.GetIconId();
			else if (cbGroups->FindString(wxT("group ") + strRole) != wxNOT_FOUND)
			{
				icon = groupFactory.GetIconId();
				strRole = wxT("group ") + strRole;
			}
			else
				continue;

			defPrivilege priv;
			priv.m_username = strRole;
			priv.m_origPriv = strPriv;
			priv.m_modified = false;
			priv.m_newPriv  = wxT("");

			wxString strKey = strRole;
			m_privileges[strKey] = priv;

			pos = lbPrivileges->GetItemCount();

			lbPrivileges->InsertItem(pos, strRole, icon);
			lbPrivileges->SetItem(pos, 1, strPriv);

			strRole = wxT("");
			strPriv = wxT("");
			pos++;
		}
	}
}
Esempio n. 14
0
bool SerialConnection::FilterInput( wxString &message, wxString &source )
{
    if ( InputFilterList.Count() == 0 )
            return true;
    for ( size_t i = 0; i < InputFilterList.Count(); i++ )
        if ( InputFilterList[i] == message.SubString(3,3) || InputFilterList[i] == message.SubString(1,2) || InputFilterList[i] == message.SubString(1,5) )
        {
            if ( InputFilterType == BLACKLIST )
                return false;
            else
                return true;
        }
    if ( InputFilterType == BLACKLIST )
        return true;
    else
        return false;
}
Esempio n. 15
0
static wxString TrimSep(const wxString& path)
{
	const wxString sep = wxFileName::GetPathSeparator();
	if (path.EndsWith(sep)) {
		return path.SubString(0, path.length()-2);
	}
	return path;
}
Esempio n. 16
0
ParserCommon::EFileType ParserCommon::FileType(const wxString& filename, bool /*force_refresh*/)
{
    static bool          empty_ext = true;
    static wxArrayString header_ext;
    header_ext.Add(_T("h")); header_ext.Add(_T("hpp")); header_ext.Add(_T("tcc")); header_ext.Add(_T("xpm"));
    static wxArrayString source_ext;
    source_ext.Add(_T("c")); source_ext.Add(_T("cpp")); source_ext.Add(_T("cxx")); source_ext.Add(_T("cc")); source_ext.Add(_T("c++"));

    if (filename.IsEmpty())
    {
        wxString log;
        log.Printf(wxT("ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftOther' (empty)."), filename.wx_str());
        //CCLogger::Get()->Log(log);
        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())
    {
        wxString log;
        log.Printf(wxT("ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftHeader' (w/o ext.)."), filename.wx_str());
        //CCLogger::Get()->Log(log);
        return ParserCommon::ftHeader;
    }

    for (size_t i=0; i<header_ext.GetCount(); ++i)
    {
        if (ext==header_ext[i])
        {
            wxString log;
            log.Printf(wxT("ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftHeader' (w/ ext.)."), filename.wx_str());
            TRACE(log);
            return ParserCommon::ftHeader;
        }
    }

    for (size_t i=0; i<source_ext.GetCount(); ++i)
    {
        if (ext==source_ext[i])
        {
            wxString log;
            log.Printf(wxT("ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftSource' (w/ ext.)."), filename.wx_str());
            TRACE(log);
            return ParserCommon::ftSource;
        }
    }

    wxString log;
    log.Printf(wxT("ParserDummy::ParserCommon::FileType() : File '%s' is of type 'ftOther' (unknown ext)."), filename.wx_str());
    TRACE(log);

    return ParserCommon::ftOther;
}
Esempio n. 17
0
wxString FbGenreFunction::DecodeList(const wxString &genres)
{
	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 << m_names[code];
	}
	return result;
}
wxString wxStringFormatter::FindNextFunction(wxString input, int& Startpos, int& Endpos)
{
	wxLogDebug("FindNextFunction: " + input);
	int functBegin;
	int blockOpen = input.find_first_of(DELIMS_F_OPEN);
	if(blockOpen == wxNOT_FOUND)
	{
		Startpos = wxNOT_FOUND;
		return "";
	}

	int blockClose = input.find_first_of(m_funcDelims, blockOpen +1);
	while(!DELIMS_F_CLOSE.Contains(input.GetChar(blockClose)) && blockClose != wxNOT_FOUND)
	{
		if(DELIMS_F_OPEN.Contains(input.GetChar(blockClose)))
		{
			blockOpen = blockClose;
			blockClose = input.find_first_of(m_funcDelims, blockOpen +1);
		}
	}

	if(blockClose == wxNOT_FOUND)
	{
		Startpos = wxNOT_FOUND;
		return "";
	}

	Endpos = blockClose + 1;

	//return input.SubString(blockOpen+1, blockClose-1);

	functBegin = input.find_last_of(DELIMS, blockOpen -1);
	functBegin++;

	wxString tmp = DoFunction(input.SubString(functBegin, blockOpen -1),  input.SubString(blockOpen+1, blockClose-1));
	if(m_concatDelims.Contains(input.GetChar(functBegin -1)))
	{
		functBegin--;
	}
	Startpos = functBegin;
	return tmp;
}
Esempio n. 19
0
void EffectPanelUtils::enableControlsByName(wxWindow *window, const wxString &name, bool enable) {
    wxWindow *w = window->FindWindowByName(name);
    if (w != nullptr) {
        w->Enable(enable);
    }
    wxString n2 = "IDD_" + name.SubString(3, name.size());
    w = window->FindWindowByName(name);
    if (w != nullptr) {
        w->Enable(enable);
    }
}
Esempio n. 20
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;
}
Esempio n. 21
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;
    }
Esempio n. 22
0
bool wxExLink::SetLink(
    wxString& link,
    int& line_no,
    int& column_no) const
{
    if (link.size() < 2)
    {
        return false;
    }

    // Using backslash as separator does not yet work.
    link.Replace("\\\\", "/");
    link.Replace("\\", "/");

    // The harddrive letter is filtererd, it does not work
    // when adding it to wxExMatch.
    wxString prefix;

#ifdef __WXMSW__
    if (isalpha(link[0]) && link[1] == ':')
    {
        prefix = link.SubString(0,1);
        link = link.Mid(2);
    }
#endif

    // file[:line[:column]]
    std::vector <wxString> v;

    if (wxExMatch("([0-9A-Za-z _/.-]+):([0-9]*):?([0-9]*)", link, v))
    {
        link = v[0];
        line_no = 0;
        column_no = 0;

        if (v.size() > 1)
        {
            line_no = atoi(v[1]);

            if (v.size() > 2)
            {
                column_no = atoi(v[2]);
            }
        }

        link = prefix + link;

        return true;
    }

    return false;
}
Esempio n. 23
0
void Plot2DWiz::SetValue(wxString s)
{
  if (s.StartsWith(wxT("plot2d")))
    Parse(s);
  else if (s.StartsWith(wxT("wxplot2d")))
  {
    Parse(s.SubString(2, s.Length()));
    combo_box_1->SetValue(_("inline"));
  }
  else
    text_ctrl_1->SetValue(s);

  text_ctrl_1->SetSelection(-1, -1);
}
std::vector<wxString> SplitString(wxString& data, wxString& str)
{
    std::vector<wxString> vec = {};
    int index = 0;
    while (true)
    {
        int start = index;
        index = data.find(str, index);
        if (index != wxNOT_FOUND)
        {
            vec.push_back(data.SubString(start, index - 1));
        }
        else
        {
            if (!data.EndsWith(str))
            {
                vec.push_back(data.SubString(start, data.Length()));
            }
            break;
        }
        index += str.Length();
    }
    return vec;
}
Esempio n. 25
0
// Get an array from a comma separated list
bool getArrayFromCommaSeparatedList(const wxString &str, wxArrayString &res)
{
	size_t len = str.Len(), index = 0, nBracketLevel = 0, startArray = 0;
	bool inSingleQuote = false, inDoubleQuote = false;

	if (len == 0)
		return true;

	for(; index < len; index++)
	{
		wxChar curr = str.GetChar(index);
		if (!inDoubleQuote && curr == (wxChar)'\'')
			inSingleQuote = !inSingleQuote;
		else if (!inSingleQuote && curr == (wxChar)'"')
			inDoubleQuote = !inDoubleQuote;
		else if (!inDoubleQuote && !inSingleQuote && curr == (wxChar)'(')
			nBracketLevel++;
		else if (!inDoubleQuote && !inSingleQuote && curr == (wxChar)')')
			nBracketLevel--;
		else if (!inDoubleQuote && !inSingleQuote && nBracketLevel == 0 && curr == (wxChar)',')
		{
			if (index != startArray)
				res.Add(str.SubString(startArray, index - 1).Trim(true).Trim(false));
			else
				res.Add(wxEmptyString);
			startArray = index + 1;
		}
	}
	if (inDoubleQuote || inSingleQuote || nBracketLevel != 0)
		return false;

	// Add last value to array
	res.Add(str.SubString(startArray, index).Trim(true).Trim(false));

	return true;
}
Esempio n. 26
0
wxString DIALOG_BOM::getPluginFileName(  const wxString& aCommand )
{
    wxString pluginName;

    // Try to find the plugin name.
    // This is possible if the name ends by .py or .xsl
    int pos = -1;

    if( (pos = aCommand.Find( wxT(".py") )) != wxNOT_FOUND )
        pos += 2;
    else if( (pos = aCommand.Find( wxT(".xsl") )) != wxNOT_FOUND )
        pos += 3;

    // the end of plugin name is at position pos.
    if( pos > 0 )
    {
        // Be sure this is the end of the name: the next char is " or space
        int eos = aCommand[pos+1];

        if( eos == ' '|| eos == '\"' )
        {
            // search for the starting point of the name
            int jj = pos-1;
            while( jj >= 0 )
                if( aCommand[jj] != eos )
                    jj--;
                else
                    break;

            // extract the name
            if( jj >= 0 )
            {
                eos = aCommand[jj];

                if( eos == ' '|| eos == '\"' )  // do not include delimiters
                    jj++;

                pluginName = aCommand.SubString( jj, pos );
            }
        }
    }

    return pluginName;
}
int wxStringFormatter::FindNextBlock(wxString& input, int pos, int& level)
{
	wxString str;
	wxLogDebug(wxString::Format("FindNextBlock: %d ", pos) + input);
	int blockOpen;
	int blockClose;

	blockClose = input.find_first_of(m_blockDelims, pos);

	if(DELIMS_B_CLOSE.Contains(input.GetChar(blockClose)))
	{
		return blockClose;
	}
	else if(DELIMS_B_OPEN.Contains(input.GetChar(blockClose)))
	{
		level++;
		blockOpen = blockClose;
		blockClose = FindNextBlock(input, blockClose+1, level);

		wxString block;
		block = input.SubString(blockOpen + 1, blockClose - 1);
		str.Printf("> %d %d", blockOpen + 1, blockClose - 1);
		wxLogDebug("block > " + block + str);
		block = DoFunctions(block);
		block = ReplaceSymbols(block);
		block = DoConcat(block);
		input.replace(blockOpen, (blockClose + 1) - blockOpen, block);
		level--;
	}
	else
	{
		wxLogDebug("not found");
		return wxNOT_FOUND;
	}

	if(level > 0)
	{
		return FindNextBlock(input, blockOpen, level);
	}
	return -1;
}
Esempio n. 28
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();

}
Esempio n. 29
0
wxString pgDatabase::GetDefaultPrivileges(const wxChar &cType, wxString strDefPrivs, const wxString &strSchema)
{
	wxString strDefPrivsSql;

	if (!strDefPrivs.IsEmpty())
	{
		wxString strRole, strPriv, strSupportedPrivs, strType;
		strDefPrivs.Replace(wxT("\\\""), wxT("\""), true);
		strDefPrivs.Replace(wxT("\\\\"), wxT("\\"), true);

		switch(cType)
		{
			case 'r':
				strType = wxT("TABLES");
				strSupportedPrivs = wxT("arwdDxt");
				break;
			case 'S':
				strType = wxT("SEQUENCES");
				strSupportedPrivs = wxT("rwU");
				break;
			case 'f':
				strType = wxT("FUNCTIONS");
				strSupportedPrivs = wxT("X");
				break;
			default:
				return wxT("");
		}

		// Removing starting brace '{' and ending brace '}'
		strDefPrivs = strDefPrivs.SubString(1, strDefPrivs.Length() - 1);

		while (pgObject::findUserPrivs(strDefPrivs, strRole, strPriv))
		{
			strDefPrivsSql += pgObject::GetDefaultPrivileges(strType, strSupportedPrivs, strSchema, wxT(""), strPriv, qtIdent(strRole));

			strRole = wxT("");
			strPriv = wxT("");
		}
	}
	return strDefPrivsSql;
}
/////////////////////
// Parses parameters
void AssOverrideTag::ParseParameters(wxString text) {
	// text is all text following the name until the next \ or the end of the override block

	// Tokenize text, attempting to find all parameters
	wxArrayString paramList;
	wxString work;

	{
		if (text.IsEmpty() || text[0] != _T('(')) {
			// There's just one (or none at all) parameter (because there's no parantheses)
			// This means text is all our parameters
			paramList.Add(text.Trim(true).Trim(false));
			// Only using goto here to avoid yet another nested block (keeps the code cleaner!)
			goto end_tokenizing;
		}

		// Ok, so there are parantheses used here, so there may be more than one parameter
		// Enter fullscale parsing!
		size_t i = 0, textlen = text.Length();
		size_t start = 0;
		int parDepth = 1;
		while (i < textlen && parDepth > 0) {
			// Just skip until next ',' or ')', whichever comes first
			// (Next ')' is achieved when parDepth == 0)
			start = ++i;
			while (i < textlen && parDepth > 0) {
				if (text[i] == _T('(')) parDepth++;
				if (text[i] == _T(')')) parDepth--;
				// parDepth 1 is where we start, and the tag-level we're interested in parsing on
				if (text[i] == _T(',') && parDepth == 1) break;
				if (parDepth < 0) {
					wxLogWarning(_T("Unmatched parenthesis near '%s'!\nTag-parsing incomplete."), text.SubString(i, 10).c_str());
					goto end_tokenizing;
				}
				if (parDepth == 0) {
					// We just ate the paranthesis ending this parameter block
					// Make sure it doesn't get included in the parameter text
					break;
				}
				i++;
			}
			// i now points to the first character not member of this parameter
			work = text.SubString(start, i-1);
			work.Trim(true).Trim(false);
			paramList.Add(work);
			wxLogDebug(_T("Got parameter: %s"), work.c_str());
		}

		if (i+1 < textlen) {
			// There's some additional garbage after the parantheses
			// Just add it in for completeness
			paramList.Add(text.Mid(i+1));
		}
	}
	// This label is only gone to from inside the previous block, if the tokenizing needs to end early
end_tokenizing:

	int curPar = 0;
	size_t totalPars = paramList.GetCount();

	// Get optional parameters flag
	ASS_ParameterOptional parsFlag = OPTIONAL_0;
	switch (totalPars) {
		case 1: parsFlag = OPTIONAL_1; break;
		case 2: parsFlag = OPTIONAL_2; break;
		case 3: parsFlag = OPTIONAL_3; break;
		case 4: parsFlag = OPTIONAL_4; break;
		case 5: parsFlag = OPTIONAL_5; break;
		case 6: parsFlag = OPTIONAL_6; break;
		case 7: parsFlag = OPTIONAL_7; break;
	}

	// Find prototype
	bool clipOnce = true;
	AssOverrideTagProto *proto = NULL;
	for (std::list<AssOverrideTagProto>::iterator cur=AssOverrideTagProto::proto.begin();cur!=AssOverrideTagProto::proto.end();cur++) {
		if (Name == (*cur).name) {
			if (Name == _T("\\clip") && totalPars != 4 && clipOnce) {
				clipOnce = false;
				continue;
			}
			proto = &(*cur);
			break;
		}
	}
	if (proto == NULL) {
		throw _T("Couldn't find tag prototype while parsing.");
	}

	// Get parameters
	size_t n=0;
	wxString curtok = _T("");
	if (curPar < (signed)totalPars) {
		curtok = paramList[curPar];
		curPar++;
	}

	// For each parameter
	while (n < proto->params.size()) {
		AssOverrideParamProto *curproto = &proto->params[n];
		bool isDefault = false;
		n++;

		// Create parameter
		AssOverrideParameter *newparam = new AssOverrideParameter;

		// Check if it's optional and not set (set to default)
		if (!(curproto->optional & parsFlag)) {
			if (curproto->defaultValue.GetType() != VARDATA_NONE) {
				isDefault = true;
				newparam->CopyFrom(curproto->defaultValue);
			}
			newparam->ommited = true;
			// This parameter doesn't really count against the number of parsed parameters,
			// since it's left out. Don't count it.
			curPar--;
		}

		if (isDefault == false) {
			// Determine parameter type and set value
			switch (curproto->type) {
				case VARDATA_INT: {
					long temp = 0;
					curtok.ToLong(&temp);
					newparam->SetInt(temp);
					break;
				}
				case VARDATA_FLOAT: {
					double temp = 0.0;
					curtok.ToDouble(&temp);
					newparam->SetFloat(temp);
					break;
				}
				case VARDATA_TEXT: {
					newparam->SetText(curtok);
					break;
				}
				case VARDATA_BOOL: {
					long temp = false;
					curtok.ToLong(&temp);
					newparam->SetBool(temp != 0);
					break;
				}
				case VARDATA_BLOCK: {
					AssDialogueBlockOverride *temp = new AssDialogueBlockOverride;
					temp->text = curtok;
					temp->ParseTags();
					newparam->SetBlock(temp);
					break;
				}
			}

			// Get next actual parameter
			if (curPar < (signed)totalPars) {
				// Unless this parameter was omitted (in which case the token shouldn't be eaten)
				if (!newparam->ommited) {
					curtok = paramList[curPar];
				}
				curPar++;
			}
			else curtok = _T("");
		}

		// Add to list
		newparam->classification = curproto->classification;
		Params.push_back(newparam);
	}
}