int CompareDirectory(Item const &item) const { int c = directory.compare(item.directory); if (c) return c; c = filename.compare(item.filename); if (c) return c; return Compare(line, item.line); }
int CompareFile(Item const &item) const { int c = filename.compare(item.filename); if (c) return c; return Compare(line, item.line); }
bool Metalink3Reader::remove_namespace(wxString& name) { wxString ns = wxT("http://www.metalinker.org/\t"); if(name.compare(0, ns.length(), ns) == 0) { name.erase(0, ns.length()); return true; } return false; }
void CConfigMain::ChooseSIDevice(wxString deviceName, int deviceNum) { SIDevices tempType; if (!deviceName.compare(_(SIDEV_STDCONT_STR))) tempType = SIDEVICE_GC_CONTROLLER; else if (!deviceName.compare(_(SIDEV_STEERING_STR))) tempType = SIDEVICE_GC_STEERING; else if (!deviceName.compare(_(SIDEV_DANCEMAT_STR))) tempType = SIDEVICE_DANCEMAT; else if (!deviceName.compare(_(SIDEV_BONGO_STR))) tempType = SIDEVICE_GC_TARUKONGA; else if (!deviceName.compare(SIDEV_GBA_STR)) tempType = SIDEVICE_GC_GBA; else if (!deviceName.compare(_(SIDEV_AM_BB_STR))) tempType = SIDEVICE_AM_BASEBOARD; else tempType = SIDEVICE_NONE; SConfig::GetInstance().m_SIDevice[deviceNum] = tempType; if (Core::GetState() != Core::CORE_UNINITIALIZED) { // Change plugged device! :D SerialInterface::ChangeDevice(tempType, deviceNum); } }
/* static */ wxString wxFileSystemHandler::GetRightLocation(const wxString& location) { int i, len = location.length(); for (i = len-1; i >= 0; i--) { if (location[i] == wxT('#')) len = i; if (location[i] != wxT(':')) continue; // C: on Windows if (i == 1) continue; if (i >= 2 && wxIsalpha(location[i-1]) && location[i-2] == wxT('/')) continue; // Could be the protocol break; } if (i == 0) return wxEmptyString; const static wxString protocol(wxT("file:")); if (i < (int)protocol.length() - 1 || location.compare(0, i + 1, protocol)) return location.Mid(i + 1, len - i - 1); int s = ++i; // Start position // Check if there are three '/'s after "file:" int end = wxMin(len, s + 3); while (i < end && location[i] == wxT('/')) i++; if (i == s + 2) // Host is specified, e.g. "file://host/path" return location.Mid(s, len - s); if (i > s) { // Remove the last '/' if it is preceding "C:/...". // Otherwise, keep it. if (i + 1 >= len || location[i + 1] != wxT(':')) i--; else if (i + 4 < len) { // Check if ':' was encoded const static wxString colonLower(wxT("%3a")); const static wxString colonUpper(wxT("%3A")); wxString sub =location.Mid(i + 1, 3); if (sub == colonLower || sub == colonUpper) i--; } } return location.Mid(i, len - i); }
// searches the array for an item (forward or backwards) int wxArrayString::Index(const wxString& str, bool bCase, bool bFromEnd) const { if ( m_autoSort ) { // use binary search in the sorted array wxASSERT_MSG( bCase && !bFromEnd, wxT("search parameters ignored for auto sorted array") ); size_t lo = 0, hi = m_nCount; while ( lo < hi ) { size_t i; i = (lo + hi)/2; int res; res = str.compare(m_pItems[i]); if ( res < 0 ) hi = i; else if ( res > 0 ) lo = i + 1; else return i; } return wxNOT_FOUND; } else { // use linear search in unsorted array if ( bFromEnd ) { if ( m_nCount > 0 ) { size_t ui = m_nCount; do { if ( m_pItems[--ui].IsSameAs(str, bCase) ) return ui; } while ( ui != 0 ); } } else { for( size_t ui = 0; ui < m_nCount; ui++ ) { if( m_pItems[ui].IsSameAs(str, bCase) ) return ui; } } } return wxNOT_FOUND; }
/** * Check that a string looks like a floating point number that can * be dealt with. */ static bool validateFloatField( const wxString& aStr ) { // Skip empty fields if( aStr.size() == 0 ) return false; // a single . or , doesn't count as number, although valid in a float if( aStr.size() == 1 ) { if( (aStr.compare( "." ) == 0) || (aStr.compare( "," ) == 0) ) return false; } return true; }
bool wxRfc2231::ExtractParameter(const std::list<mimetic::FieldParam>& parameters_list, const wxString& name, wxString& value) { /* Parse complete list and check if we can find parameter */ std::list<mimetic::FieldParam>::const_iterator it; for (it = parameters_list.begin(); it != parameters_list.end(); it++) { if (name.compare(wxString(it->name().c_str(), wxConvLocal)) == 0) { value = wxString(it->value().c_str(), wxConvLocal); return true; } } /* We did not found the parameter */ return false; }
/* static*/ PicType PicType::FindPIC(wxString picTypeStr) { for (unsigned int i=0;i<s_arrSupported.size();i++) { if (picTypeStr.compare(s_arrSupported[i].name)==0) { // this is a supported PIC! PicType ret; if (!ret.LoadPIC(s_arrSupported[i])) wxLogError(_("Could not load data for PIC '%s'."), picTypeStr); // we either failed or successfully loaded the PIC data... return ret; } } return UPP_INVALID_PIC; }
t_WLib WiredCodec::FindBestCodec(wxString extension) { list<t_WLib>::const_iterator iterTWLib; list<t_LibInfo>::const_iterator iterTLibInfo; short note; t_WLib TheLib; note = 0; for (iterTWLib = _WLib.begin(); iterTWLib != _WLib.end(); iterTWLib++) for (iterTLibInfo = (*iterTWLib).Info.begin(); iterTLibInfo != (*iterTWLib).Info.end(); iterTLibInfo++) if (!extension.compare((*iterTLibInfo).Extension)) if ((*iterTLibInfo).Note > note) { note = (*iterTLibInfo).Note; TheLib = (*iterTWLib); } return TheLib; }
bool CDownloadQueue::AddLink( const wxString& link, uint8 category ) { wxString uri(link); if (link.compare(0, 7, wxT("magnet:")) == 0) { uri = CMagnetED2KConverter(link); if (uri.empty()) { AddLogLineC(CFormat(_("Cannot convert magnet link to eD2k: %s")) % link); return false; } } if (uri.compare(0, 7, wxT("ed2k://")) == 0) { return AddED2KLink(uri, category); } else { AddLogLineC(CFormat(_("Unknown protocol of link: %s")) % link); return false; } }
void GameCubeConfigPane::ChooseEXIDevice(const wxString& deviceName, int deviceNum) { TEXIDevices tempType; if (!deviceName.compare(_(EXIDEV_MEMCARD_STR))) tempType = EXIDEVICE_MEMORYCARD; else if (!deviceName.compare(_(EXIDEV_MEMDIR_STR))) tempType = EXIDEVICE_MEMORYCARDFOLDER; else if (!deviceName.compare(_(EXIDEV_MIC_STR))) tempType = EXIDEVICE_MIC; else if (!deviceName.compare(EXIDEV_BBA_STR)) tempType = EXIDEVICE_ETH; else if (!deviceName.compare(EXIDEV_AGP_STR)) tempType = EXIDEVICE_AGP; else if (!deviceName.compare(_(EXIDEV_AM_BB_STR))) tempType = EXIDEVICE_AM_BASEBOARD; else if (!deviceName.compare(EXIDEV_GECKO_STR)) tempType = EXIDEVICE_GECKO; else if (!deviceName.compare(_(DEV_NONE_STR))) tempType = EXIDEVICE_NONE; else tempType = EXIDEVICE_DUMMY; // Gray out the memcard path button if we're not on a memcard or AGP if (tempType == EXIDEVICE_MEMORYCARD || tempType == EXIDEVICE_AGP) m_memcard_path[deviceNum]->Enable(); else if (deviceNum == 0 || deviceNum == 1) m_memcard_path[deviceNum]->Disable(); SConfig::GetInstance().m_EXIDevice[deviceNum] = tempType; if (Core::IsRunning()) { // Change plugged device! :D ExpansionInterface::ChangeDevice( (deviceNum == 1) ? 1 : 0, // SlotB is on channel 1, slotA and SP1 are on 0 tempType, // The device enum to change to (deviceNum == 2) ? 2 : 0); // SP1 is device 2, slots are device 0 } }
void wxNumberFormatter::RemoveTrailingZeroes(wxString& s) { // If number is in scientific format, trailing zeroes belong to the exponent and cannot be removed. if ( s.find_first_of("eE") != wxString::npos ) return; const size_t posDecSep = s.find(GetDecimalSeparator()); // No decimal point => removing trailing zeroes irrelevant for integer number. if ( posDecSep == wxString::npos ) return; wxCHECK_RET( posDecSep, "Can't start with decimal separator" ); // Find the last character to keep. size_t posLastNonZero = s.find_last_not_of("0"); // If it's the decimal separator itself, don't keep it neither. if ( posLastNonZero == posDecSep ) posLastNonZero--; s.erase(posLastNonZero + 1); // Remove sign from orphaned zero. if ( s.compare("-0") == 0 ) s = "0"; }
void CConfigMain::ChooseEXIDevice(wxString deviceName, int deviceNum) { TEXIDevices tempType; if (!deviceName.compare(_(EXIDEV_MEMCARD_STR))) tempType = EXIDEVICE_MEMORYCARD; else if (!deviceName.compare(_(EXIDEV_MEMDIR_STR))) tempType = EXIDEVICE_MEMORYCARDFOLDER; else if (!deviceName.compare(_(EXIDEV_MIC_STR))) tempType = EXIDEVICE_MIC; else if (!deviceName.compare(EXIDEV_BBA_STR)) tempType = EXIDEVICE_ETH; else if (!deviceName.compare(_(EXIDEV_AM_BB_STR))) tempType = EXIDEVICE_AM_BASEBOARD; else if (!deviceName.compare(EXIDEV_GECKO_STR)) tempType = EXIDEVICE_GECKO; else if (!deviceName.compare(_(DEV_NONE_STR))) tempType = EXIDEVICE_NONE; else tempType = EXIDEVICE_DUMMY; // Gray out the memcard path button if we're not on a memcard if (tempType == EXIDEVICE_MEMORYCARD) GCMemcardPath[deviceNum]->Enable(); else if (deviceNum == 0 || deviceNum == 1) GCMemcardPath[deviceNum]->Disable(); SConfig::GetInstance().m_EXIDevice[deviceNum] = tempType; if (Core::GetState() != Core::CORE_UNINITIALIZED) { // Change plugged device! :D ExpansionInterface::ChangeDevice( (deviceNum == 1) ? 1 : 0, // SlotB is on channel 1, slotA and SP1 are on 0 tempType, // The device enum to change to (deviceNum == 2) ? 2 : 0); // SP1 is device 2, slots are device 0 } }
int operator()(const wxString& s1, const wxString& s2) const { return s1.compare(s2); }
bool wxMarkupParser::Parse(const wxString& text) { // The stack containing the names and corresponding attributes (which are // actually only used for <span> tags) of all of the currently opened tag // or none if we're not inside any tag. wxStack<TagAndAttrs> tags; // Current run of text. wxString current; const wxString::const_iterator end = text.end(); for ( wxString::const_iterator it = text.begin(); it != end; ++it ) { switch ( (*it).GetValue() ) { case '<': { // Flush the text preceding the tag, if any. if ( !current.empty() ) { m_output.OnText(current); current.clear(); } // Remember the tag starting position for the error // messages. const size_t pos = it - text.begin(); bool start = true; if ( ++it != end && *it == '/' ) { start = false; ++it; } const wxString tag = ExtractUntil('>', it, end); if ( tag.empty() ) { wxLogDebug("%s at %lu.", it == end ? "Unclosed tag starting" : "Empty tag", pos); return false; } if ( start ) { wxString attrs; const wxString name = tag.BeforeFirst(' ', &attrs); TagAndAttrs tagAndAttrs(name); const wxString err = ParseAttrs(attrs, tagAndAttrs); if ( !err.empty() ) { wxLogDebug("Bad attributes for \"%s\" " "at %lu: %s.", name, pos, err); return false; } tags.push(tagAndAttrs); } else // end tag { if ( tags.empty() || tags.top().name != tag ) { wxLogDebug("Unmatched closing tag \"%s\" at %lu.", tag, pos); return false; } } if ( !OutputTag(tags.top(), start) ) { wxLogDebug("Unknown tag at %lu.", pos); return false; } if ( !start ) tags.pop(); } break; case '>': wxLogDebug("'>' should be escaped as \">\"; at %lu.", it - text.begin()); break; case '&': // Processing is somewhat complicated: we need to recognize at // least the "<" entity to allow escaping left square // brackets in the markup and, in fact, we recognize all of the // standard XML entities for consistency with Pango markup // parsing. // // However we also allow '&' to appear unescaped, i.e. directly // and not as "&" when it is used to introduce the mnemonic // for the label. In this case we simply leave it alone. // // Notice that this logic makes it impossible to have a label // with "lt;" inside it and using "l" as mnemonic but hopefully // this shouldn't be a problem in practice. { const size_t pos = it - text.begin() + 1; unsigned n; for ( n = 0; n < WXSIZEOF(xmlEntities); n++ ) { const XMLEntity& xmlEnt = xmlEntities[n]; if ( text.compare(pos, xmlEnt.len, xmlEnt.name) == 0 && text[pos + xmlEnt.len] == ';' ) { // Escape the ampersands if needed to protect them // from being interpreted as mnemonics indicators. if ( xmlEnt.value == '&' ) current += "&&"; else current += xmlEnt.value; it += xmlEnt.len + 1; // +1 for '&' itself break; } } if ( n < WXSIZEOF(xmlEntities) ) break; //else: fall through, '&' is not special } default: current += *it; } } if ( !tags.empty() ) { wxLogDebug("Missing closing tag for \"%s\"", tags.top().name); return false; } if ( !current.empty() ) m_output.OnText(current); return true; }