SectionFieldAlignment SectionFieldDescriptor::ParseAlignment(wxString& value) { if ( value.Cmp(_("L")) == 0 ) { return FA_LEFT; } else if ( value.Cmp(_("R")) == 0 ) { return FA_RIGHT; } else { throw wxString::Format(DESCRIPTOR_WRONG_ALIGNMENT + wxString(" %s"), value); } }
void EdiComposer::UpdateTrailer(const wxString& recordType) { if ( recordType.Cmp(ADDED) == 0 ) { GetTrailer().TotalAdds++; } else if( recordType.Cmp(CHANGED) == 0 ) { GetTrailer().TotalChanges++; } else if( recordType.Cmp(MOVED) == 0 ) { GetTrailer().TotalMoveHistory++; } else if( recordType.Cmp(REPLACED) == 0 ) { GetTrailer().TotalReplacements++; } };
int wxVListBoxComboPopup::Append(const wxString& item) { int pos = (int)m_strings.GetCount(); if ( m_combo->GetWindowStyle() & wxCB_SORT ) { // Find position // TODO: Could be optimized with binary search wxArrayString strings = m_strings; unsigned int i; for ( i=0; i<strings.GetCount(); i++ ) { if ( item.Cmp(strings.Item(i)) < 0 ) { pos = (int)i; break; } } } Insert(item,pos); return pos; }
void SelectAllTreeItems(const wxString &searchStr, wxTreeCtrl *tvCtrl, int SelImageIdx, const wxTreeItemId& idParent, wxTreeItemIdValue cookie) { wxTreeItemId id; if (!cookie) id = tvCtrl->GetFirstChild(idParent, cookie); else id = tvCtrl->GetNextChild(idParent, cookie); if (!id.IsOk()) return; if (searchStr.Cmp(wxEmptyString) == 0) tvCtrl->SetItemImage(id, SelImageIdx); else { if (tvCtrl->GetItemText(id).Upper().Contains(searchStr.Upper())) { tvCtrl->SetItemImage(id, SelImageIdx); } } if (tvCtrl->ItemHasChildren(id)) SelectAllTreeItems(searchStr, tvCtrl, SelImageIdx, id); SelectAllTreeItems(searchStr, tvCtrl, SelImageIdx, idParent, cookie); }
bool SbAccessFilterPolicy::setPath(wxString path) { struct apn_rule *rule; rule = getApnRule(); if ((rule == NULL) || path.IsEmpty()){ return (false); } startChange(); if (rule->rule.sbaccess.path != NULL) { free(rule->rule.sbaccess.path); rule->rule.sbaccess.path = NULL; setModified(); } if (path.Cmp(wxT("any")) != 0) { rule->rule.sbaccess.path = strdup(path.fn_str()); setModified(); } finishChange(); return (true); }
bool Identifier::equals(const wxString& rhs) const { if (needsQuoting(textM)) return (0 == rhs.Cmp(textM)); else return (0 == rhs.CmpNoCase(textM)); }
int CComparisonManager::CompareFiles(const int dirSortMode, const wxString& local, const wxString& remote, bool localDir, bool remoteDir) { switch (dirSortMode) { default: if (localDir) { if (!remoteDir) return -1; } else if (remoteDir) return 1; break; case 2: // Inline break; } #ifdef __WXMSW__ return local.CmpNoCase(remote); #else return local.Cmp(remote); #endif return 0; }
static bool sortfunc(const wxString& a, const wxString& b) { #ifdef __WXMSW__ return b.CmpNoCase(a) > 0; #else return b.Cmp(a) > 0; #endif }
static bool sortfunc(const wxString& a, const wxString& b) { int cmp = a.CmpNoCase(b); if (!cmp) cmp = a.Cmp(b); return cmp < 0; }
bool ALMRunConfig::set(const wxString& name,const wxString &value) { if (name.Cmp("Explorer") == 0) Explorer = value; else if (name.Cmp("Root") == 0) { Root = value; if (Root.empty()) return false; wxSetWorkingDirectory(Root); } else if(name.Cmp("HotKey") == 0) HotKey = value; else if(name.Cmp("HotKeyReLoad") == 0) HotKeyReLoad = value; else return false; return ::wxSetEnv(wxT("ALMRUN_")+name.Upper(),value); }
// 10個のプルダウン全て調べる void WxSQLiteTest::ColumnPullDownSearcher(wxString& dataType, wxString& value) { // それぞれのカラムを調べる if (!dataType.IsEmpty() && !value.IsEmpty()) { if (!dataType.Cmp(wxT("カラムを作らない")) == 0 && ColumnValidator(value)) { columnArray->Add(dataType); columnArray->Add(value.MakeUpper()); wxMessageBox(dataType); wxMessageBox(value); } } }
int IniParser::FindGroupByName(const wxString& name, bool caseSensitive) const { for (int i = 0; i < GetGroupsCount(); ++i) { bool found = caseSensitive ? name.Cmp(m_Array[i].name) == 0 : name.CmpNoCase(m_Array[i].name) == 0; if (found) return i; } return -1; }
int ProjectListBox::GetProjectCountByPath(wxString path) { int count = 0; for(int i=0; i<this->GetItemCount(); i++) { if(path.Cmp(GetText(i,1))==0) { count++; } } return count; }
bool ALMRunConfig::set(const wxString& name,const int value) { if (name.Cmp("CompareMode") == 0) CompareMode = value; else if (name.Cmp("NumberKey") == 0) config[NumberKey] = (value != 0); else if (name.Cmp("ShowTrayIcon") == 0) { config[ShowTrayIcon] = value != 0; ::wxGetApp().GetFrame().ShowTrayIcon(config[ShowTrayIcon]); } else if (name.Cmp("ShowTopTen") == 0) config[ShowTopTen] = value != 0; else if (name.Cmp("ExecuteIfOnlyOne") == 0) config[ExecuteIfOnlyOne] = value != 0; else if (name.Cmp("StayOnTop") == 0) { config[StayOnTop] = value != 0; MerryFrame& frm = wxGetApp().GetFrame(); long style = frm.GetWindowStyle(); if (config[StayOnTop]) frm.SetWindowStyle(style|wxSTAY_ON_TOP); else if (style & wxSTAY_ON_TOP) frm.SetWindowStyle(style^wxSTAY_ON_TOP); } else return false; return true; }
//----------------------------------------------------------------------- int DialogResourceGroups::getInternalGroupIndex( const wxString& groupName ) const { int rowsize = m_groupsGrid->GetRows(); for ( int i = 0; i < rowsize; i++ ) { const wxString rowname = m_groupsGrid->GetCellValue( i, 0 ); if ( rowname.Cmp( groupName ) == 0 ) return i; } return -1; }
wxString SectionFieldDescriptor::Encode(wxString& value, wxString& type) { wxDateTime date; if ( type.Cmp("date") == 0 && value.Length() != 0 ) { if ( date.ParseFormat(value, "%Y/%m/%d") ) { return date.Format("%Y%m%d"); } else { return value; } } else { return value; } }
void CViewHeader::AddRecentDirectory(const wxString &directory) { const int len = directory.Len(); // Check if directory is already in the list for (auto iter = m_recentDirectories.begin(); iter != m_recentDirectories.end(); ++iter) { if (*iter == directory) { m_pComboBox->SetStringSelection(directory); m_pComboBox->SetSelection(len, len); return; } } if (m_recentDirectories.size() == 20) { wxASSERT(m_recentDirectories.front() != directory); int pos = 0; for (auto it = m_sortedRecentDirectories.begin(); it != m_sortedRecentDirectories.end(); ++pos, ++it) { if (*it == m_recentDirectories.front()) { m_sortedRecentDirectories.erase(it); break; } } wxASSERT(pos != 20); wxASSERT(m_pComboBox->FindString(m_recentDirectories.front(), true) == pos); m_pComboBox->Delete(pos); m_recentDirectories.pop_front(); } m_recentDirectories.push_back(directory); // Find insertion position. // Do a linear search, binary search not worth it for 20 items int pos = 0; auto it = m_sortedRecentDirectories.begin(); for (; it != m_sortedRecentDirectories.end(); ++pos, ++it) { int cmp = directory.CmpNoCase(*it); if (cmp < 0 || (!cmp && directory.Cmp(*it) < 0)) { break; } } m_sortedRecentDirectories.insert(it, directory); int item = m_pComboBox->Insert(directory, pos); m_pComboBox->SetSelection(item); m_pComboBox->SetSelection(len, len); wxASSERT(m_sortedRecentDirectories.size() == m_recentDirectories.size()); }
int IniParser::FindKeyByName(int groupIdx, const wxString& name, bool caseSensitive) const { if (groupIdx == -1) return -1; for (int i = 0; i < GetKeysCount(groupIdx); ++i) { bool found = caseSensitive ? name.Cmp(m_Array[groupIdx].pairs[i].key) == 0 : name.CmpNoCase(m_Array[groupIdx].pairs[i].key) == 0; if (found) return i; } return -1; }
CompilePPUProgram::SP_TYPE CompilePPUProgram::GetSpType(const wxString& op) { if(op.Cmp(".int") == 0) return SP_INT; if(op.Cmp(".string") == 0) return SP_STRING; if(op.Cmp(".strlen") == 0) return SP_STRLEN; if(op.Cmp(".buf") == 0) return SP_BUF; if(op.Cmp(".srl") == 0) return SP_SRL; if(op.Cmp(".srr") == 0) return SP_SRR; if(op.Cmp(".mul") == 0) return SP_MUL; if(op.Cmp(".div") == 0) return SP_DIV; if(op.Cmp(".add") == 0) return SP_ADD; if(op.Cmp(".sub") == 0) return SP_SUB; if(op.Cmp(".and") == 0) return SP_AND; if(op.Cmp(".or") == 0) return SP_OR; if(op.Cmp(".xor") == 0) return SP_XOR; if(op.Cmp(".not") == 0) return SP_NOT; if(op.Cmp(".nor") == 0) return SP_NOR; return SP_ERR; }
void IRC::Disconnect(wxString& QuitMsg, bool UseMsg) { if (UseMsg) { if (IRCState == CONNECTED || IRCState == INSESSION) { if (!QuitMsg.Cmp("")) { QuitMsg = wxString::Format("%s IRC Client v%s",xAPPNAME,xAPPVER); } Throw("QUIT :%s",QuitMsg.c_str()); } } Sock.Close(); InitConnection(); UpdateState(DISCONNECTED); }
int wxSortedArrayString::Index(const wxString& str, bool WXUNUSED_UNLESS_DEBUG(bCase), bool WXUNUSED_UNLESS_DEBUG(bFromEnd)) const { wxASSERT_MSG( bCase && !bFromEnd, "search parameters ignored for sorted array" ); wxSortedArrayString::const_iterator it = std::lower_bound(begin(), end(), str, wxStringCompare(wxStringCmp())); if ( it == end() || str.Cmp(*it) != 0 ) return wxNOT_FOUND; return it - begin(); }
/** * Compare two references (e.g. "R100", "R19") and perform a 'natural' sort * This sorting must preserve numerical order rather than alphabetical * e.g. "R100" is lower (alphabetically) than "R19" * BUT should be placed after R19 */ int BOM_TABLE_GROUP::SortReferences( const wxString& aFirst, const wxString& aSecond ) { // Default sorting int defaultSort = aFirst.Cmp( aSecond ); static const wxString REGEX_STRING = "^([a-zA-Z]+)(\\d+)$"; // Compile regex statically static wxRegEx regexFirst( REGEX_STRING, wxRE_ICASE | wxRE_ADVANCED ); static wxRegEx regexSecond( REGEX_STRING, wxRE_ICASE | wxRE_ADVANCED ); if( !regexFirst.Matches( aFirst ) || !regexSecond.Matches( aSecond ) ) { return defaultSort; } // First priority is to order by prefix wxString prefixFirst = regexFirst.GetMatch( aFirst, 1 ); wxString prefixSecond = regexSecond.GetMatch( aSecond, 1 ); if( prefixFirst.CmpNoCase( prefixSecond ) != 0 ) // Different prefixes! { return defaultSort; } wxString numStrFirst = regexFirst.GetMatch( aFirst, 2 ); wxString numStrSecond = regexSecond.GetMatch( aSecond, 2 ); // If either match failed, just return normal string comparison if( numStrFirst.IsEmpty() || numStrSecond.IsEmpty() ) { return defaultSort; } // Convert each number string to an integer long numFirst = 0; long numSecond = 0; // If either conversion fails, return normal string comparison if( !numStrFirst.ToLong( &numFirst ) || !numStrSecond.ToLong( &numSecond ) ) { return defaultSort; } return (int) (numFirst - numSecond); }
// add item at the end size_t wxArrayString::Add(const wxString& str, size_t nInsert) { if ( m_autoSort ) { // insert the string at the correct position to keep the array sorted size_t lo = 0, hi = m_nCount; while ( lo < hi ) { size_t i; i = (lo + hi)/2; int res; res = m_compareFunction ? m_compareFunction(str, m_pItems[i]) : str.Cmp(m_pItems[i]); if ( res < 0 ) hi = i; else if ( res > 0 ) lo = i + 1; else { lo = hi = i; break; } } wxASSERT_MSG( lo == hi, wxT("binary search broken") ); Insert(str, lo, nInsert); return (size_t)lo; } else { // Now that we must postpone freeing the old memory until we don't need it // any more, i.e. don't reference "str" which could be a reference to one // of our own strings. wxScopedArray<wxString> oldStrings(Grow(nInsert)); for (size_t i = 0; i < nInsert; i++) { // just append m_pItems[m_nCount + i] = str; } size_t ret = m_nCount; m_nCount += nInsert; return ret; } }
// add item at the end size_t wxArrayString::Add(const wxString& str, size_t nInsert) { if ( m_autoSort ) { // insert the string at the correct position to keep the array sorted size_t i, lo = 0, hi = m_nCount; int res; while ( lo < hi ) { i = (lo + hi)/2; res = str.Cmp(m_pItems[i]); if ( res < 0 ) hi = i; else if ( res > 0 ) lo = i + 1; else { lo = hi = i; break; } } wxASSERT_MSG( lo == hi, wxT("binary search broken") ); Insert(str, lo, nInsert); return (size_t)lo; } else { Grow(nInsert); for (size_t i = 0; i < nInsert; i++) { // just append m_pItems[m_nCount + i] = str; } size_t ret = m_nCount; m_nCount += nInsert; return ret; } }
void ListInterface::FilterList( const wxString &filter, List &list ) { bool bEmptyFilter = (filter.Cmp(wxEmptyString) == 0 ); int itemid = list.GetNextItemId(-1); while( itemid != -1 ) { wxListCtrl *lctrl = list.list; wxArrayInt columnorder = lctrl->GetColumnsOrder(); bool bFilter = false; wxString name = list.GetColumnValue(itemid, 0); DataEntry *entry = FindEntryByName(name); if( entry ) { for( unsigned int i = 0; i < columnorder.GetCount(); ++i ) { int c = columnorder[i]; wxListItem item; item.m_col = c; item.m_mask = wxLIST_MASK_TEXT; item.m_itemId = itemid; lctrl->GetItem(item); wxString &text = item.m_text; if( text.Contains(filter) && !bEmptyFilter ) bFilter = true; AssignEntryColour(list, itemid, *entry, bFilter); } } itemid = list.GetNextItemId(itemid); } }
int wxSortedArrayString::Index(const wxString& str, bool WXUNUSED_UNLESS_DEBUG(bCase), bool WXUNUSED_UNLESS_DEBUG(bFromEnd)) const { wxASSERT_MSG( bCase && !bFromEnd, "search parameters ignored for sorted array" ); wxSortedArrayString::const_iterator it = std::lower_bound(begin(), end(), str, #if __cplusplus >= 201103L [](const wxString& s1, const wxString& s2) { return s1 < s2; } #else // C++98 version wxStringCompare(wxStringCmp()) #endif // C++11/C++98 ); if ( it == end() || str.Cmp(*it) != 0 ) return wxNOT_FOUND; return it - begin(); }
void CompilePPUProgram::DetectArgInfo(Arg& arg) { const wxString str = arg.string; if(str.Len() <= 0) { arg.type = ARG_ERR; return; } if(GetInstruction<PPUOpcodes>(str)) { arg.type = ARG_INSTR; return; } if(str.Len() > 1) { for(u32 i=0; i<m_branches.GetCount(); ++i) { if(str.ToStdString() != m_branches[i].m_name) continue; arg.type = ARG_BRANCH; arg.value = GetBranchValue(str); return; } } switch((char)str[0]) { case 'r': case 'f': case 'v': if(str.Len() < 2) { arg.type = ARG_ERR; return; } if(str.Cmp("rtoc") == 0) { arg.type = ARG_REG_R; arg.value = 2; return; } for(u32 i=1; i<str.Len(); ++i) { if(str[i] < '0' || str[i] > '9') { arg.type = ARG_ERR; return; } } u32 reg; sscanf(str(1, str.Len() - 1), "%d", ®); if(reg >= 32) { arg.type = ARG_ERR; return; } switch((char)str[0]) { case 'r': arg.type = ARG_REG_R; break; case 'f': arg.type = ARG_REG_F; break; case 'v': arg.type = ARG_REG_V; break; default: arg.type = ARG_ERR; break; } arg.value = reg; return; case 'c': if(str.Len() > 2 && str[1] == 'r') { for(u32 i=2; i<str.Len(); ++i) { if(str[i] < '0' || str[i] > '9') { arg.type = ARG_ERR; return; } } u32 reg; sscanf(str, "cr%d", ®); if(reg < 8) { arg.type = ARG_REG_CR; arg.value = reg; } else { arg.type = ARG_ERR; } return; } break; case '"': if(str.Len() < 2) { arg.type = ARG_ERR; return; } if(str[str.Len() - 1] != '"') { arg.type = ARG_ERR; return; } arg.string = str(1, str.Len() - 2).ToStdString(); arg.type = ARG_TXT; return; } if(str.Len() > 2 && str(0, 2).Cmp("0x") == 0) { for(u32 i=2; i<str.Len(); ++i) { if( (str[i] >= '0' && str[i] <= '9') || (str[i] >= 'a' && str[i] <= 'f') || (str[i] >= 'A' && str[i] <= 'F') ) continue; arg.type = ARG_ERR; return; } u32 val; sscanf(str, "0x%x", &val); arg.type = ARG_NUM16; arg.value = val; return; } for(u32 i= str[0] == '-' ? 1 : 0; i<str.Len(); ++i) { if(str[i] < '0' || str[i] > '9') { arg.type = ARG_ERR; return; } } u32 val; sscanf(str, "%d", &val); arg.type = ARG_NUM; arg.value = val; }
wxString EdiComposer::ConvertDataForType(const wxString& data, const wxString& type) { if ( type.Cmp(TEXT_TYPE) == 0 || type.Cmp(REGEXP_TYPE) == 0 ) { return data; } else if (type.Cmp(CARRIER_TYPE) == 0) { return GetCarrier(); } else if (type.Cmp(CHOICE_TYPE) == 0) { return data; } else if (type.Cmp(NUMERIC_TYPE) == 0) { return data; } else if (type.Cmp(MONEY_TYPE) == 0) { return data; } else if (type.Cmp(ALPHA_NUMERIC_TYPE) == 0) { return data; } else if (type.Cmp(DATE_TYPE) == 0 ) { if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } wxString str(""); int c = date.GetYear()/100 - 19; str << ( c > 9 ? ( c - ( ( c/10 ) * 10) ) : c); str << date.Format("%y%m%d"); return str; } else if (type.Cmp(DATE_TYPE_0) == 0 ) { if ( data.Cmp("00/00/0000") == 0 ) { return "0000000"; } if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } wxString str(""); int c = date.GetYear()/100 - 19; str << ( c > 9 ? ( c - ( ( c/10 ) * 10) ) : c); str << date.Format("%y%m%d"); return str; } else if (type.Cmp(DATE_TYPE_9) == 0 ) { if ( data.Cmp("99/99/9999") == 0 ) { return "9999999"; } if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } wxString str(""); int c = date.GetYear()/100 - 19; str << ( c > 9 ? ( c - ( ( c/10 ) * 10) ) : c); str << date.Format("%y%m%d"); return str; } else if (type.Cmp(DATE_TYPE_09) == 0 ) { if ( data.Cmp("99/99/9999") == 0 ) { return "9999999"; } if ( data.Cmp("00/00/0000") == 0 ) { return "0000000"; } if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } wxString str(""); int c = date.GetYear()/100 - 19; str << ( c > 9 ? ( c - ( ( c/10 ) * 10) ) : c); str << date.Format("%y%m%d"); return str; } else if (type.Cmp(LONG_DATE_TYPE) == 0 ) { if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } return date.Format("%Y%m%d"); } else if (type.Cmp(LONG_DATE_TYPE_0) == 0 ) { if ( data.Cmp("00/00/0000") == 0 ) { return "00000000"; } if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } return date.Format("%Y%m%d"); } else if (type.Cmp(LONG_DATE_TYPE_9) == 0 ) { if ( data.Cmp("99/99/9999") == 0 ) { return "99999999"; } if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } return date.Format("%Y%m%d"); } else if (type.Cmp(LONG_DATE_TYPE_09) == 0 ) { if ( data.Cmp("99/99/9999") == 0 ) { return "99999999"; } if ( data.Cmp("00/00/0000") == 0 ) { return "0000000"; } if ( data == "" ) { return ""; } wxDateTime date; if ( !date.ParseFormat(data, "%m/%d/%Y") ) { wxFAIL; } return date.Format("%Y%m%d"); } else if (type.Cmp(FILE_COUNTER_TYPE) == 0) { return data; } else if (type.Cmp(ROW_COUNTER_TYPE) == 0) { return data; } else { THROW_ATF_EXCEPTION(0, wxString::Format("Unknown type '%s'", type)); } return wxEmptyString; };