当前位置: 首页>>代码示例>>C++>>正文


C++ TString::Insert方法代码示例

本文整理汇总了C++中TString::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::Insert方法的具体用法?C++ TString::Insert怎么用?C++ TString::Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TString的用法示例。


在下文中一共展示了TString::Insert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnLocationDeletelocation

void CFrameLocs::OnLocationDeletelocation() 
{
	// TODO: Add your control notification handler code here
	int n;
	TString str;
	CLocation * loc;
	POSITION pos = m_wndLocs.GetFirstSelectedItemPosition();
	
	if (pos == NULL)
		return;
	
	n = m_wndLocs.GetNextSelectedItem(pos);
	if (n < 0)
		return;

	loc = (CLocation *)(m_wndLocs.GetItemData(n));
	if (loc == NULL)
		return;

	loc->SetTextB(str);
	str.Insert(0, "Do you want to remove location:\r\n\r\n");
	str += "\r\n\r\nfrom your list of locations?";

	if (AfxMessageBox(str, MB_YESNO) == IDYES)
	{
		theLocs.RemoveAt(loc);
		InitCityByCountry(g_nCurrentCountry);
		delete loc;
	}	
}
开发者ID:gopa810,项目名称:SamskaraTimes,代码行数:30,代码来源:FrameLocs.cpp

示例2: CSVString

TString CSVString( const TString &astring, char adelimiter )
{
  bool changed = false;
  int pos;
  TString word = astring;

  ReplaceSub32OrdinalsWithHexForm( word );
  changed = 0;
  pos = 1;
  while( pos<=word.Length() )
  {
    if( word[pos]==adelimiter )
    {
      changed = 1;
    }
    else if( word[pos]=='"' )
    {
      word.Insert( "\"", pos );
      pos++;
      changed = 1;
    }
    pos++;
  }
  if( changed )
    word = "\"" + word + "\"";

  return word;
}
开发者ID:Sustak,项目名称:final.utils,代码行数:28,代码来源:csv.cpp

示例3: ReplaceSub32OrdinalsWithHexForm

void ReplaceSub32OrdinalsWithHexForm( TString& astring )
{
  int sl = astring.Length();
  for( int i=1; i<=sl; i++ )
  {
    if( astring[i] == '\\' )
    {
      astring.Insert( "\\", i );
      i++;
      sl++;
    }
    else
    {
      if( ((unsigned char)astring[i]) < 32 )
      {
        astring.Insert( "\\x" + utils::IntToHex((unsigned char)astring[i],2), i );
        astring.Delete( i+4,1 );
        sl += 3;
        i += 3;
      }
    }
  }
}
开发者ID:Sustak,项目名称:final.utils,代码行数:23,代码来源:csv.cpp

示例4: misalignmentDependence

void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
                            TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
                            Bool_t resolution = false,
                            TString saveas = "")
{
    for (int i = 0; i < nParameters; i++)
    {
        TString saveasi = saveas;
        TString insert = nPart(1,parameternames[i]);
        insert.Prepend(".");
        saveasi.Insert(saveasi.Last('.'),insert);    //insert the parameter name before the file extension
        misalignmentDependence(nFiles,files,names,misalignment,values,phases,xvar,yvar,
                               function,parameters[i],parameternames[i],functionname,
                               resolution,
                               saveasi);
    }
}
开发者ID:hroskes,项目名称:HiggsPlot,代码行数:17,代码来源:misalignmentDependence.C

示例5: bfcread_hist_extract

void bfcread_hist_extract(
  const Char_t *MainFile=
    "/afs/rhic.bnl.gov/star/data/samples/gstar.hist.root",
  const Char_t *MakerHistDir="EventQA",
  const Char_t *TopDirTree="bfcTree",
  Char_t *OutFile=0,
  const Char_t *PrintList="")
{

  cout << "bfcread_hist_extract.C, input hist file = " 
       << MainFile << endl;
  cout << "bfcread_hist_extract.C, directory name for hist = " 
       << MakerHistDir << endl;
  cout << "bfcread_hist_extract.C, top level directory in hist file = " 
       << TopDirTree << endl;

//
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("StIOMaker");
    gSystem->Load("StarClassLibrary");
    gSystem->Load("StUtilities");
    gSystem->Load("StAnalysisUtilities");
    gSystem->Load("libglobal_Tables");

// setup chain with IOMaker - can read in .dst.root, .dst.xdf files
  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,TopDirTree);
  IOMk->SetDebug();
  IOMk->SetIOMode("r");
  IOMk->SetBranch("*",0,"0");                 //deactivate all branches
  IOMk->SetBranch("histBranch",0,"r"); //activate dst Branch


