/*------------------------------------------------------------------ ---------------------------------- open dialog to browse sound files ------------------------------------------------------------------*/ BOOL BrowseSoundFile(HWND hDlg, const wchar_t* deffile, wchar_t fname[MAX_PATH]) { wchar_t filter[1024], mmfileexts[1024]; DWORD index; filter[0]=filter[1]='\0'; str0cat(filter, MyString(IDS_MMFILE)); GetMMFileExts(mmfileexts); str0cat(filter, mmfileexts); str0cat(filter, MyString(IDS_ALLFILE)); str0cat(filter, L"*.*"); if(!deffile[0] || IsMMFile(deffile)) index = 1; else index = 2; if(SelectMyFile(hDlg, filter, index, deffile, fname)) { if(!wcsncmp(fname,api.root,api.root_len)) { // make relative to waves/ if possible if(!wcsncmp(fname+api.root_len, L"\\waves\\", 7)) { memmove(fname, fname+api.root_len+7, ((wcslen(fname)-api.root_len-7+1) * sizeof fname[0])); } } return 1; } return 0; }
//----------------------------------------------------------------------------- void CheckEvents::CheckPostTerm(const MyString &idStr, const CondorID &id, const JobInfo *info, MyString &errorMsg, check_event_result_t &result) { // Allow for the case where we ran a post script after all submit // attempts fail. if ( noSubmitId == id && info->submitCount == 0 && info->termCount == 0 && info->postScriptCount >= 1 ) { return; } if ( info->submitCount < 1 ) { errorMsg = idStr + " post script ended, submit count < 1 (" + MyString(info->submitCount) + ")"; result = (AllowDuplicates() || (AllowGarbage() && (info->submitCount <= 1))) ? EVENT_BAD_EVENT : EVENT_ERROR; } if ( info->TotalEndCount() < 1 ) { errorMsg = idStr + " post script ended, total end " "count < 1 (" + MyString(info->TotalEndCount()) + ")"; result = AllowAlmostAll() ? EVENT_BAD_EVENT : EVENT_ERROR; } if ( info->postScriptCount > 1 ) { errorMsg = idStr + " post script ended, post script " "count > 1 (" + MyString(info->postScriptCount) + ")"; result = (AllowDuplicates() || AllowGarbage()) ? EVENT_BAD_EVENT : EVENT_ERROR; } }
int main() { std::cout<< "hello, this is mystring plugin" << std::endl; MyString str0("AAA"); std::cout << "str0="<< str0 << std::endl; MyString str1(NULL); std::cout << "str1="<< str1 << std::endl; //MyString str2; // compile error, cause lacking of default constructor //std::cout << "str2="<< str2 << std::endl; str0 += "BBB"; std::cout << "str0="<< str0 << std::endl; MyString str3("CCC"); str0 += str3; std::cout << "str0="<< str0 << std::endl; MyString str4("DDD"); MyString str5("DDD"); std::cout << "str4==str5:"<< ((str4==str5)? "true":"false") << std::endl; std::vector<MyString> vec; vec.push_back(MyString("aaa")); vec.push_back(MyString("bbb")); std::cout << "vec:"<< vec[0] << ", " << vec[1] << std::endl; return 0; }
//--------------------------------------------------------------------------- MyString MYRTLEXP GetFName( const MyString& nm, char Slash ) { char *m = StrRChr( nm.Text(), Slash ); if (!m) return MyString(nm); else return MyString(m+1); }
/*------------------------------------------------------------------ ---------------------------------- open dialog to browse sound files ------------------------------------------------------------------*/ BOOL BrowseSoundFile(HWND hDlg, const char* deffile, char* fname) { char filter[1024], mmfileexts[1024]; char ftitle[MAX_PATH], initdir[MAX_PATH]; OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); // Initialize OPENFILENAME ofn.lStructSize = sizeof(ofn); filter[0]=filter[1]='\0'; str0cat(filter, MyString(IDS_MMFILE)); GetMMFileExts(mmfileexts); str0cat(filter, mmfileexts); str0cat(filter, MyString(IDS_ALLFILE)); str0cat(filter, "*.*"); if(!deffile[0] || IsMMFile(deffile)) ofn.nFilterIndex = 1; else ofn.nFilterIndex = 2; memcpy(initdir, api.root, api.root_len+1); if(deffile[0]) { WIN32_FIND_DATA fd; HANDLE hfind; hfind = FindFirstFile(deffile, &fd); if(hfind != INVALID_HANDLE_VALUE) { FindClose(hfind); strncpy_s(initdir,sizeof(initdir),deffile,_TRUNCATE); del_title(initdir); } } *fname = '\0'; ofn.hwndOwner = hDlg; ofn.hInstance = NULL; ofn.lpstrFilter = filter; ofn.lpstrFile = fname; ofn.nMaxFile = MAX_PATH; ofn.lpstrFileTitle = ftitle; ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrInitialDir = initdir; ofn.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_FILEMUSTEXIST; if(GetOpenFileName(&ofn)) { size_t tlen=api.root_len; if(!strncmp(fname,api.root,tlen)) { // make relative to waves/ if possible if(!strncmp(fname+tlen,"\\waves\\",7)) { memmove(fname,fname+tlen+7,strlen(fname)-tlen-6); } } return 1; } return 0; }
//--------------------------------------------------------------------------- MyString MYRTLEXP GetFExtOnly( const MyString& nm, char Slash ) { char *m = StrRChr( nm.Text(),Slash ); if ( !m ) m = nm.Text(); m = StrRChr( m,'.' ); if (m) return MyString(m+1); else return MyString(""); }
/*------------------------------------------------ WM_DRAWITEM message --------------------------------------------------*/ void OnDrawItem(HWND hDlg, LPDRAWITEMSTRUCT pdis) { char texts[4][80]; strcpy(texts[0], MyString(IDS_BTNFACE, "ButtonFace")); strcpy(texts[1], MyString(IDS_BTNSHADOW, "ButtonShadow")); strcpy(texts[2], MyString(IDS_BTNLIGHT, "ButtonLight")); strcpy(texts[3], MyString(IDS_BTNTEXT, "ButtonText")); // common/combobox.c OnDrawItemColorCombo(pdis, texts); }
//----------------------------------------------------------------------------- void CheckEvents::CheckJobFinal(const MyString &idStr, const CondorID &id, const JobInfo *info, MyString &errorMsg, check_event_result_t &result) { // Allow for the case where we ran a post script after all submit // attempts fail. if ( noSubmitId == id && info->submitCount == 0 && info->termCount == 0 && info->postScriptCount >= 1 ) { return; } if ( id._subproc != 0 ) { // This is a parallel universe node. return; } if ( info->submitCount != 1 ) { errorMsg = idStr + " ended, submit count != 1 (" + MyString(info->submitCount) + ")"; result = (AllowAlmostAll() || (AllowGarbage() && (info->submitCount <= 1))) ? EVENT_BAD_EVENT : EVENT_ERROR; } if ( info->TotalEndCount() != 1 ) { errorMsg = idStr + " ended, total end " "count != 1 (" + MyString(info->TotalEndCount()) + ")"; if ( AllowExtraAborts() && (info->abortCount == 1) && (info->termCount == 1) ) { result = EVENT_BAD_EVENT; } else if ( AllowDoubleTerm() && (info->termCount == 2) ) { result = EVENT_BAD_EVENT; } else if ( AllowExtraRuns() ) { result = EVENT_BAD_EVENT; } else if ( AllowGarbage() && info->TotalEndCount() == 0 ) { result = EVENT_BAD_EVENT; } else if ( AllowDuplicates() ) { // Note: should we check here that we don't have some // weird combo that *should* be illegal? result = EVENT_BAD_EVENT; } else { result = EVENT_ERROR; } } if ( info->postScriptCount > 1 ) { errorMsg = idStr + " ended, post script " "count > 1 (" + MyString(info->postScriptCount) + ")"; result = (AllowDuplicates() || AllowGarbage()) ? EVENT_BAD_EVENT : EVENT_ERROR; } }
/* 高效率的字符串分割实现 */ std::vector<MyString>& my_split(const char *str, const char *delim) { auto *ret = new std::vector<MyString>; const char *posBegin = str, *posEnd = nullptr; while ((posEnd = my_strstr(posBegin, delim)) != nullptr) { ret->push_back(MyString(posBegin, (int)(posEnd - posBegin))); posBegin = posEnd + 1; } ret->push_back(MyString(posBegin)); return *ret; }
/*------------------------------------------- set items to left tree view ---------------------------------------------*/ void InitTreeView(HWND hDlg) { HWND hTree; TV_INSERTSTRUCT tv; HTREEITEM hTreeItem[MAX_TREEITEM]; int i; hTree = GetDlgItem(hDlg, IDC_TREE); memset(&tv, 0, sizeof(TV_INSERTSTRUCT)); tv.hInsertAfter = TVI_LAST; tv.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; tv.item.state = TVIS_EXPANDED; tv.item.stateMask = TVIS_EXPANDED; for(i = 0; i < MAX_TREEITEM; i++) { int nParent = g_treeItem[i].nParent; tv.item.lParam = i; if(nParent < 0) tv.hParent = TVI_ROOT; else tv.hParent = hTreeItem[nParent]; tv.item.pszText = MyString(g_treeItem[i].idStr, g_treeItem[i].entry); hTreeItem[i] = TreeView_InsertItem(hTree, &tv); } m_lastTreeItem = GetMyRegLong("", "LastTreeItem", 0); if(m_lastTreeItem >= MAX_TREEITEM) m_lastTreeItem = 0; TreeView_SelectItem(hTree, hTreeItem[m_lastTreeItem]); }
/*------------------------------------------------ clicked "..." button --------------------------------------------------*/ void OnBrowseFile(HWND hDlg, WORD id) { char filter[80], deffile[MAX_PATH], fname[MAX_PATH]; filter[0] = filter[1] = 0; if(id == IDC_BROWSEHELP) { str0cat(filter, "HTML"); str0cat(filter, "*.html;*.htm"); } else if(id == IDC_BROWSEHELP2CH) { str0cat(filter, "HTML"); str0cat(filter, "*.html;*.htm"); } else if(id == IDC_BROWSELANGDLL) { str0cat(filter, MyString(IDS_LANGDLLFILE)); str0cat(filter, "lang*.dll"); } GetDlgItemText(hDlg, id - 1, deffile, MAX_PATH); if(!SelectMyFile(hDlg, filter, 0, deffile, fname)) // propsheet.c return; SetDlgItemText(hDlg, id - 1, fname); PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); SendPSChanged(hDlg); }
std::vector<MyString> get_hostname_with_alias(const condor_sockaddr& addr) { std::vector<MyString> ret; MyString hostname = get_hostname(addr); if (hostname.IsEmpty()) return ret; ret.push_back(hostname); if (nodns_enabled()) return ret; // no need to call further DNS functions. hostent* ent; //int aftype = addr.get_aftype(); //ent = gethostbyname2(hostname.Value(), addr.get_aftype()); // really should call gethostbyname2() however most platforms do not // support. (Solaris, HP-UX, IRIX) // complete DNS aliases can be only obtained by gethostbyname. // however, what happens if we call it in IPv6-only system? // can we get DNS aliases for the hostname that only contains // IPv6 addresses? ent = gethostbyname(hostname.Value()); if (!ent) return ret; char** alias = ent->h_aliases; for (; *alias; ++alias) { ret.push_back(MyString(*alias)); } return ret; }
/*--------------------------------------------------------- -- show a message when TClock failed to customize the clock ---------------------------------------------------------*/ void InitError(int n) { char s[160]; wsprintf(s, "%s: %d", MyString(IDS_NOTFOUNDCLOCK), n); api.Message(NULL, s, "Error", MB_OK, MB_ICONEXCLAMATION); }
//----------------------------------------------------------------------------- void CheckEvents::CheckJobSubmit(const MyString &idStr, const JobInfo *info, MyString &errorMsg, check_event_result_t &result) { if ( info->submitCount != 1 ) { errorMsg = idStr + " submitted, submit count != 1 (" + MyString(info->submitCount) + ")"; result = AllowDuplicates() ? EVENT_BAD_EVENT : EVENT_ERROR; } if ( info->TotalEndCount() != 0 ) { errorMsg = idStr + " submitted, total end count != 0 (" + MyString(info->TotalEndCount()) + ")"; result = AllowExecSubmit() ? EVENT_BAD_EVENT : EVENT_ERROR; } }
//----------------------------------------------------------------------------- void CheckEvents::CheckJobExecute(const MyString &idStr, const JobInfo *info, MyString &errorMsg, check_event_result_t &result) { if ( info->submitCount < 1 ) { errorMsg = idStr + " executing, submit count < 1 (" + MyString(info->submitCount) + ")"; result = (AllowExecSubmit() || AllowGarbage()) ? EVENT_WARNING : EVENT_ERROR; } if ( info->TotalEndCount() != 0 ) { errorMsg = idStr + " executing, total end count != 0 (" + MyString(info->TotalEndCount()) + ")"; result = AllowExtraRuns() ? EVENT_BAD_EVENT : EVENT_ERROR; } }
/*------------------------------------------------ initialize --------------------------------------------------*/ static void OnInit(HWND hDlg) { LOGFONT logfont; char s[MAX_PATH]; HFONT hfont; hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if(hfont) { SendDlgItemMessage(hDlg, IDC_HELPURL, WM_SETFONT, (WPARAM)hfont, 0); SendDlgItemMessage(hDlg, IDC_LANGDLL, WM_SETFONT, (WPARAM)hfont, 0); } SendDlgItemMessage(hDlg, IDC_ABOUTICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)g_hIconTClock); hfontLink = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0); GetObject(hfontLink, sizeof(LOGFONT), &logfont); logfont.lfUnderline = 1; hfontLink = CreateFontIndirect(&logfont); SendDlgItemMessage(hDlg, IDC_MAILTO, WM_SETFONT, (WPARAM)hfontLink, 0); SendDlgItemMessage(hDlg, IDC_HOMEPAGE, WM_SETFONT, (WPARAM)hfontLink, 0); if(hCurHand == NULL) hCurHand = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_HAND)); oldLabProc = (WNDPROC)GetWindowLongPtr(GetDlgItem(hDlg, IDC_MAILTO), GWLP_WNDPROC); SubclassWindow(GetDlgItem(hDlg, IDC_MAILTO), LabLinkProc); SubclassWindow(GetDlgItem(hDlg, IDC_HOMEPAGE), LabLinkProc); //hbrback = CreateSolidBrush(GetSysColor(COLOR_3DFACE)); GetMyRegStr("", "HelpURL", s, MAX_PATH, MyString(IDS_HELPURL)); if (!s[0]) lstrcpyn(s, MyString(IDS_HELPURL), MAX_PATH); SetDlgItemText(hDlg, IDC_HELPURL, s); GetMyRegStr("", "2chHelpURL", s, MAX_PATH, MyString(IDS_HELP2CH)); if (!s[0]) lstrcpyn(s, MyString(IDS_HELP2CH), MAX_PATH); SetDlgItemText(hDlg, IDC_HELP2CH, s); GetMyRegStr("", "LangDLL", s, MAX_PATH, ""); SetDlgItemText(hDlg, IDC_LANGDLL, s); }
// Insert // Takes two arguments // An int – the index in this MyString // at which to insert the new chars // A MyString containing the chars to be inserted void MyString::Insert(const MyString & aMyString, int index) { if(index > _length) throw std::runtime_error("RAGEQUIT index is greater than Length()"); if(index < 0) throw std::runtime_error("RAGEQUIT index is less than zero"); MyString bMyString = aMyString; MyString returnString = MyString(); MyString subString = MyString(SubStr(index, _length - index)); returnString.Assign(SubStr(0, index)); returnString.Append(bMyString); returnString.Append(subString); Assign(returnString); }
std::vector<MyString> get_hostname_with_alias(const condor_sockaddr& addr) { std::vector<MyString> prelim_ret; std::vector<MyString> actual_ret; MyString hostname = get_hostname(addr); if (hostname.IsEmpty()) return prelim_ret; // we now start to construct a list (prelim_ret) of the hostname and all // the aliases. first the name itself. prelim_ret.push_back(hostname); if (nodns_enabled()) // don't need to verify this... the string is actually an IP here return prelim_ret; // no need to call further DNS functions. // now, add the aliases hostent* ent; //int aftype = addr.get_aftype(); //ent = gethostbyname2(hostname.Value(), addr.get_aftype()); // really should call gethostbyname2() however most platforms do not // support. (Solaris, HP-UX, IRIX) // complete DNS aliases can be only obtained by gethostbyname. // however, what happens if we call it in IPv6-only system? // can we get DNS aliases for the hostname that only contains // IPv6 addresses? ent = gethostbyname(hostname.Value()); if (ent) { char** alias = ent->h_aliases; for (; *alias; ++alias) { prelim_ret.push_back(MyString(*alias)); } } // WARNING! there is a reason this is implimented as two separate loops, // so please don't try to combine them. // // calling verify_name_has_ip() will potentially overwrite static data that // is referred to by ent->h_aliases (man 3 gethostbyname, see notes). so // first, we push the name and then all aliases into the MyString vector // prelim_ret, and then verify them in the following loop. for (unsigned int i = 0; i < prelim_ret.size(); i++) { if(verify_name_has_ip(prelim_ret[i], addr)) { actual_ret.push_back(prelim_ret[i]); } else { dprintf(D_ALWAYS, "WARNING: forward resolution of %s doesn't match %s!\n", prelim_ret[i].Value(), addr.to_ip_string().Value()); } } return actual_ret; }
/*------------------------------------------------ initialize --------------------------------------------------*/ void OnInit(HWND hDlg) { int i, count, index; HFONT hfont; hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if(hfont) { SendDlgItemMessage(hDlg, IDC_COMBOAUTOEXEC, WM_SETFONT, (WPARAM)hfont, 0); SendDlgItemMessage(hDlg, IDC_FILEAUTOEXEC, WM_SETFONT, (WPARAM)hfont, 0); } index = CBAddString(hDlg, IDC_COMBOAUTOEXEC, (LPARAM)MyString(IDS_ADDALARM)); CBSetItemData(hDlg, IDC_COMBOAUTOEXEC, index, 0); count = GetMyRegLong("", "AutoExecNum", 0); if(count < 1) count = 0; for(i = 0; i < count; i++) { PAUTOEXECSTRUCT pAS; pAS = malloc(sizeof(AUTOEXECSTRUCT)); ReadAutoExecFromReg(pAS, i); index = CBAddString(hDlg, IDC_COMBOAUTOEXEC, (LPARAM)pAS->name); CBSetItemData(hDlg, IDC_COMBOAUTOEXEC, index, (LPARAM)pAS); if(i == 0) SetAutoExecToDlg(hDlg, pAS); } //リスト項目の表示数を指定 AdjustDlgConboBoxDropDown(hDlg, IDC_COMBOAUTOEXEC, 7); if(count > 0) { CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, 1); curAutoExec = 1; } else { AUTOEXECSTRUCT as; CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, 0); curAutoExec = -1; memset(&as, 0, sizeof(as)); as.hour = 12; as.days = 0x7f; SetAutoExecToDlg(hDlg, &as); } SendDlgItemMessage(hDlg, IDC_TESTAUTOEXEC, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_hIconPlay); OnFileChange(hDlg, IDC_FILEAUTOEXEC); SendDlgItemMessage(hDlg, IDC_DELAUTOEXEC, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_hIconDel); OnAutoExec(hDlg, IDC_AUTOEXEC); bPlaying = FALSE; }
// Assign // Takes a MyString argument // makes this MyString a copy of aMyString void MyString::Assign(const MyString &aMyString) { MyString bMyString = MyString(aMyString); // prevent self-dereferencing delete[] _string; _capacity = bMyString._capacity ; // Copy capacity from aMyString _length = bMyString._length ; // Copy length from aMyString _string = new char[_capacity + 1] ; strcpy(_string, bMyString._string) ; // Copy string contents from // aMyString _string[_length] = '\0' ; // Sets last char in array to terminator }
//--------------------------------------------------------------------------- MyString MYRTLEXP GetFPath( const MyString& nm, char Slash ) { char str[ MAX_PATH_SIZE ]; char *m; StrCpy( str,nm.Text(),sizeof(str) ); m = StrRChr( str,Slash ); if (m) *m = 0; else str[0] = 0; return MyString( AddLastSlash(str) ); }
void Burger::Display::SetWindowTitle(const char *pTitle) { HWND pWindow = static_cast<WindowsApp *>(m_pGameApp)->GetWindow(); // Is the window present? if (pWindow) { String16 MyString(pTitle); // Set the new title text SetWindowTextW(pWindow,reinterpret_cast<LPCWSTR>(MyString.c_str())); } }
void Game::proclamateWinnerAndPrompt() { TeamEnum winner = m_arbiter -> getWinningTeam(); MyString message( winner == TeamEnum::LEFT ? "Left" : "Right"); IOManager::instance().manageOutput(message + " team won!"); IOManager::instance().manageOutput(MyString("What do you want to do?")); IOManager::instance().manageInput(m_endGameChoices, &m_choiceSelected); m_stateFn = &Game::cleanGameDataAndDecideIfExit; }
void InitFunction(HWND hDlg, int id) { int index; int i; for(i = 0; i < MAX_MOUSEFUNC; i++) { index = CBAddString(hDlg, id, (LPARAM)MyString(m_mousefunc[i].idStr, m_mousefunc[i].entry)); CBSetItemData(hDlg, id, index, m_mousefunc[i].nCommand); } }
MyString MYRTLEXP GetFNameOnly( const MyString& nm, char Slash ) { char str[ MAX_PATH_SIZE ]; char *m = StrRChr( nm.Text(),Slash ); if (!m) m = nm.Text(); else m++; StrCpy( str,m,sizeof(str) ); m = StrRChr(str,'.'); if (m) *m = 0; return MyString(str); }
bool SetNodeDagFile( Dag *dag, const char *nodeName, const char *dagFile, MyString &whynot ) { Job *job = dag->FindNodeByName( nodeName ); if ( job ) { job->SetDagFile( dagFile ); return true; } else { whynot = MyString( "Node " ) + nodeName + " not found!"; return false; } }
int main() { MyString str("Hello World."); printf("str = %s\n", str.c_str()); printf("len = %d\n", str.get_length()); printf("count l = %d\n", str.count("l")); printf("count ll = %d\n", str.count("ll")); printf("start_with He %d\n", str.start_with("He")); printf("start_with e %d\n", str.start_with("e")); printf("end_with d %d\n", str.end_with("d")); printf("end_with d. %d\n", str.end_with("d.")); printf("find ll %d\n", str.find("ll")); printf("rfind l %d\n", str.rfind("l")); printf("find Wd %d\n", str.find("Wd")); printf("rfind ls %d\n", str.rfind("ls")); printf("123 isnumber %d\n", MyString("123").is_number()); printf("123s isnumber %d\n", MyString("123s").is_number()); printf("123 isalpha %d\n", MyString("123").is_alpha()); printf("sss isalpha %d\n", MyString("sss").is_alpha()); printf("sss isspace %d\n", MyString("sss").is_space()); printf(" isspace %d\n", MyString("\r\n\t ").is_space()); str="1a2a3aa4a5a6"; MyStringList strlist = str.split("a"); for(int i = 0; i < strlist.size(); i ++) { printf("%s\n", strlist[i].c_str()); } str = MyString("AA").join(strlist); printf("%s\n", str.c_str ()); strlist = str.split2("AA"); for(i = 0; i < strlist.size(); i ++) { printf("%s\n", strlist[i].c_str()); } str = str + "ZZZZZZZZZZ"; printf("%s\n", str.c_str ()); printf("%s\n", str(0, 11111111).c_str ()); printf("%s\n", str(0, -11111111).c_str ()); printf("%s\n", str(5, 13).c_str ()); printf("%s\n", str(2, 5).c_str ()); printf("%d\n", str(2, 3).get_code ()); printf("%s\n", str[2].c_str ()); MyString aaaa=" 6"; aaaa = aaaa*3; printf("%s\n", aaaa.c_str ()); printf("%s\n", aaaa.lstrip().c_str ()); error("%d %s\n", 4, "666"); }
// Append // Takes a MyString argument // Appends chars to the end of this MyString void MyString::Append(const MyString &aMyString) { MyString bMyString = MyString(aMyString);// prevent self-dereferencing int totalLength = _length + bMyString._length; if (_capacity < totalLength) { _capacity = totalLength; char *oldString = new char[_capacity + 1]; strcpy(oldString, _string); delete[] _string; _string = oldString; } strcat(_string, bMyString._string); _length = totalLength; _string[_length] = '\0'; }
//----------------------------------------------------------------------------- void CheckEvents::CheckJobEnd(const MyString &idStr, const JobInfo *info, MyString &errorMsg, check_event_result_t &result) { if ( info->submitCount < 1 ) { errorMsg = idStr + " ended, submit count < 1 (" + MyString(info->submitCount) + ")"; result = (AllowExecSubmit() || (AllowGarbage() && (info->submitCount <= 1))) ? EVENT_WARNING : EVENT_ERROR; } if ( info->TotalEndCount() != 1 ) { errorMsg = idStr + " ended, total end " "count != 1 (" + MyString(info->TotalEndCount()) + ")"; if ( AllowExtraAborts() && (info->abortCount == 1) && (info->termCount == 1) ) { result = EVENT_BAD_EVENT; } else if ( AllowDoubleTerm() && (info->termCount == 2) ) { result = EVENT_BAD_EVENT; } else if ( AllowExtraRuns() ) { result = EVENT_BAD_EVENT; } else if ( AllowDuplicates() ) { // Note: should we check here that we don't have some // weird combo that *should* be illegal? result = EVENT_BAD_EVENT; } else { result = EVENT_ERROR; } } if ( info->postScriptCount != 0 ) { errorMsg = idStr + " ended, post script " "count != 0 (" + MyString(info->postScriptCount) + ")"; result = AllowDuplicates() ? EVENT_BAD_EVENT : EVENT_ERROR; } }
/*------------------------------------------------ 「スタートアップ」にショートカットをつくる --------------------------------------------------*/ void OnStartup(HWND hDlg) { LPITEMIDLIST pidl; char dstpath[MAX_PATH], myexe[MAX_PATH]; if(SHGetSpecialFolderLocation(hDlg, CSIDL_STARTUP, &pidl) == NOERROR && SHGetPathFromIDList(pidl, dstpath) == TRUE) ; else return; if(MyMessageBox(hDlg, MyString(IDS_STARTUPLINK), "TClock", MB_YESNO, MB_ICONQUESTION) != IDYES) return; GetModuleFileName(GetModuleHandle(NULL), myexe, MAX_PATH); CreateLink(myexe, dstpath, "TClock"); }