void CompilerPatternDlg::OnSubmit(wxCommandEvent& event) { if(GetPattern().Trim().IsEmpty() || GetFileIndex().Trim().IsEmpty() || GetLineIndex().Trim().IsEmpty()) { wxMessageBox(_("Please fill all the fields"), _("CodeLite"), wxOK | wxICON_INFORMATION, this); return; } EndModal(wxID_OK); }
double data_base::GetValueFromDataWithLine(const std::string& search, int instanceIndex) const { /*Note: instanceIndex is the number of times a search word can be found in the target file. i.e. value = 1; value = 3; has 2 instances, so if inctanceIndex is 1 the result will be 1 and if instanceIndex is 2 the result will be 3. This method gets the value from an specific instance of a keyword.*/ int start = GetLineIndex(search, instanceIndex); int end = searchCharIndex(';', buffer, start); if(end == ENDOFFILE) { end = searchCharIndex('\n', buffer, start); } std::string numberStr = sliceStr(buffer,start, end);//Get slice numberStr = removeCharFromStr('=', numberStr.c_str()); return cStrToNum(numberStr.c_str()); }
void data_base::WriteValueWithLineIndex(const std::string& value, const std::string& search, int instanceIndex) { /*This methods find the instance of a keyword and modifies its value. i.e. value = 3;\nvalue = 4 [mod line 2 with 3] -> value = 3;\nvalue = 3.*/ int start = GetLineIndex(search, instanceIndex) + 3; int end = searchCharIndex(';', buffer, start); int size = end - start; if(end == ENDOFFILE) { end = searchCharIndex('\n', buffer, start); } if(buffer != "") { buffer.replace(start, size, value); FlushData(); } }
std::string data_base::GetStrFromDataWithLine(const std::string& search, int instanceIndex) const { /*Note: instanceIndex is the number of times a search word can be found in the target file. i.e. value = 1; value = 3; has 2 instances, so if inctanceIndex is 1 the result will be 1 and if instanceIndex is 2 the result will be 3. This method gets the value from an specific instance of a keyword.*/ int start = GetLineIndex(search, instanceIndex); int end = searchCharIndex(';', buffer, start); if(end == ENDOFFILE) { end = searchCharIndex('\n', buffer, start); } std::string Str = sliceStr(buffer,start, end); Str = removeCharFromStr('=', Str.c_str());//Cleans value string from the = sign while(Str[0] == ' ')//remover initial spaces left after removing '='. { Str = removeCharFromStr(' ', Str.c_str()); } return Str; }