// constructor for other maker (not used in chain)
   StHistUtil   *HU  = new StHistUtil;

// now must set pointer to StMaker so HistUtil can find histograms
//  with StHistUtil methods
// -- input any maker pointer but must cast as type StMaker
   HU->SetPntrToMaker((StMaker *)IOMk);

// ONLY use StIOMaker in chain 
// --- now execute chain member functions - 1 event (histograms) only
  IOMk->Init();
  IOMk->Clear();
  IOMk->Make();

// method to print out list of histograms
// - can do this anytime after they're booked
// - default is to print out QA hist branch
   Int_t NoHist=0;
   //NoHist = HU->ListHists(MakerHistDir);
   TList* dList = HU->FindHists(MakerHistDir);
   if (PrintList) HU->SetDefaultPrintList(MakerHistDir,PrintList);
   NoHist = HU->CopyHists(dList);
   TH1** nh = HU->getNewHist();

   TString name = MainFile;
   if (!OutFile) {
     name.Remove(0,name.Last('/')+1);
     TString name2 = MakerHistDir;
     name2.Remove(0,name2.Last('/')+1);
     name.Insert(name.First('.'),"_");
     name.Insert(name.First('.'),name2);
     OutFile = name.Data();
   }
   cout <<  "Output hist file: " << OutFile << endl;
   TFile* ofile = new TFile(OutFile,"RECREATE");
   for (int i=0; i<NoHist; i++) {
     printf("Extracting: %d. %s : %s\n",
       i+1,nh[i]->GetName(),nh[i]->GetTitle());
     nh[i]->Write();
   }
   ofile->Close();
      
}
开发者ID:star-bnl,项目名称:star-macros,代码行数:76,代码来源:bfcread_hist_extract.C

示例6: makePlots


//.........这里部分代码省略.........
    gg->SetLineColor(linecolor[k]);
    gg->SetLineWidth(linewidth[k]);
    gg->SetLineStyle(linestyle[k]);

    gg->SetMaximum(MAXY);
    gg->SetMinimum(1.6);

    gg->GetXaxis()->SetLimits( 0.0, 0.055 );

    gg->GetXaxis()->SetTitle("sin^{2}#theta_{13}");
    gg->GetXaxis()->CenterTitle(true);
    gg->GetXaxis()->SetLabelFont(42);
    gg->GetXaxis()->SetLabelOffset(0.006);
    gg->GetXaxis()->SetLabelSize(0.06);
    gg->GetXaxis()->SetTitleSize(0.06);
    gg->GetXaxis()->SetTickLength(0.05);
    gg->GetXaxis()->SetTitleOffset(1.07);
    gg->GetXaxis()->SetTitleFont(42);
    gg->GetXaxis()->SetNdivisions(509);
    gg->GetYaxis()->SetTitle("R");
    gg->GetYaxis()->CenterTitle(true);
    gg->GetYaxis()->SetNdivisions(509);
    gg->GetYaxis()->SetLabelFont(42);
    gg->GetYaxis()->SetLabelOffset(0.007);
    gg->GetYaxis()->SetLabelSize(0.06);
    gg->GetYaxis()->SetTitleSize(0.06);
    gg->GetYaxis()->SetTitleOffset(0.93);
    gg->GetYaxis()->SetTitleFont(42);

    if ( ((k+1) % 2) == 0 )
    {
      TString alpha = ((TObjString*)v_Labels->At(labelpos))->GetString();      
      leg->AddEntry( gg, alpha.Data(),"l");
      labelpos+=1;
    }
    
    c1->cd();

    if( k == 0 )
      gg->Draw("AC");
    else
      gg->Draw("C");

    TString ThisModel;
    TString ThisConfig;
    
    if( TString(model) == TString("StdPicture") )
      ThisModel = TString("No matter effect");
    else 
    {
      ThisModel = TString(model);
      ThisModel.Insert(5," ");
    }

    ThisConfig = TString(config);
    ThisConfig.Insert(3," ");
      
    TLatex *   tex = new TLatex(0.033, (MAXY-(MAXY*0.035)), ThisModel.Data() );
    tex->SetLineWidth(2);
    tex->Draw();

    if ( TString(model) != TString("StdPicture") ) {
      tex = new TLatex(0.033, (MAXY-(MAXY*0.055)), ThisConfig.Data() );
      tex->SetLineWidth(2);
      tex->Draw();
    }
      
  
  }
  
  leg->Draw();

  
  
  double y_min = 1.60;
  double y_max = MAXY;
  
  TLine *line = new TLine(x_Q13_SetI, y_min,x_Q13_SetI, y_max);
  //line->Draw();
  line = new TLine(x_Q13_SetII, y_min,x_Q13_SetII, y_max);
  //line->Draw();

  c1->cd();
  
  std::stringstream saveAs;
  
  saveAs.str("");
  saveAs << path << model << "/pdf/" << "RvsSin2Q13_" << model << "_" << target << "_" << config << ".pdf";
  c1->SaveAs( saveAs.str().c_str() );
  
  saveAs.str("");
  saveAs << path << model << "/png/" << "RvsSin2Q13_" << model << "_" << target << "_" << config << ".png";
  c1->SaveAs( saveAs.str().c_str() );

  saveAs.str("");
  saveAs << path << model << "/eps/" << "RvsSin2Q13_" << model<< "_" <<  target << "_" << config << ".eps";
  c1->SaveAs( saveAs.str().c_str() );
  
  
}
开发者ID:andres0sorio,项目名称:GRBsWork,代码行数:101,代码来源:make_plots_paper02_sin2theta_02.C

