Example #1
0
/** This function determines the caracteristics of a given line (code line, comment line etc...).
 *  It is called by the "CountLines" function.
 *  @see CountLines
 */
void CodeStatExecDlg::AnalyseLine(LanguageDef &language, wxString line, bool &comment, bool &code, bool &multi_line_comment)
{
   int first_single_line_comment, first_multi_line_comment_begin, first_multi_line_comment_end;

   // Delete first and trailing spaces
   line = line.Trim(true);
   line = line.Trim(false);

	if (line.IsEmpty())
	   return;

	// Searching for single and multi-lines comment signs
	if (language.single_line_comment.Length() > 0)
      first_single_line_comment = line.Find(language.single_line_comment);
   else first_single_line_comment = -1;
   if (language.multiple_line_comment[0].Length() > 0)
      first_multi_line_comment_begin = line.Find(language.multiple_line_comment[0]);
   else first_multi_line_comment_begin = -1;
   if (language.multiple_line_comment[1].Length() > 0)
      first_multi_line_comment_end = line.Find(language.multiple_line_comment[1]);
   else first_multi_line_comment_end = -1;

   // We are in a multiple line comment => finding the "end of multiple line comment" sign
   if (multi_line_comment)
   {
      comment = true;
   	if (first_multi_line_comment_end > -1)
   	{
   		multi_line_comment = false;
   		if (first_multi_line_comment_end+language.multiple_line_comment[1].Length() < line.Length())
   		   AnalyseLine(language, line.Mid(first_multi_line_comment_end+language.multiple_line_comment[1].Length()), comment, code, multi_line_comment);
   	}
   }
   // We are not in a multiple line comment
   else if (!multi_line_comment)
   {
   	// First comment sign found is a single line comment sign
      if ( (first_single_line_comment>-1)
         &&((first_multi_line_comment_begin==-1)||((first_multi_line_comment_begin>-1)&&(first_single_line_comment<first_multi_line_comment_begin))) )
      {
      	comment = true;
         if (first_single_line_comment > 0)
            code = true;
      }
      // First comment sign found is a multi-line comment begin sign
      else if (first_multi_line_comment_begin>-1)
      {
         multi_line_comment = true;
         comment = true;
         if (first_multi_line_comment_begin > 0)
            code = true;
         if (first_multi_line_comment_begin+language.multiple_line_comment[0].Length() < line.Length())
   		   AnalyseLine(language, line.Mid(first_multi_line_comment_begin+language.multiple_line_comment[0].Length()), comment, code, multi_line_comment);
      }
      else
      {
      	code = true;
      }
   }
}
Example #2
0
void Page::SetName(wxString& myname) {
	myname.Trim(FALSE);myname.Trim(TRUE);myname.Truncate(100);
	if(!myname.IsEmpty()) {
	       	name = myname;
	} else {
		name = file.GetFullName();
	}
}
Example #3
0
long GetSpeedFromString(wxString label){
	long temp;
	label.Replace(_("kB/s"),wxT(""),TRUE);
	label.Trim(FALSE);
	label.Trim(TRUE);
	label.ToLong(&temp);
	return temp;
}
bool wxsCorrector::FixIdName(wxString& Id)
{
    Id.Trim(true);
    Id.Trim(false);

    long Tmp;
    if ( Id.ToLong(&Tmp,10) ) return false;

    // We'll use FixVarName's routines to correct identifier
    return FixVarName(Id);
}
Example #5
0
void DebuggerTree::FixupVarNameForChange(wxString& str)
{
    // remove everything from '=' and after
    str = str.BeforeFirst(_T('='));
    str.Trim(false);
    str.Trim(true);

    // if it contains invalid chars, clear it
    if (str.find_first_of(_T(" \t")) != wxString::npos)
        str.Clear();
}
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 #7
0
bool CCOptionsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
    // cut off any leading / trailing spaces
    from.Trim(true).Trim(false);
    to.Trim(true).Trim(false);

    if (to.IsEmpty())
    {
        // Allow removing a token, but ask the user if that's OK.
        if (cbMessageBox( _("This setup will replace the token with an empty string.\n"
                            "This will *remove* the token and probably break CC for some cases.\n"
                            "Do you really want to *remove* that token?"),
                          _("Confirmation"),
                          wxICON_QUESTION | wxYES_NO ) == wxID_YES)
        {
            return true;
        }
    }
    else if (to.Contains(from))
    {
        cbMessageBox(_("Replacement token cannot contain search token.\n"
                       "This would cause an infinite loop otherwise."),
                     _("Error"), wxICON_ERROR);
        return false;
    }

    wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
    if (!re.Matches(from))
    {
        cbMessageBox(_("Search token can only contain alphanumeric characters and underscores."),
                     _("Error"), wxICON_ERROR);
        return false;
    }
    if (!re.Matches(to))
    {
        // Allow replacing with special characters only if the user says it's ok.
        if (cbMessageBox( _("You are replacing a token with a string that contains\n"
                            "characters other than alphanumeric and underscores.\n"
                            "This could make parsing the file impossible.\n"
                            "Are you sure?"),
                          _("Confirmation"),
                          wxICON_QUESTION | wxYES_NO ) != wxID_YES)
        {
            return false;
        }
    }

    return true;
}
Example #8
0
CServerPath::CServerPath(const CServerPath &path, wxString subdir)
	: m_data(path.m_data)
{
	m_type = path.m_type;
	m_bEmpty = path.m_bEmpty;

	subdir.Trim(true);
	subdir.Trim(false);

	if (subdir == _T(""))
		return;

	if (!ChangePath(subdir))
		Clear();
}
bool UnquoteCommand(wxString& command, wxString& arguments, bool is_dde = false)
{
	arguments = _T("");

	if (command == _T(""))
		return true;

	wxChar inQuotes = 0;
	wxString file;
	for (unsigned int i = 0; i < command.Len(); i++)
	{
		const wxChar& c = command[i];
		if (c == '"' || c == '\'')
		{
			if (!inQuotes)
				inQuotes = c;
			else if (c != inQuotes)
				file += c;
			else if (command[i + 1] == c)
			{
				file += c;
				i++;
			}
			else
				inQuotes = false;
		}
		else if (command[i] == ' ' && !inQuotes)
		{
			arguments = command.Mid(i + 1);
			arguments.Trim(false);
			break;
		}
		else if (is_dde && !inQuotes && (command[i] == ',' || command[i] == '#'))
		{
			arguments = command.Mid(i + 1);
			arguments.Trim(false);
			break;
		}
		else
			file += command[i];
	}
	if (inQuotes)
		return false;

	command = file;

	return true;
}
Example #10
0
// Checks whether an odamex-style address format is valid
bool dlgMain::IsAddressValid(wxString Address)
{
    wxInt32 Colon;
    wxString RegEx;
    wxRegEx ReValIP;
    wxString IPHost;
    wxUint16 Port;

    // Get rid of any whitespace on either side of the string
    Address.Trim(false);
    Address.Trim(true);

    if (Address.IsEmpty() == true)
        return false;

    // Set the regular expression and load it in
    RegEx = wxT("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4]"
                    "[0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]"
                    "[0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");

    ReValIP.Compile(RegEx);

    if (ReValIP.IsValid() == false)
    {
        wxMessageBox(wxT("RegEx invalid"));
        return false;
    }

    // Find the colon that separates the ip address and the port number
    Colon = Address.Find(wxT(':'), true);

    if (Colon == wxNOT_FOUND)
        return false;

    // Check if there is something after the colon
    if (Colon + 1 >= Address.Len())
        return false;

    // Acquire the ip address and port number
    Port = wxAtoi(Address.Mid(Colon + 1));
    IPHost = Address.Mid(0, Colon);

    // Finally do the comparison
    if ((Port > 0) && (ReValIP.Matches(IPHost) == true))
        return true;
    else
        return false;
}
Example #11
0
bool CHideWin::HaveExt( wxString str, wxString ext )
{
    ext.Trim( false );
    ext.Trim( true );

    if ( ext.IsEmpty() )
        return false;

    if ( str.Length() < ext.Length() )
    {
        return false;
    }

    return str.Right( ext.Length() ) == ext;

}
Example #12
0
wxDateTime CReminderDialog::ParseSnoozeTime(wxString strTime)
{
	// Parser function to parse something like: 1 Week 3 Days 5 Minutes.
	wxDateTime dateTime = wxDateTime::Now();
	strTime = strTime.Trim(true);
	int weeks = 0, days = 0, hours = 0, minutes = 0;
	wxRegEx reExp(wxT("\\s*(\\d+)\\s*([a-zA-Z]*)\\s*"), wxRE_ADVANCED);
	wxString strNumber;
	wxString strText;
	int nNumber = 0;
	while( reExp.Matches(strTime) )
	{
		strNumber = reExp.GetMatch(strTime, 1);
		strText = reExp.GetMatch(strTime, 2);
		strTime = strTime.Remove(0, reExp.GetMatch(strTime, 0).Length());
		strText = strText.Lower();
		try
		{
			nNumber =  boost::lexical_cast<int>(strText.c_str());
		}
		catch (boost::bad_lexical_cast &)
		{			
			nNumber = 0;
		}
		if(strText.Find(wxT("minute")) == 0)
			minutes = nNumber;
		else if(strText.Find(wxT("hour")) == 0)
			hours = nNumber;
		else if(strText.Find(wxT("day")) == 0)
			days = nNumber;
		else if(strText.Find(wxT("week")) == 0)
			weeks = nNumber;
	}
	return dateTime + GetTimeSpan(weeks, days, hours, minutes);
}
Example #13
0
void AttachDbgProcDlg::RefreshProcessesList(wxString filter, int colToSort)
{
    wxWindowUpdateLocker locker(m_dvListCtrl);
    m_dvListCtrl->DeleteAllItems();

    filter.Trim().Trim(false);

    // Populate the list with list of processes
    std::vector<ProcessEntry> proclist;
    ProcUtils::GetProcessList(proclist);

    //    if(colToSort == 0) { // sort by PID
    //        std::sort(proclist.begin(), proclist.end(), PIDSorter());
    //
    //    } else if(colToSort == 1) { // sort by name
    //        std::sort(proclist.begin(), proclist.end(), NameSorter());
    //    }

    filter.MakeLower();
    for(size_t i = 0; i < proclist.size(); ++i) {

        // Use case in-sensitive match for the filter
        wxString entryName(proclist.at(i).name);

        // Append only processes that matches the filter string
        if(filter.IsEmpty() || FileUtils::FuzzyMatch(filter, entryName)) {
            const ProcessEntry& entry = proclist.at(i);
            if(entry.pid == (long)wxGetProcessId()) continue;
            wxVector<wxVariant> cols;
            cols.push_back(wxString() << entry.pid);
            cols.push_back(entry.name);
            m_dvListCtrl->AppendItem(cols);
        }
    }
}
Example #14
0
wxString
AnPickFromFs::trimFileName(wxString fileName)
{
	fileName = fileName.Trim(0);
	fileName = fileName.Trim(1);
	return fileName;
}
Example #15
0
void TextFrame::addBookmark(int line, wxString name)
{
    wxStyledTextCtrl* txt = getCurrentTextCtrl();
    if(txt)
    {
        // Define bookmark line
        if(line==wxNOT_FOUND)
            line = txt->GetCurrentLine();

        // Define bookmark name
        if(name.IsEmpty())
        {
            name = txt->GetCurLine(NULL);
            name.Trim();
            if(name.IsEmpty())
                name = wxGetTextFromUser(_("Name of the new bookmark"), _("New bookmark"), name);
        }

        if(!name.IsEmpty())
        {
            // Set bookmark for bookmark panel
            BookmarkList& list = getDocument()->getBookmarks();
            Bookmark bm = {line, name};
            list.insert(bm);
            UpdateBookmarkPanel();

            // Add Bookmark marker
            addMarker(TEXT_MARKER_BOOKMARK, name, line);
        }
    }
}
Example #16
0
static void CCBoxTipWindow_ShrinkTip(wxString& str)
{
    str.Replace("\r", "");
    str.Replace("<p>", "");
    str.Replace("</p>", "");
    str.Replace("/**", "");
    str.Replace("/*!", "");
    str.Replace("/*", "");
    str.Replace("*/", "");
    str.Replace("**/", "");

    wxString tip;
    wxArrayString lines = ::wxStringTokenize(str, wxT("\n"), wxTOKEN_RET_EMPTY_ALL);
    for(size_t i = 0; i < lines.GetCount(); ++i) {
        wxString& curline = lines.Item(i);
        curline.Trim().Trim(false);
        if(curline.StartsWith("*")) curline.Remove(0, 1);
        tip << curline << "\n";
    }
    str.swap(tip);
    str.Trim().Trim(false);
    
    // strip double empty lines
    while(str.Replace("\n\n", "\n")) {}
}
Example #17
0
bool wxTerminal::CheckForCD( const wxString &command, wxString &path )
{
	if ( command.IsEmpty() )               return false; // Returning true tells caller there's nothing else to do
	if ( command.Left(2) != wxT("cd") )    return false; // Not a cd attempt so return false so that RunCommand takes over
	if ( wxIsalpha( command.GetChar(2) ) ) return false; // This must be a real command beginning with cd???

	if ( command == wxT("cd.") || command == wxT("cd .") )  {
		path = wxGetCwd();
		return true;
	}

	if ( command == wxT("cd") || command == wxT("cd~") || command == wxT("cd ~") ) {
		path = wxGetHomeDir();
		return true;

	} else if ( command.Find(wxT("&&")) != wxNOT_FOUND ) {
		// a complex command: cd <somewhere> && ...
		return false;

	} else {
		// Otherwise it should be a real dir. Remove the initial cd, plus any white-space
		path = command.Mid( 2 );
		path << wxFileName::GetPathSeparator();
		path.Trim(false);
		wxFileName fn(path);
		fn.MakeAbsolute(m_workingDir);
		fn.Normalize();
		if( fn.DirExists() ) {
			path = fn.GetFullPath();
			return true;
		}
		return false;
	}
}
Example #18
0
wxArrayString SQLCommandPanel::ParseSql(const wxString& sql) const
{
    // filter out comments
    wxString noCommentsSql;
    wxArrayString lines = ::wxStringTokenize(sql, "\n", wxTOKEN_STRTOK);
    for(size_t i=0; i<lines.GetCount(); ++i) {
        lines.Item(i).Trim().Trim(false);
        if ( lines.Item(i).StartsWith("--") ) {
            continue;
        }
        noCommentsSql << lines.Item(i) << "\n";
    }
    
    // Split by semi-colon
    wxArrayString tmpSqls = ::wxStringTokenize(noCommentsSql, ";", wxTOKEN_STRTOK);
    wxArrayString sqls;
    for(size_t i=0; i<tmpSqls.GetCount(); ++i) {
        
        wxString sql = tmpSqls.Item(i);
        sql.Trim().Trim(false);
        if ( sql.IsEmpty() )
            continue;
            
        sql.Replace("\n", " ");
        sql.Replace("\r", "");
        sqls.Add( sql );
    }
    return sqls;
}
Example #19
0
void EventWatcherFrame::addEvents(wxString& s)
{
    // deselect all items so user can cleanly see what is added
    for (int ix = 0; ix < (int)listbox_monitored->GetCount(); ++ix)
    {
        if (listbox_monitored->IsSelected(ix))
            listbox_monitored->Deselect(ix);
    }
    while (true)
    {
        int p = s.Find("\n");
        wxString s2;
        if (p == -1)
            s2 = s.Strip();
        else
        {
            s2 = s.Left(p).Strip(wxString::both);
            s.Remove(0, p);
            s.Trim(false);
        }
        if (!s2.IsEmpty() && listbox_monitored->FindString(s2) == wxNOT_FOUND)
            listbox_monitored->Select(listbox_monitored->Append(s2));
        if (p == -1)
            break;
    }
    updateControls();
}
bool wxsCorrector::FixVarName(wxString& Name)
{
    wxString Corrected;
    Name.Trim(true);
    Name.Trim(false);

    if ( !Name.empty() )
    {
        // Validating name as C++ ideentifier
        // TODO: Other languages ?

        static wxString FirstChar(
            _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
            _T("abcdefghijklmnopqrstuvwxyz")
            _T("_"));

        if ( FirstChar.Find(Name.GetChar(0)) == -1 )
            Manager::Get()->GetLogManager()->DebugLog(F(_T("wxSmith: Variable name : \"%s\" is not a valid c++ identifier (invalid character \"%c\" at position %d)"),Name.wx_str(),wxChar(Name.GetChar(0)),0));
        else
            Corrected.Append(Name.GetChar(0));

        static wxString NextChars(
            _T("0123456789")
            _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
            _T("abcdefghijklmnopqrstuvwxyz")
            _T("_"));

        for ( size_t i=1; i<Name.Length(); ++i )
        {
            if ( NextChars.Find(Name.GetChar(i)) == -1 )
            {
                Manager::Get()->GetLogManager()->DebugLog(F(_T("wxSmith: Variable name : \"%s\" is not a valid c++ identifier (invalid character \"%c\" at position %lu)"),
                                                            Name.wx_str(),
                                                            wxChar(Name.GetChar(i)),
                                                            static_cast<unsigned long>(i)));
            }
            else
                Corrected.Append(Name.GetChar(i));
        }
    }

    bool Diff = Name != Corrected;
    Name = Corrected;
    return Diff;
}
Example #21
0
void CodeFormatter::AstyleFormat(const wxString& input, const wxString& options, wxString& output)
{
    char* textOut = AStyleMain(_C(input), _C(options), ASErrorHandler, ASMemoryAlloc);
    if(textOut) {
        output = _U(textOut);
        output.Trim();
        delete[] textOut;
    }
}
void NmeaConverter_pi::SendNMEASentence(wxString sentence)
{
    sentence.Trim();
    wxString Checksum = ComputeChecksum(sentence);
    sentence = sentence.Append(wxT("*"));
    sentence = sentence.Append(Checksum);
    sentence = sentence.Append(wxT("\r\n"));
    PushNMEABuffer(sentence);
}
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 #24
0
void inifile_trim( wxString& buffer )
{
	buffer.Trim(false);			// trims left side.

	if( buffer.Length() <= 1 )	// this I'm not sure about... - air
	{
		buffer.Empty();
		return;
	}

	if( buffer.Left( 2 ) == L"//" )
	{
		buffer.Empty();
		return;
	}

	buffer.Trim(true);			// trims right side.
}
void FileUtils::OSXOpenDebuggerTerminalAndGetTTY(const wxString& path, wxString& tty, long& pid)
{
    tty.Clear();
    wxString command;
    wxString tmpfile;
    wxString escapedPath = path;
    if(escapedPath.Contains(" ")) {
        escapedPath.Prepend("\"").Append("\"");
    }
    tmpfile << "/tmp/terminal.tty." << ::wxGetProcessId();
    command << "osascript -e 'tell app \"Terminal\" to do script \"tty > " << tmpfile << " && clear && sleep 12345\"'";
    CL_DEBUG("Executing: %s", command);
    long res = ::wxExecute(command);
    if(res == 0) {
        CL_WARNING("Failed to execute command:\n%s", command);
        return;
    }

    // Read the tty from the file, wait for it up to 10 seconds
    wxFileName ttyFile(tmpfile);
    pid = wxNOT_FOUND;
    for(size_t i = 0; i < 10; ++i) {
        if(!ttyFile.Exists()) {
            ::wxSleep(1);
            continue;
        }
        ReadFileContent(ttyFile, tty);
        tty.Trim().Trim(false);

        // Remove the file
        wxLogNull noLog;
        ::wxRemoveFile(ttyFile.GetFullPath());

        // Get the parent process ID (we want the parent PID and not
        // the sleep command PID)
        wxString psCommand;
        psCommand << "ps -A -o ppid,command";
        wxString psOutput = ProcUtils::SafeExecuteCommand(psCommand);
        CL_DEBUG("PS output:\n%s\n", psOutput);
        wxArrayString lines = ::wxStringTokenize(psOutput, "\n", wxTOKEN_STRTOK);
        for(size_t u = 0; u < lines.GetCount(); ++u) {
            wxString l = lines.Item(u);
            l.Trim().Trim(false);
            if(l.Contains("sleep") && l.Contains("12345")) {
                // we got a match
                CL_DEBUG("Got a match!");
                wxString ppidString = l.BeforeFirst(' ');
                ppidString.ToCLong(&pid);
                break;
            }
        }
        break;
    }
    CL_DEBUG("PID is: %d\n", (int)pid);
    CL_DEBUG("TTY is: %s\n", tty);
}
Example #26
0
void wxGPProcess::ProcessInput(wxString sInputData)
{
	if(m_nState != enumGISTaskWork)
        return;
    sInputData = sInputData.Trim(true).Trim(false);
//INFO, DONE, ERR, ??
	wxString sRest;
	if( sInputData.StartsWith(wxT("DONE: "), &sRest) )
	{
		int nPercent = wxAtoi(sRest.Trim(true).Trim(false).Truncate(sRest.Len() - 1));
		wxTimeSpan Elapsed = wxDateTime::Now() - m_dtBeg;//time left
        wxString sTxt;
		if(m_pProgressor)
			m_pProgressor->SetValue(nPercent);

        double nPercentR = 100 - nPercent;
		if(nPercentR >= 0)
		{
			//wxTimeSpan Remains = Elapsed * (nPercentR / nPercent);
			long dMSec = double(Elapsed.GetMilliseconds().ToDouble() * nPercentR) / nPercent;
			wxTimeSpan Remains = wxTimeSpan(0,0,0,dMSec);
			m_dtEstEnd = wxDateTime::Now() + Remains;
			sTxt = wxString(_("Remains ")) + Remains.Format(_("%H hour(s) %M min. %S sec."));
		}

		if(m_pTrackCancel && !sTxt.IsEmpty())
			m_pTrackCancel->PutMessage(sTxt, -1, enumGISMessageTitle);
		return;
	}
	if( sInputData.StartsWith(wxT("INFO: "), &sRest) )
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sRest, -1, enumGISMessageNorm);
		return;
	}
	if( sInputData.StartsWith(wxT("ERR: "), &sRest) )
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sRest, -1, enumGISMessageErr);
		return;
	}
	if( sInputData.StartsWith(wxT("WARN: "), &sRest) )
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sRest, -1, enumGISMessageWarning);
		return;
	}
    else
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sInputData, -1, enumGISMessageInfo);
		return;
	}
}
Example #27
0
void CommandBuilder::BuildCommand(wxString cmdString)
{
   // Find the command name terminator...  If there is more than one word and
   // no terminator, the command is badly formed
   cmdString.Trim(true); cmdString.Trim(false);
   int splitAt = cmdString.Find(wxT(':'));
   if (splitAt < 0 && cmdString.Find(wxT(' ')) >= 0) {
      mError = wxT("Command is missing ':'");
      ScriptCommandRelay::SendResponse(wxT("\n"));
      mValid = false;
      return;
   }

   wxString cmdName = cmdString.Left(splitAt);
   wxString cmdParams = cmdString.Mid(splitAt+1);
   cmdName.Trim(true);
   cmdParams.Trim(false);

   BuildCommand(cmdName, cmdParams);
}
jewel::Decimal
wx_to_decimal
(   wxString wxs,
    wxLocale const& loc,
    DecimalParsingFlags p_flags
)
{
    bool const allow_parens =
        p_flags.test(string_flags::allow_negative_parens);
    wxs = wxs.Trim().Trim(false);  // trim both right and left.
    typedef wxChar CharT;
    static CharT const open_paren = wxChar('(');
    static CharT const close_paren = wxChar(')');
    static CharT const minus_sign = wxChar('-');
    wxString const decimal_point_s = loc.GetInfo
    (   wxLOCALE_DECIMAL_POINT,
        wxLOCALE_CAT_MONEY
    );
    wxString const thousands_sep_s = loc.GetInfo
    (   wxLOCALE_THOUSANDS_SEP,
        wxLOCALE_CAT_MONEY
    );
    if (wxs.IsEmpty())
    {
        return Decimal(0, 0);
    }
    JEWEL_ASSERT (wxs.Len() >= 1);
    if ((wxs.Len() == 1) && (*(wxs.begin()) == minus_sign))
    {
        return Decimal(0, 0);
    }

    // We first convert wxs into a canonical form in which there are no
    // thousands separators, negativity is indicated only by a minus
    // sign, and the decimal point is '.'.
    if (allow_parens && (wxs[0] == open_paren) && (wxs.Last() == close_paren))
    {
        wxs[0] = minus_sign;  // Replace left parenthesis with minus sign
        wxs.RemoveLast();  // Drop right parenthesis
    }
    wxs.Replace(thousands_sep_s, wxEmptyString);

    // We need to get the std::locale (not wxLocale) related decimal point
    // character, so that we can ensure the Decimal constructor-from-string
    // sees that appropriate decimal point character.
    locale const gloc;  // global locale
    char const spot_char = use_facet<numpunct<char> >(gloc).decimal_point();
    char const spot_str[] = { spot_char, '\0' };
    wxs.Replace(decimal_point_s, wxString(spot_str));

    string const s = wx_to_std8(wxs);
    Decimal const ret(s);
    return ret;
}
Example #29
0
void LocalWorkspace::GetSearchInFilesMask(wxString& findInFileMask, const wxString& defaultValue)
{
    findInFileMask.Clear();
    findInFileMask = defaultValue;
    if(!SanityCheck()) return;

    wxXmlNode* optsNode = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("FindInFilesMask"));
    if(optsNode) {
        findInFileMask = optsNode->GetNodeContent();
        findInFileMask.Trim().Trim(false);
    }
}
Example #30
0
// Removes MI additional characters from string
static void StripString(wxString &string)
{
	string.Replace(wxT("\\n\""), wxT("\""));
	string = string.AfterFirst(wxT('"'));
	string = string.BeforeLast(wxT('"'));
	string.Replace(wxT("\\\""), wxT("\""));
	string.Replace(wxT("\\\\"), wxT("\\"));
	string.Replace(wxT("\\\\r\\\\n"), wxT("\r\n"));
	string.Replace(wxT("\\\\n"), wxT("\n"));
	string.Replace(wxT("\\\\r"), wxT("\r"));
	string = string.Trim();
}