bool Envelope::HandleXMLTag(const wxChar *tag, const wxChar **attrs) { // Return unless it's the envelope tag. if (wxStrcmp(tag, wxT("envelope"))) return false; int numPoints = 0; long nValue = -1; while (*attrs) { const wxChar *attr = *attrs++; const wxChar *value = *attrs++; if (!value) break; const wxString strValue = value; if( !wxStrcmp(attr, wxT("numpoints")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) numPoints = nValue; } if (numPoints < 0) return false; WX_CLEAR_ARRAY(mEnv); mEnv.Alloc(numPoints); return true; }
bool WaveClip::HandleXMLTag(const wxChar *tag, const wxChar **attrs) { if (!wxStrcmp(tag, wxT("waveclip"))) { double dblValue; while (*attrs) { const wxChar *attr = *attrs++; const wxChar *value = *attrs++; if (!value) break; const wxString strValue = value; if (!wxStrcmp(attr, wxT("offset"))) { if (!XMLValueChecker::IsGoodString(strValue) || !Internat::CompatibleToDouble(strValue, &dblValue)) return false; SetOffset(dblValue); } } return true; } return false; }
bool CommandManager::HandleXMLTag(const wxChar *tag, const wxChar **attrs) { if (!wxStrcmp(tag, wxT("audacitykeyboard"))) { mXMLKeysRead = 0; } if (!wxStrcmp(tag, wxT("command"))) { wxString name; wxString key; while(*attrs) { const wxChar *attr = *attrs++; const wxChar *value = *attrs++; if (!value) break; if (!wxStrcmp(attr, wxT("name")) && XMLValueChecker::IsGoodString(value)) name = value; if (!wxStrcmp(attr, wxT("key")) && XMLValueChecker::IsGoodString(value)) key = KeyStringNormalize(value); } if (mCommandNameHash[name]) { if (GetDefaultKeyFromName(name) != key) { mCommandNameHash[name]->key = KeyStringNormalize(key); mXMLKeysRead++; } } } return true; }
/// Visit an element. virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { if (element.Value()!=0x0 && !wxStrcmp(element.Value(), "tr")) { if (!wxStrcmp(element.Attribute("bgcolor"), "#FFFFFF")) { // first num const TiXmlElement *pChild = element.FirstChildElement(); if (pChild) { // child pChild = pChild->NextSiblingElement(); wxString host = wxString(pChild->GetText(), wxConvUTF8); // port pChild = pChild->NextSiblingElement(); wxString port = wxString(pChild->GetText(), wxConvUTF8); if (port.Len()>0 && wxAtoi(port)!=0) { m_pProxyData = new CProxyData(host, port); m_pArray->Add(m_pProxyData); } } } } return true; }
static GLenum Args(int argc, wxChar **argv) { GLint i; for (i = 1; i < argc; i++) { if (wxStrcmp(argv[i], _T("-sb")) == 0) { doubleBuffer = GL_FALSE; } else if (wxStrcmp(argv[i], _T("-db")) == 0) { doubleBuffer = GL_TRUE; } else if (wxStrcmp(argv[i], _T("-speed")) == 0) { speed_test = GL_TRUE; doubleBuffer = GL_TRUE; } else if (wxStrcmp(argv[i], _T("-va")) == 0) { use_vertex_arrays = GL_TRUE; } else { wxString msg = _T("Bad option: "); msg += argv[i]; wxMessageBox(msg); return GL_FALSE; } } return GL_TRUE; }
// Sorting function of the flat profile columns int wxCALLBACK SortFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData) { CBProfilerExecDlg *dialog = (CBProfilerExecDlg*) sortData; wxListCtrl *listCtrl = dialog->GetoutputFlatProfileArea(); int col = dialog->GetsortColumn(); long itemId1 = listCtrl->FindItem(-1, item1); long itemId2 = listCtrl->FindItem(-1, item2); wxListItem listItem1, listItem2; listItem1.SetId(itemId1); listItem1.SetColumn(col); listItem1.SetMask(wxLIST_MASK_TEXT); listCtrl->GetItem(listItem1); listItem2.SetId(itemId2); listItem2.SetColumn(col); listItem2.SetMask(wxLIST_MASK_TEXT); listCtrl->GetItem(listItem2); // All the columns are composed with numbers except the last one if (col == 6) { if (dialog->GetsortAscending()) return wxStrcmp(listItem1.GetText(), listItem2.GetText()); else return wxStrcmp(listItem2.GetText(), listItem1.GetText()); } else { double num1, num2; double success = listItem1.GetText().ToDouble(&num1); if (!success) { if (dialog->GetsortAscending()) return -1; else return 1; } success = listItem2.GetText().ToDouble(&num2); if (!success) { if (dialog->GetsortAscending()) return 1; else return -1; } if (dialog->GetsortAscending()) { if (num1 < num2) return -1; else if (num1 > num2) return 1; else return 0; } else { if (num1 > num2) return -1; else if (num1 < num2) return 1; else return 0; } } }
bool OyunApp::OnInit() { // Play like a nice Linux application for (int i = 1 ; i < argc ; i++) { if (!wxStrcmp(argv[i], wxT("--version"))) { const wchar_t *version = wxT(STRINGIZE( OYUN_VERSION )); const wxString verstring = _("Oyun %ls\n" "Copyright (C) 2004-2011 Charles Pence\n" "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n" "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n"); wxPrintf(verstring, version); return false; } else if (!wxStrcmp(argv[i], wxT("--help"))) { const wxString helpstring = _("Usage: oyun [OPTION]...\n" "Run an evolutionary game theory tournament.\n" "\n" " --test run the Oyun testing suite\n" " --help display this help and exit\n" " --version output version information and exit\n" "\n" "Report bugs to: <*****@*****.**>.\n" "Oyun home page: <http://charlespence.net/oyun/>.\n"); wxPrintf(wxT("%s"), helpstring); return false; } else { // Invalid command-line parameter wxPrintf(_("oyun: unrecognized option `%ls'\n" "Try `oyun --help' for more information.\n"), argv[i]); return false; } } // Seed the RNG Random::Seed(time(NULL)); #ifdef __WXMAC__ // Create the common OS X menu bar if we need it CreateMacMenuBar(); #endif // Make the first wizard CreateWizard(); return true; }
bool Tags::HandleXMLTag(const wxChar *tag, const wxChar **attrs) { if (wxStrcmp(tag, wxT("tags")) != 0) return false; // loop through attrs, which is a null-terminated list of // attribute-value pairs while(*attrs) { const wxChar *attr = *attrs++; const wxChar *value = *attrs++; if (!value) break; if (!wxStrcmp(attr, wxT("title"))) mTitle = value; else if (!wxStrcmp(attr, wxT("artist"))) mArtist = value; else if (!wxStrcmp(attr, wxT("album"))) mAlbum = value; else if (!wxStrcmp(attr, wxT("track"))) mTrackNum = wxAtoi(value); else if (!wxStrcmp(attr, wxT("year"))) mYear = value; else if (!wxStrcmp(attr, wxT("genre"))) mGenre = wxAtoi(value); else if (!wxStrcmp(attr, wxT("comments"))) mComments = value; else if (!wxStrcmp(attr, wxT("id3v2"))) mID3V2 = wxAtoi(value)?true:false; } // while return true; }
XMLTagHandler *FFmpegPresets::HandleXMLChild(const wxChar *tag) { if (!wxStrcmp(tag, wxT("preset"))) { return this; } else if (!wxStrcmp(tag, wxT("setctrlstate"))) { return this; } return NULL; }
XMLTagHandler *Tags::HandleXMLChild(const wxChar *tag) { if (wxStrcmp(tag, wxT("tags")) == 0) { return this; } if (wxStrcmp(tag, wxT("tag")) == 0) { return this; } return NULL; }
bool NoteTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs) { if (!wxStrcmp(tag, wxT("notetrack"))) { while (*attrs) { const wxChar *attr = *attrs++; const wxChar *value = *attrs++; if (!value) break; const wxString strValue = value; long nValue; double dblValue; if (!wxStrcmp(attr, wxT("name")) && XMLValueChecker::IsGoodString(strValue)) mName = strValue; else if (!wxStrcmp(attr, wxT("offset")) && XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue)) SetOffset(dblValue); else if (!wxStrcmp(attr, wxT("visiblechannels"))) { if (!XMLValueChecker::IsGoodInt(strValue) || !strValue.ToLong(&nValue) || !XMLValueChecker::IsValidVisibleChannels(nValue)) return false; mVisibleChannels = nValue; } else if (!wxStrcmp(attr, wxT("height")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) mHeight = nValue; else if (!wxStrcmp(attr, wxT("minimized")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) mMinimized = (nValue != 0); else if (!wxStrcmp(attr, wxT("isSelected")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) this->SetSelected(nValue != 0); #ifdef EXPERIMENTAL_MIDI_OUT else if (!wxStrcmp(attr, wxT("velocity")) && XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue)) mGain = (float) dblValue; #endif else if (!wxStrcmp(attr, wxT("bottomnote")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) SetBottomNote(nValue); else if (!wxStrcmp(attr, wxT("data"))) { std::string s(strValue.mb_str(wxConvUTF8)); std::istringstream data(s); mSeq = new Alg_seq(data, false); } } // while return true; } return false; }
XMLTagHandler *TimeTrack::HandleXMLChild(const wxChar *tag) { if (!wxStrcmp(tag, wxT("envelope"))) return mEnvelope; return NULL; }
void* wxHashTableBase::DoDelete( const wxChar* key, long hash ) { wxASSERT( m_keyType == wxKEY_STRING ); size_t bucket = size_t(hash) % m_size; if( m_table[bucket] == NULL ) return NULL; Node *first = m_table[bucket]->GetNext(), *curr = first, *prev = m_table[bucket]; do { if( wxStrcmp( curr->m_key.string, key ) == 0 ) { void* retval = curr->m_value; curr->m_value = NULL; DoUnlinkNode( bucket, curr, prev ); delete curr; return retval; } prev = curr; curr = curr->GetNext(); } while( curr != first ); return NULL; }
XMLTagHandler *Envelope::HandleXMLChild(const wxChar *tag) { if (wxStrcmp(tag, wxT("controlpoint"))) return NULL; return AddPointAtEnd(0,0); }
// use binary search because the array is sorted ConfigEntry * ConfigGroup::FindEntry(const wxChar *szName) const { size_t i, lo = 0, hi = m_aEntries.Count(); int res; ConfigEntry *pEntry; while ( lo < hi ) { i = (lo + hi)/2; pEntry = m_aEntries[i]; #if wxCONFIG_CASE_SENSITIVE res = wxStrcmp(pEntry->Name(), szName); #else res = wxStricmp(pEntry->Name(), szName); #endif if ( res > 0 ) hi = i; else if ( res < 0 ) lo = i + 1; else return pEntry; } return NULL; }
int wxChoice::GetSelection() const { XmString text; Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget); XtVaGetValues (label, XmNlabelString, &text, NULL); wxXmString freeMe(text); wxString s = wxXmStringToString( text ); if (!s.empty()) { int i = 0; for (wxStringList::compatibility_iterator node = m_stringList.GetFirst (); node; node = node->GetNext ()) { if (wxStrcmp(node->GetData(), s.c_str()) == 0) { return i; } else i++; } // for() return -1; } return -1; }
ConfigGroup * ConfigGroup::FindSubgroup(const wxChar *szName) const { size_t i, lo = 0, hi = m_aSubgroups.Count(); int res; ConfigGroup *pGroup; while ( lo < hi ) { i = (lo + hi)/2; pGroup = m_aSubgroups[i]; #if wxCONFIG_CASE_SENSITIVE res = wxStrcmp(pGroup->Name(), szName); #else res = wxStricmp(pGroup->Name(), szName); #endif if ( res > 0 ) hi = i; else if ( res < 0 ) lo = i + 1; else return pGroup; } return NULL; }
int wxSortedArrayString::Index(const wxChar* sz, bool bCase, bool WXUNUSED(bFromEnd)) const { wxSortedArrayString::const_iterator it; wxString s(sz); if (bCase) it = std::lower_bound(begin(), end(), s, wxStringCompare(wxStrcmpCppWrapper)); else it = std::lower_bound(begin(), end(), s, wxStringCompare(wxStricmpCppWrapper)); if (it == end()) return wxNOT_FOUND; if (bCase) { if (wxStrcmp(it->c_str(), sz) != 0) return wxNOT_FOUND; } else { if (wxStricmp(it->c_str(), sz) != 0) return wxNOT_FOUND; } return it - begin(); }
bool FortyApp::OnInit() { bool largecards = false; #ifndef __WXWINCE__ m_helpFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("about.htm"); if (!wxFileExists(m_helpFile)) #endif { m_helpFile = wxPathOnly(argv[0]) + wxFILE_SEP_PATH + wxT("about.htm"); } wxSize size(668,510); if ((argc > 1) && (!wxStrcmp(argv[1],wxT("-L")))) { largecards = true; size = wxSize(1000,750); } FortyFrame* frame = new FortyFrame( 0, wxT("Forty Thieves"), wxDefaultPosition, size, largecards ); // Show the frame frame->Show(true); frame->GetCanvas()->ShowPlayerDialog(); return true; }
void InteractiveInputTestCase::TestRegExInteractive() { #ifdef TEST_REGEX wxPuts(wxT("*** Testing RE interactively ***")); for ( ;; ) { wxChar pattern[128]; wxPrintf(wxT("Enter a pattern (press ENTER or type 'quit' to escape): ")); if ( !wxFgets(pattern, WXSIZEOF(pattern), stdin) ) break; // kill the last '\n' pattern[wxStrlen(pattern) - 1] = 0; if (pattern[0] == '\0' || wxStrcmp(pattern, "quit") == 0) break; wxRegEx re; if ( !re.Compile(pattern) ) { continue; } wxChar text[128]; for ( ;; ) { wxPrintf(wxT("Enter text to match: ")); if ( !wxFgets(text, WXSIZEOF(text), stdin) ) break; // kill the last '\n' text[wxStrlen(text) - 1] = 0; if ( !re.Matches(text) ) { wxPrintf(wxT("No match.\n")); } else { wxPrintf(wxT("Pattern matches at '%s'\n"), re.GetMatch(text).c_str()); size_t start, len; for ( size_t n = 1; ; n++ ) { if ( !re.GetMatch(&start, &len, n) ) { break; } wxPrintf(wxT("Subexpr %u matched '%s'\n"), n, wxString(text + start, len).c_str()); } } } wxPuts("\n"); } #endif // TEST_REGEX }
int CatheterGrid::getGridRowChannel(int row) { const wxString& channel = GetCellValue(wxGridCellCoords(row, CHANNEL_COL)); if (!wxStrcmp(channel, "global")) return GLOBAL_ADDR; else return wxAtoi(channel); }
XMLTagHandler *WaveClip::HandleXMLChild(const wxChar *tag) { if (!wxStrcmp(tag, wxT("sequence"))) return mSequence; else if (!wxStrcmp(tag, wxT("envelope"))) return mEnvelope; else if (!wxStrcmp(tag, wxT("waveclip"))) { // Nested wave clips are cut lines WaveClip *newCutLine = new WaveClip(mSequence->GetDirManager(), mSequence->GetSampleFormat(), mRate); mCutLines.Append(newCutLine); return newCutLine; } else return NULL; }
int main(int argc, char **argv) { wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); wxInitializer initializer; if ( !initializer ) { fprintf(stderr, "Failed to initialize the wxWidgets library, aborting."); return -1; } wxCmdLineParser parser(cmdLineDesc, argc, argv); switch ( parser.Parse() ) { case -1: // help was given, terminating break; case 0: // everything is ok; proceed if (parser.Found("d")) { wxPrintf("Dummy switch was given...\n"); while (1) { wxChar input[128]; wxPrintf("Try to guess the magic number (type 'quit' to escape): "); if ( !wxFgets(input, WXSIZEOF(input), stdin) ) break; // kill the last '\n' input[wxStrlen(input) - 1] = 0; if (wxStrcmp(input, "quit") == 0) break; long val; if (!wxString(input).ToLong(&val)) { wxPrintf("Invalid number...\n"); continue; } if (val == 42) wxPrintf("You guessed!\n"); else wxPrintf("Bad luck!\n"); } } break; default: break; } // do something useful here return 0; }
void OPJMarkerTree::OnItemExpanding(wxTreeEvent& event) { wxTreeItemId item = event.GetItem(); OPJMarkerData* data = (OPJMarkerData *) GetItemData(item); wxString text; if (item.IsOk()) text << wxT('"') << GetItemText(item).c_str() << wxT('"'); else text = wxT("invalid item"); if (wxStrcmp(data->GetDesc1(), wxT("INFO-CSTREAM"))) return; wxLogMessage(wxT("Expanding... (%s -> %s, %s, %d, %d)"), text.c_str(), data->GetDesc1(), data->GetDesc2(), data->m_start, data->m_length); // the codestream box is being asked for expansion wxTreeItemIdValue cookie; if (!GetFirstChild(item, cookie).IsOk()) { OPJParseThread *pthread = CreateParseThread(item); if (pthread->Run() != wxTHREAD_NO_ERROR) wxLogMessage(wxT("Can't start parse thread!")); else wxLogMessage(wxT("New parse thread started.")); } }
// Return true iff the attribute is recognized. bool PlayableTrack::HandleXMLAttribute(const wxChar *attr, const wxChar *value) { const wxString strValue{ value }; long nValue; if (!wxStrcmp(attr, wxT("mute")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) { mMute = (nValue != 0); return true; } else if (!wxStrcmp(attr, wxT("solo")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) { mSolo = (nValue != 0); return true; } return AudioTrack::HandleXMLAttribute(attr, value); }
extern "C" int LINKAGEMODE wxHtmlEntityCompare(const void *key, const void *item) { #if wxUSE_UNICODE_UTF8 return strcmp((char*)key, ((wxHtmlEntityInfo*)item)->name); #else return wxStrcmp((wxChar*)key, ((wxHtmlEntityInfo*)item)->name); #endif }
dir_t CatheterGrid::getGridRowDirection(int row) { const wxString& dirStr = GetCellValue(wxGridCellCoords(row, DIRECTION_COL)); if (!wxStrcmp(dirStr, DIRPOSSTR)) { return DIR_POS; } else { return DIR_NEG; } }
void VarArgTestCase::Sscanf() { int i = 0; char str[20]; wchar_t wstr[20]; wxString input("42 test"); wxSscanf(input, "%d %s", &i, &str); CPPUNIT_ASSERT( i == 42 ); CPPUNIT_ASSERT( wxStrcmp(str, "test") == 0 ); i = 0; wxSscanf(input, L"%d %s", &i, &wstr); CPPUNIT_ASSERT( i == 42 ); CPPUNIT_ASSERT( wxStrcmp(wstr, "test") == 0 ); }
// test that the conversion between str and wcs (subject to flags) succeeds // // the first argument is the index in the test array and is used solely for // diagnostics void Test(size_t n, wxMBConv& conv) const { if ( str ) { wxWCharBuffer wbuf = conv.cMB2WC(str); if ( wcs ) { CPPUNIT_ASSERT_MESSAGE ( Message(n, "MB2WC failed"), wbuf.data() ); CPPUNIT_ASSERT_MESSAGE ( Message(n, "MB2WC", wbuf, wcs), wxStrcmp(wbuf, wcs) == 0 ); } else // conversion is supposed to fail { CPPUNIT_ASSERT_MESSAGE ( Message(n, "MB2WC succeeded"), !wbuf.data() ); } } if ( wcs && !(flags & ONLY_MB2WC) ) { wxCharBuffer buf = conv.cWC2MB(wcs); if ( str ) { CPPUNIT_ASSERT_MESSAGE ( Message(n, "WC2MB failed"), buf.data() ); CPPUNIT_ASSERT_MESSAGE ( Message(n, "WC2MB", buf, str), strcmp(buf, str) == 0 ); } else { CPPUNIT_ASSERT_MESSAGE ( Message(n, "WC2MB succeeded"), !buf.data() ); } } }
void CommandManager::HandleXMLEndTag(const wxChar *tag) { if (!wxStrcmp(tag, wxT("audacitykeyboard"))) { wxMessageBox(wxString::Format(_("Loaded %d keyboard shortcuts\n"), mXMLKeysRead), _("Loading keyboard shortcuts"), wxOK | wxCENTRE); } }