示例7: makehistogram

/// Make Output Histogram ////////////////////////////////////////////////////
void makehistogram(TString nameofhistogram, float xmin, float xmax, float rebin, float ymax){

  TString pad1 = nameofhistogram;
  TString pad2 = nameofhistogram;
  TString canvas = nameofhistogram;
  TString hstack = nameofhistogram;
  TString legend = nameofhistogram;
  TString func = nameofhistogram;
  TString clone = nameofhistogram;
  TString line = nameofhistogram;
  pad1.Insert(0, "pad1_");
  pad2.Insert(0, "pad2_");
  canvas.Insert(0, "c_");
  hstack.Insert(0, "hs_");
  legend.Insert(0, "legend_");
  func.Insert(0, "ratio_");
  clone.Insert(0, "h3_");
  line.Insert(0, "l_");

  mapcanvas[canvas] = new TCanvas(canvas,"",800,600); 
  gStyle -> SetOptStat(1111);
  gStyle -> SetPadTickY(1);
  gStyle -> SetPadTickX(1);

  mappad[pad1] = new TPad("", "", 0, 0, 1, 1);
  mappad[pad1] -> SetBottomMargin(0.05);
  mappad[pad1] -> SetTopMargin(0.05);
  mappad[pad1] -> SetLeftMargin(0.09);
  mappad[pad1] -> SetRightMargin(0.09);
  gStyle -> SetPadTickY(1);
  gStyle -> SetPadTickX(1);
  mappad[pad1] -> Draw();
  mappad[pad1] -> cd();
  mappad[pad1] -> SetLogy();
  
  GetHist(nameofhistogram + head + ttjets) -> SetLineColor(kBlue);
  GetHist(nameofhistogram + head + gluino) -> SetLineColor(kGreen);
  GetHist(nameofhistogram + head + stop) -> SetLineColor(kRed);
  
  GetHist(nameofhistogram + head + ttjets) -> SetLineWidth(3);
  GetHist(nameofhistogram + head + gluino) -> SetLineWidth(3);
  GetHist(nameofhistogram + head + stop) -> SetLineWidth(3);

  GetHist(nameofhistogram + head + ttjets) -> SetFillColor(kBlue);
  GetHist(nameofhistogram + head + gluino) -> SetFillColor(kGreen);
  GetHist(nameofhistogram + head + stop) -> SetFillColor(kRed);
  
  GetHist(nameofhistogram + head + ttjets) -> SetFillStyle(3004);
  GetHist(nameofhistogram + head + gluino) -> SetFillStyle(3007);
  GetHist(nameofhistogram + head + stop) -> SetFillStyle(3005);


  //rebining
  //GetHist(nameofhistogram + TruthCorrection + DY_high) -> Rebin(rebin);
  
  //draw
  GetHist(nameofhistogram + head + ttjets) -> SetStats(0);
  GetHist(nameofhistogram + head + ttjets) -> Draw();
  GetHist(nameofhistogram + head + gluino) -> Draw("same");
  GetHist(nameofhistogram + head + stop) -> Draw("same");

  GetHist(nameofhistogram + head + ttjets) -> GetXaxis() -> SetRangeUser(xmin, xmax);
  GetHist(nameofhistogram + head + ttjets) -> SetMinimum(1.);

  

  mappad[pad1] -> Update();
  
  maplegend[legend] = new TLegend(0.6,0.7,0.9,0.9);
  maplegend[legend] -> AddEntry(GetHist(nameofhistogram + head + ttjets), "ttjets", "l");
  maplegend[legend] -> AddEntry(GetHist(nameofhistogram + head + gluino), "gluino", "l");
  maplegend[legend] -> AddEntry(GetHist(nameofhistogram + head + stop), "stop", "l");

  maplegend[legend] -> SetFillColor(kWhite);
  maplegend[legend] -> SetLineColor(kBlack);
  maplegend[legend] -> SetBorderSize(1);
  maplegend[legend] -> SetFillStyle(1001);
  maplegend[legend] -> SetShadowColor(0); // 0 = transparent
  maplegend[legend] -> SetEntrySeparation(0.3);
  maplegend[legend] -> Draw("same");

  mapcanvas[canvas] -> cd();

  TString pdfname = "./pdfs/";
  pdfname.Append(nameofhistogram);
  pdfname.Append(".pdf");
  mapcanvas[canvas] -> SaveAs(pdfname);

}
开发者ID:sungbinoh,项目名称:ROOT_macro,代码行数:90,代码来源:histogram_overlap.C

示例8: GenerateTree

//_____________________________________________________________________________
Int_t ProofAux::GenerateTree(const char *fnt, Long64_t ent, TString &fn)
{
   // Generate the main tree for the 'friends' tutorial; the tree is called
   // 'Tmain', has 'ent' entries and is saved to file 'fnt'.
   // The full file path is returned in 'fn'.
   // Return 0 on success, -1 on error.

   Int_t rc = -1;

   // Check the filename
   fn = fnt;
   if (fn.IsNull()) {
      Error("GenerateTree", "file name undefined!");
      return rc;
   }
   TUrl uu(fn, kTRUE);
   if (!strcmp(uu.GetProtocol(), "file") && !fn.BeginsWith("/")) {
      // Local file with relative path: create under the data directory
      if (!gProofServ ||
          !(gProofServ->GetDataDir()) || strlen(gProofServ->GetDataDir()) <= 0) {
         Error("GenerateTree", "data directory undefined!");
         return rc;
      }
      // Insert data directory
      fn.Insert(0, TString::Format("%s/", gProofServ->GetDataDir()));
      // Make sure the directory exists
      TString dir = gSystem->DirName(fn);
      if (gSystem->AccessPathName(dir, kWritePermission)) {
         if (gSystem->mkdir(dir, kTRUE) != 0) {
            Error("GenerateTree", "problems creating directory %s to store the file", dir.Data());
            return rc;
         }
      }
   }

   // Create the file
   TDirectory* savedir = gDirectory;
   TFile *f = new TFile(fn, "RECREATE");
   if (!f || f->IsZombie()) {
      Error("GenerateTree", "problems opening file %s", fn.Data());
      return rc;
   }
   savedir->cd();
   rc = 0;

   // Create the tree
   TTree *T = new TTree("Tmain","Main tree for tutorial friends");
   T->SetDirectory(f);
   Int_t Run = 1;
   T->Branch("Run",&Run,"Run/I");
   Long64_t Event = 0;
   T->Branch("Event",&Event,"Event/L");
   Float_t x = 0., y = 0., z = 0.;
   T->Branch("x",&x,"x/F");
   T->Branch("y",&y,"y/F");
   T->Branch("z",&z,"z/F");
   TRandom r;
   for (Long64_t i = 0; i < ent; i++) {
      if (i > 0 && i%1000 == 0) Run++;
      Event = i;
      x = r.Gaus(10,1);
      y = r.Gaus(20,2);
      z = r.Landau(2,1);
      T->Fill();
   }
   T->Print();
   f->cd();
   T->Write();
   T->SetDirectory(0);
   f->Close();
   delete f;
   delete T;

   // Notify success
   Info("GenerateTree", "file '%s' successfully created", fn.Data());

   // Add to the list
   TString fds(fn);
   if (!strcmp(uu.GetProtocol(), "file")) {
      if (gSystem->Getenv("LOCALDATASERVER")) {
         if (strcmp(TUrl(gSystem->Getenv("LOCALDATASERVER"), kTRUE).GetProtocol(), "file"))
            fds.Insert(0, TString::Format("%s/", gSystem->Getenv("LOCALDATASERVER")));
      } else {
         fds.Insert(0, TString::Format("root://%s/", gSystem->HostName()));
      }
   }
   fMainList->Add(new TObjString(fds));

   // Done
   return rc;
}
开发者ID:gganis,项目名称:proof,代码行数:92,代码来源:ProofAux.C

示例9: saveHistos

void TSelectionClass::saveHistos()
{
	cout<<"save Histo: "<<hFiducialCutSilicon->GetTitle()<<endl;
	TString name = hFiducialCutSilicon->GetName();
	name.Insert(0,"c");
	TCanvas *c1= fiducialCuts->getAllFiducialCutsCanvas(hFiducialCutSilicon);
	c1->SetName(name);
	histSaver->SaveCanvas(c1);
	delete c1;
	c1 = 0;
    delete hFiducialCutSilicon;

	name = hFiducialCutSiliconDiamondHit->GetName();
	name.Insert(0,"c");
	c1 = fiducialCuts->getAllFiducialCutsCanvas(hFiducialCutSiliconDiamondHit,true);
	c1->SetName(name);
	histSaver->SaveCanvas(c1);
	delete c1;
	c1=0;
    delete hFiducialCutSiliconDiamondHit;

	name = "c";
	name.Append(hFiducialCutSiliconOneAndOnlyOneDiamondHit->GetName());
	c1= fiducialCuts->getAllFiducialCutsCanvas(hFiducialCutSiliconOneAndOnlyOneDiamondHit,true);
	c1->SetName(name);
	histSaver->SaveCanvas(c1);
    delete c1;
    c1=0;
    delete hFiducialCutSiliconOneAndOnlyOneDiamondHit;

	name = "c";
	name.Append(hSelectedEvents->GetName());
	c1 = fiducialCuts->getAllFiducialCutsCanvas(hSelectedEvents,true);
	c1->SetName(name);
	histSaver->SaveCanvas(c1);
    delete c1;
    c1=0;
    delete hSelectedEvents;

    map<Int_t,TH2F*>::iterator it;
    for (it = mapFiducialCutSiliconDiamondHitSamePattern.begin(); it!=mapFiducialCutSiliconDiamondHitSamePattern.end(); it++){
        TH2F* histo = (*it).second;
        name = histo->GetName();
        name.Replace(0,1,"c");
        c1 = fiducialCuts->getAllFiducialCutsCanvas(histo,true);
        c1->SetName(name);
        histSaver->SaveCanvas(c1);
        delete c1;
        c1=0;
        delete histo;
    }
	hAnalysisFraction->Scale(.1);
	hAnalysisFraction->SetStats(false);
	//	hAnalysisFraction->GetYaxis()->SetRangeUser(0,100);
	histSaver->SaveHistogram(hAnalysisFraction);
	delete hAnalysisFraction;


    histSaver->SaveHistogram(hDiamondPatternFiducialPattern);

    histSaver->SaveHistogram(hDiamondPatternFiducialPatternNoMapping);
    name = "stackPatternMapping";
    hDiamondPatternFiducialPattern->SetLineColor(kGreen);
    hDiamondPatternFiducialPatternNoMapping->SetLineColor(kRed);
    THStack *stack = new THStack(name,name);
    stack->Add(hDiamondPatternFiducialPattern);
    stack->Add(hDiamondPatternFiducialPatternNoMapping);
    stack->Draw();
    if(stack->GetXaxis()) stack->GetXaxis()->SetTitle("pattern no.");
    if(stack->GetYaxis()) stack->GetYaxis()->SetTitle("number of entries #");
    histSaver->SaveStack(stack,"hist",true);
    if(stack) delete stack;
    histSaver->SaveHistogram(pDiamondPatternFiducialPatternProfile);
    if(hDiamondPatternFiducialPatternNoMapping) delete hDiamondPatternFiducialPatternNoMapping;
    if(hDiamondPatternFiducialPattern) delete hDiamondPatternFiducialPattern;
    if (pDiamondPatternFiducialPatternProfile) delete pDiamondPatternFiducialPatternProfile;
}
开发者ID:diamondIPP,项目名称:StripTelescopeAnalysis,代码行数:77,代码来源:TSelectionClass.cpp


注:本文中的TString::Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。