本文整理汇总了C++中TString::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::Format方法的具体用法?C++ TString::Format怎么用?C++ TString::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::Format方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTextEP
void VAISNAVADAY::GetTextEP(TString &str)
{
double h1, m1, h2, m2;
m1 = modf(eparana_time1, &h1);
if (eparana_time2 >= 0.0)
{
m2 = modf(eparana_time2, &h2);
if (GCDisplaySettings::getValue(50))
str.Format(" %s %02d:%02d (%s) - %02d:%02d (%s) %s", GCStrings::getString(60).c_str(),
int(h1), int(m1*60), GCStrings::GetParanaReasonText(eparana_type1),
int(h2), int(m2*60), GCStrings::GetParanaReasonText(eparana_type2),
GCStrings::GetDSTSignature(nDST));
else
str.Format(" %s %02d:%02d - %02d:%02d (%s)", GCStrings::getString(60).c_str(),
int(h1), int(m1*60), int(h2), int(m2*60), GCStrings::GetDSTSignature(nDST));
}
else if (eparana_time1 >= 0.0)
{
if (GCDisplaySettings::getValue(50))
str.Format(" %s %02d:%02d (%s) %s", GCStrings::getString(61).c_str(),
int(h1), int(m1*60), GCStrings::GetParanaReasonText(eparana_type1), GCStrings::GetDSTSignature(nDST) );
else
str.Format(" %s %02d:%02d (%s)", GCStrings::getString(61).c_str(),
int(h1), int(m1*60), GCStrings::GetDSTSignature(nDST) );
}
else
{
str = " ";
str += GCStrings::getString(62);
}
}
示例2: InterlockedIncrement
void TaskHandler( void ){
LONG currentTask = InterlockedIncrement( &m_nCurrentTask );
TString str;
str.Format(_T("[%u] Task #%u is starting."), GetCurrentThreadId(), currentTask);
AddMessage( (LPCTSTR)str );
Sleep( currentTask * 1000 );
str.Format(_T("[%u] Task #%u is done."), GetCurrentThreadId(), currentTask);
AddMessage( (LPCTSTR)str );
if( InterlockedDecrement(&m_nCurrentTask) == 0 ){
PostMessage( WM_APP_COMPLETED, 0, (LPARAM)currentTask );
}
}
示例3:
BOOL TFile::WriteString2(int i, const char * psz)
{
TString str;
str.Format("%d\r\n%s\r\n", i, psz);
WriteString(str);
return TRUE;
}
示例4:
LRESULT OnCompleted( WPARAM wParam, LPARAM lParam ){
TString str;
str.Format(_T("___Task #%u was the last task of the batch____"), lParam);
AddMessage( (LPCTSTR)str );
m_btnStart.Enable( TRUE );
return 0;
}
示例5: OnInitDialog
BOOL DlgEditCustomEvent::OnInitDialog()
{
CDialog::OnInitDialog();
TString str;
// TODO: Add extra initialization here
CComboBox * p;
int i;
p = (CComboBox *)GetDlgItem(IDC_COMBO1);
for(i =0; i < 30; i++)
{
str.Format("%s Tithi (%s Paksa)", GCStrings::GetTithiName(i), GCStrings::GetPaksaName(i/15));
p->AddString(str);
}
p->SetCurSel(this->m_nTithi);
if (m_nClass != 6)
p->EnableWindow(FALSE);
p = (CComboBox *)GetDlgItem(IDC_COMBO2);
for(i = 0; i < 12; i++)
{
p->AddString(GCStrings::GetMasaName(i));
}
p->SetCurSel(this->m_nMasa);
if (m_nClass != 6)
p->EnableWindow(FALSE);
p = (CComboBox *)GetDlgItem(IDC_COMBO3);
for(i = 0; i <= 6; i++)
{
p->AddString(GCStrings::GetEventClassText(i));
}
p->SetCurSel(this->m_nClass);
if (m_nClass != 6)
p->EnableWindow(FALSE);
else
p->EnableWindow(GCDisplaySettings::getValue(44)==1);
p = (CComboBox *)GetDlgItem(IDC_COMBO4);
p->AddString("no fast");
p->AddString(GCStrings::GetFastingName(0x201));
p->AddString(GCStrings::GetFastingName(0x202));
p->AddString(GCStrings::GetFastingName(0x203));
p->AddString(GCStrings::GetFastingName(0x204));
p->AddString(GCStrings::GetFastingName(0x205));
p->SetCurSel(this->m_nFastType);
if (m_nClass != 6)
p->EnableWindow(FALSE);
if (m_nClass != 6)
GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例6: GetTextA
/* BEGIN GCAL 1.4.3 */
void VAISNAVADAY::GetTextA(TString &str, int bPaksa, int bNaks, int bYoga, int bFlag, int bRasi)
{
// static char * dow[] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
TString s1, s2;
s1 = GCStrings::GetTithiName(astrodata.nTithi);
if ((astrodata.nTithi == 10) || (astrodata.nTithi == 25) || (astrodata.nTithi == 11) || (astrodata.nTithi == 26))
{
if (ekadasi_parana == false)
{
if (nMhdType == EV_NULL)
{
s1 += " ";
s1 += GCStrings::getString(58);
}
else
{
s1 += " ";
s1 += GCStrings::getString(59);
}
}
}
GCStrings::getString(this->date.dayOfWeek).Left(2, s2);
str.Format("%2d %s %d %s %-34s%c ", this->date.day, GCStrings::GetMonthAbreviation(date.month), this->date.year
, s2.c_str() ,s1.c_str(), (bPaksa ? GCStrings::GetPaksaChar(this->astrodata.nPaksa) : ' '));
if (bYoga)
{
s2.Format("%-10s", GCStrings::GetYogaName(this->astrodata.nYoga));
str += s2;
}
if (bNaks)
{
s2.Format("%-15s", GCStrings::GetNaksatraName(this->astrodata.nNaksatra));
str += s2;
}
if (this->nFastType != FAST_NULL && bFlag)
str += " *";
else
str += " ";
if (bRasi)
{
if (bRasi == 1)
s2.Format(" %-15s", GCStrings::GetSankrantiName(GCRasi::GetRasi(this->astrodata.moon.longitude_deg, this->astrodata.msAyanamsa)));
else
s2.Format(" %-15s", GCStrings::GetSankrantiNameEn(GCRasi::GetRasi(this->astrodata.moon.longitude_deg, this->astrodata.msAyanamsa)));
str += s2;
}
}
示例7: OnInitDialog
BOOL DlgEventsGaubdTM::OnInitDialog()
{
CDialog::OnInitDialog();
int i = 0, n;
TString str;
str.Format("%s Paksa", GCStrings::GetPaksaName(0));
i = m_list1.AddString(str);
m_list1.SetItemData(i, -1);
for(n = 0; n < 15; n++)
{
str.Format(" %s Tithi", GCStrings::GetTithiName(n));
i = m_list1.AddString(str);
m_list1.SetItemData(i, n);
}
str.Format("%s Paksa", GCStrings::GetPaksaName(1));
i = m_list1.AddString(str);
m_list1.SetItemData(i, -1);
for(n = 15; n < 30; n++)
{
str.Format(" %s Tithi", GCStrings::GetTithiName(n));
i = m_list1.AddString(str);
m_list1.SetItemData(i, n);
}
for(n = 0; n < 12; n++)
{
str.Format(" %s Masa", GCStrings::GetMasaName((n + 11)%12));
i = m_list2.AddString(str);
m_list2.SetItemData(i, (n + 11)%12);
}
m_list1.SetCurSel(1);
m_list2.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例8: int
void DumpFile( LPTSTR lpFilename ){
BUFFER buf;
if( LoadFileData(lpFilename, buf) )
{
m_wndList.DeleteAllItems();
TString str;
int item = 0;
unsigned idx = 0;
unsigned siz = buf.size();
while( idx < siz )
{
int loop = 16;
if( int(siz - idx) < 16 ){
loop = int(siz - idx);
}
str.Format(_T("%08X"), idx);
m_wndList.InsertItem(item, (LPTSTR)str);
for( int i=0; i<loop; i++ ){
str.Format(_T("%02X"), buf.at(idx+i));
m_wndList.SetItem(item, i+1, (LPTSTR)str);
}
str.clear();
for( int i=0; i<loop; i++ ){
if( ::isgraph(int(buf.at(idx+i))) )
str.AppendFormat(_T("%c"), buf.at(idx+i));
else
str.AppendFormat(_T(" "));
}
m_wndList.SetItem(item, 17, (LPTSTR)str);
idx += 16;
item += 1;
}
}
}
示例9: OnGoogleShowlocation
void CFrameLocs::OnGoogleShowlocation()
{
// TODO: Add your command handler code here
TString str;
int n;
CLocation * loc = NULL;
POSITION pos;
pos = m_wndLocs.GetFirstSelectedItemPosition();
if (pos != NULL && (n = m_wndLocs.GetNextSelectedItem(pos),n>=0))
{
loc = (CLocation *)m_wndLocs.GetItemData(n);
if (loc != NULL)
{
str.Format("<html><head><meta http-equiv=\"REFRESH\" content=\"0;url=http://maps.google.com/?ie=UTF8&ll=%f,%f&spn=0.774196,1.235962&z=10"
"\"></head><body></body><html>", loc->m_fLatitude, loc->m_fLongitude);
TFile file;
TString fileName;
fileName = GCalApp_GetFileName(GSTR_TEMFOLDER);
fileName += "temp.html";
if (file.Open(fileName, "w") == TRUE)
{
file.WriteString(str);
file.Close();
ShellExecute(this->m_hWnd, NULL, fileName, NULL, NULL, SW_SHOW);
}
/* str.Format("http://maps.google.com/?ie=UTF8&ll=%f,%f&spn=0.774196,1.235962&z=10", loc->m_fLatitude, loc->m_fLongitude);
if (p_wndWeb != NULL)
{
p_wndWeb->Navigate(str.c_str());
m_wndTab.SetCurSel(1);
ShowControlsForTab(1);
}*/
}
}
return;
}
示例10: OnInitDialog
BOOL DlgSetPrintStyle::OnInitDialog()
{
CDialog::OnInitDialog();
CheckRadioButton(IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);
OnRadio1();
m_nStyle = 0;
m_nFontSize = 11;
m_nHeaderSize = 18;
m_strFont = "Tahoma";
int i;
TString str;
for(i = 0; i < 20; i++)
{
str.Format("%d", i + 5);
m_cbSizeText.AddString(str);
m_cbSizeHdr.AddString(str);
}
m_cbSizeText.SetCurSel(m_nFontSize - 5);
m_cbSizeHdr.SetCurSel(m_nHeaderSize - 5);
m_wndFontName.SetWindowText(m_strFont);
SetDlgItemInt(IDC_EDIT2, m_margins.top, FALSE);
SetDlgItemInt(IDC_EDIT3, m_margins.left, FALSE);
SetDlgItemInt(IDC_EDIT4, m_margins.right, FALSE);
SetDlgItemInt(IDC_EDIT5, m_margins.bottom, FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例11: OnInitDialog
BOOL DlgGetStartDate::OnInitDialog()
{
int i;
TString str;
VCTIME vc;
SYSTEMTIME st;
if (bFinal)
SetDlgItemText(IDC_BUTTON1, "Calculate");
m_setMenu.CreatePopupMenu();
m_setMenu.AppendMenu(MF_STRING, ID_SET_TODAY, "set today");
m_setMenu.AppendMenu(MF_STRING, ID_SET_START_MONTH, "set start of the month");
m_setMenu.AppendMenu(MF_STRING, ID_SET_START_YEAR, "set start of the year");
m_setMenu.AppendMenu(MF_STRING, ID_SET_START_MASA, "set start of the masa");
m_setMenu.AppendMenu(MF_STRING, ID_SET_START_GYEAR, "set start of the gaurabda year");
// inicializacia prvkov okna
CDialog::OnInitDialog();
m_hdr.InitMyFont();
m_hdr.SetWindowText("Get Start Date");
for(i = 1; i <= 31; i++)
{
str.Format("%d", i);
w_day.AddString(str.c_str());
}
for(i = 0; i < 12; i++)
{
w_month.AddString(GCStrings::getString(760 + i).c_str());
}
if (s_init == 0 || m_resultA.gyear < 0 || m_resultA.gyear > 2500)
{
GetLocalTime(&st);
m_resultC.day = st.wDay;
m_resultC.month = st.wMonth;
m_resultC.year = st.wYear;
m_resultC.shour = double(0.5);
m_resultC.tzone = m_earth.tzone;
GCCalendar::VCTIMEtoVATIME(m_resultC, m_resultA, m_earth);
s_init = 1;
}
m_resultC.tzone = m_earth.tzone;
f_update = FALSE;
w_day.SetCurSel(m_resultC.day - 1);
w_month.SetCurSel(m_resultC.month - 1);
SetDlgItemInt(IDC_EDIT2, m_resultC.year, FALSE);
w_tithi.SetCurSel(m_resultA.tithi);
w_masa.SetCurSel(GCCalendar::MasaToComboMasa(m_resultA.masa));
SetDlgItemInt(IDC_EDIT1, m_resultA.gyear, FALSE);
f_update = TRUE;
m_nNextStep = 0;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例12: calculateTriggerRates
void calculateTriggerRates(
TString inFile0Name = "root://eoscms//eos/cms/store/caf/user/velicanu/PA2013_merged_HiForest/pPb_hiForest2_pilotRun_200kHz_v3.root",
// TString inFile0Name = "/castor/cern.ch/user/m/miheejo/openHLT/cms442/r181530_reco_v1_2/HIExpressPhysics_hiexp-hirun2011-r181530-reco-v1_2.root",
// "/castor/cern.ch/user/k/kimy/openHLT//openhlt_run181531.root",
// "/castor/cern.ch/user/v/velicanu/HIHLT_Validation_Test_GRIF_v10.root",
Int_t runNum = 202792,
TString outdir = "output",
char *projectTitle = "HIpARun2013",
string source = "data"
)
{
char szBuf[256];
int scale = 23;
// event selectoin
//Form("&&Run==%d&&LumiBlock>%d",runNum,goodLumiStart)
// trigger under investigation
// const int ntrigs = 8;
// const char* triggerPath[ntrigs] = {"","HLT_HIMinBiasHfOrBSC",
// "L1_SingleMu3_BptxAND","HLT_HIL1SingleMu3","HLT_HIL2Mu3",
// "L1_DoubleMuOpen_BptxAND","HLT_HIL1DoubleMuOpen","HLT_HIL2DoubleMu3"};
/* const int ntrigs = 9;
const char* triggerPath[ntrigs] = {
"",
"HLT_PAL1SingleMuOpen_v1",
"HLT_PAL1SingleMu3_v1",
"HLT_PAL1SingleMu7_v1",
"HLT_PAL1SingleMu12_v1",
"HLT_PAL1DoubleMu0_v1",
"HLT_PADimuon0_NoVertexing_v1",
"HLT_PAMu5_v1",
"HLT_PAMu8_v1"
}; */
//trigger list for singleMu rate plot
const int ntrigs = 4 ;
const char* triggerPath[ntrigs] = {
"",
"HLT_PAMu3_v1",
"HLT_PAMu7_v1",
"HLT_PAMu12_v1"
};
/*
//trigger list for DoubleMu rate plot
const int ntrigs = 4 ;
const char* triggerPath[ntrigs] = {
"",
"HLT_PAL1DoubleMuOpen_v1",
"HLT_PAL1DoubleMu0_HighQ_v1",
"HLT_PAL2DoubleMu3_v1"
};
//trigger list fo bJet+Mu rate plot
const int ntrigs =5;
const char* triggerPath[ntrigs] = {
"",
"HLT_PAMu3PFJet20_v1",
"HLT_PAMu3PFJet40_v1",
"HLT_PAMu7PFJet20_v1",
"HLT_PABTagMu_Jet20_Mu4_v1"
};*/
TString str;
TH1D *ahTemp[ntrigs];
double ahTempRate[ntrigs]; //Rates (Integrated over lumisections)
// Load input
TChain * HltTree = new TChain("hltanalysis/HltTree","HI OpenHLT Tree");
HltTree->Add(inFile0Name);
cout << inFile0Name << endl;
cout << " # entries: " << HltTree->GetEntries() << endl;
int nEvents = HltTree->GetEntries();
for(int it=1; it<ntrigs; it++)
{
TH1D *ph = new TH1D("ph",";Lumi Section; Counts ",1100,0,1100);
HltTree->Draw("LumiBlock>>ph",str.Format("%s",triggerPath[it]));
TLegend *lTemp= new TLegend(0.2,0.8,0.8,0.9);
lTemp->SetHeader(str.Format("Run : %d",runNum));
lTemp->SetMargin(0.05);
lTemp->SetFillStyle(0);
lTemp->SetLineColor(0);
lTemp->SetLineWidth(5.0);
lTemp->SetTextSize(0.03);
lTemp->AddEntry(ph,str.Format("%s",triggerPath[it],"l"));
lTemp->Draw("same");
c1->SaveAs(str.Format("%d_%s.pdf",runNum,triggerPath[it]));
TH1D *phLumi = (TH1D*)gDirectory->Get("ph");
phLumi->SetDirectory(0);
phLumi->Scale(1./(phLumi->GetBinWidth(1)*23));// 1lumi unit=23 sec
ahTempRate[it] = phLumi->Integral()/phLumi->GetNbinsX();
ahTemp[it] = phLumi;
cout<< triggerPath[it]<<"\t"<<phLumi->GetEntries()<< "\t" << ahTempRate[it] << endl;
}
//----------------------------
// drawing part
// axis
//.........这里部分代码省略.........
示例13: multidimSampling
void multidimSampling() {
#ifdef __CINT__
std::cout << "DO NOT RUN WITH CINT:" << std::endl;
std::cout << "we are using a custom function which requires" << std::endl;
std::cout << "that this tutorial must be compiled with ACLIC" << std::endl;
return;
#endif
const int N = 100000;
//const int NBin = 1000;
const int DIM = 4;
double xmin[] = {-10,-10,-10, -10};
double xmax[] = { 10, 10, 10, 10};
double par0[] = { 1., -1., 2, 0, // the gaussian mu
1, 2, 1, 3, // the sigma
0.5,0.,0.,0.,0.,0.8 }; // the correlation
const int NPAR = DIM + DIM*(DIM+1)/2; // 14 in the 4d case
// generate the sample
GausND gaus4d(4);
TF1 * f = new TF1("functionND",gaus4d,0,1,14);
f->SetParameters(par0);
double x0[] = {0,0,0,0};
// for debugging
if (debug) f->EvalPar(x0,0);
debug = false;
TString name;
for (int i = 0; i < NPAR; ++i ) {
if (i < DIM) f->SetParName(i, name.Format("mu_%d",i+1) );
else if (i < 2*DIM) f->SetParName(i, name.Format("sig_%d",i-DIM+1) );
else if (i < 2*DIM) f->SetParName(i, name.Format("sig_%d",i-2*DIM+1) );
}
//ROOT::Math::DistSamplerOptions::SetDefaultSampler("Foam");
DistSampler * sampler = Factory::CreateDistSampler();
if (sampler == 0) {
Info("multidimSampling","Default sampler %s is not available try with Foam ",
ROOT::Math::DistSamplerOptions::DefaultSampler().c_str() );
ROOT::Math::DistSamplerOptions::SetDefaultSampler("Foam");
}
sampler = Factory::CreateDistSampler();
if (sampler == 0) {
Error("multidimSampling","Foam sampler is not available - exit ");
return;
}
sampler->SetFunction(*f,DIM);
sampler->SetRange(xmin,xmax);
bool ret = sampler->Init();
std::vector<double> data1(DIM*N);
double v[DIM];
TStopwatch w;
if (!ret) {
Error("Sampler::Init","Error initializing unuran sampler");
return;
}
// generate the data
w.Start();
for (int i = 0; i < N; ++i) {
sampler->Sample(v);
for (int j = 0; j < DIM; ++j)
data1[N*j + i] = v[j];
}
w.Stop();
w.Print();
// fill tree with data
TFile * file = new TFile("multiDimSampling.root","RECREATE");
double x[DIM];
TTree * t1 = new TTree("t1","Tree from Unuran");
t1->Branch("x",x,"x[4]/D");
for (int i = 0; i < N; ++i) {
for (int j = 0; j < DIM; ++j) {
x[j] = data1[i+N*j];
}
t1->Fill();
}
// plot the data
t1->Draw("x[0]:x[1]:x[2]:x[3]","","candle");
TCanvas * c2 = new TCanvas();
c2->Divide(3,2);
int ic=1;
c2->cd(ic++);
t1->Draw("x[0]:x[1]");
c2->cd(ic++);
t1->Draw("x[0]:x[2]");
c2->cd(ic++);
t1->Draw("x[0]:x[3]");
c2->cd(ic++);
t1->Draw("x[1]:x[2]");
c2->cd(ic++);
t1->Draw("x[1]:x[3]");
//.........这里部分代码省略.........
示例14: ParseCommandArguments
//.........这里部分代码省略.........
{
nReq = 15;
} else if (stricmp(args[i + 1], "gcalendar") == 0)
{
nReq = 16;
} else if (stricmp(args[i + 1], "gtithi") == 0)
{
nReq = 17;
} else if (stricmp(args[i + 1], "next") == 0)
{
nReq = 18;
} else if (stricmp(args[i + 1], "xlan") == 0)
{
nReq = 50;
}
else if (stricmp(args[i + 1], "help") == 0)
{
nReq = 60;
}
/*else if (stricmp(args[i + 1], "") == 0)
{
} else if (stricmp(args[i + 1], "") == 0)
{
} else if (stricmp(args[i + 1], "") == 0)
{
} else if (stricmp(args[i + 1], "") == 0)
{
}*/
}
i++;
}
}
loc.m_strFullName.Format("%s (%s %s, %s)", loc.m_strName.c_str(), loc.m_strLatitude.c_str(),
loc.m_strLongitude.c_str(), loc.m_strTimeZone.c_str());
vcStart.tzone = loc.m_fTimezone;
vcEnd.tzone = loc.m_fTimezone;
//AfxTrace("vcStart = %d,%d,%d,...,%f\n", vcStart.day, vcStart.month, vcStart.year, vcStart.shour);
switch(nReq)
{
case 10:
case 13:
case 14:
if (vcStart.year == 0 && vaStart.gyear != 0)
GCCalendar::VATIMEtoVCTIME(vaStart, &vcStart, (EARTHDATA)loc);
if (vcEnd.year == 0 && vaEnd.gyear != 0)
GCCalendar::VATIMEtoVCTIME(vaEnd, &vcEnd, (EARTHDATA)loc);
break;
default:
break;
}
if (vcStart.year != 0 && vcEnd.year != 0 && nCount < 0)
nCount = int(vcEnd.GetJulian() - vcStart.GetJulian());
if (nCount < 0)
nCount = 30;
TResultApp appday;
TResultCalendar calendar;
//AfxTrace("Count === %d\n", nCount);
switch(nReq)
{
case 10: