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


C++ TextFile::Open方法代码示例

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


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

示例1: wxComboBox

TagBox::TagBox(ToolPanel *panel, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, wxString boxname, wxString modpath)
	: wxComboBox(panel, id, label, wxDefaultPosition, size)
{
	wxString filename, filepath;
	wxString readline, tag, text;
	TextFile opfile;
	bool check;

	path = modpath;
	name = boxname;
	diagbox = NULL;
	labelset = false;
	tag = "";

	if(panel->mainwin) diagbox = panel->mainwin->diagbox;

	diagbox->Write("\nTagBox init " + name + "\n");

	// tag history load
	if(name == "") {
		diagbox->Write("Tag file not set\n");
		return;
	}
	filename =  name + "tags.ini";
	check = opfile.Open(path + "/Tags/" + filename);
	if(!check) {
		if(diagbox) diagbox->Write("No tag history\n");
		return;
	}

	diagbox->Write("Reading tag history " + filename + "\n");

	readline = opfile.ReadLine();

	while(!readline.IsEmpty()) {
		//diagbox->Write("Readline " + readline + "\n");
		readline = readline.AfterFirst(' ');
		readline.Trim();
		tag = readline;
		Insert(tag, 0);
		//diagbox->Write("Insert " + tag + "\n");
		readline = opfile.ReadLine();
	}

	opfile.Close();	
	SetLabel(tag);
	diagbox->Write(name + " " + tag + "\n");
	if(tag != "") labelset = true;
}
开发者ID:HypoModel,项目名称:HypoModBase,代码行数:49,代码来源:hypocontrols.cpp

示例2: MainLoad

void MainFrame::MainLoad()
{
	long numdat;
	int i, check, boxindex;

	wxString filename, filepath;
	wxString readline, numstring;

	TextFile infile;
	wxPoint pos;
    wxSize size;

	//filepath = GetPath();
	filepath = "Init//";

	// Box Load
	filename = "mainbox.ini";

	check = infile.Open(filepath + filename);
	if(!check) return;
	readline = infile.ReadLine();
	//tofp.WriteLine(readline);
	while(!readline.IsEmpty()) {
		numstring = readline.BeforeFirst(' ');
		numstring.ToLong(&numdat);
		boxindex = numdat;
		if(boxindex >= toolset->numtools) break;

		pos.x = ReadNextData(&readline);
		pos.y = ReadNextData(&readline);
		size.x = ReadNextData(&readline);
		size.y = ReadNextData(&readline);
		if(toolset->box[boxindex]->servant) toolset->box[boxindex]->visible = (bool)ReadNextData(&readline);
		else toolset->box[boxindex]->visible = true;

		if(pos.x >= -5000 && pos.x < 5000 && pos.y >= -5000 && pos.y < 5000) toolset->box[boxindex]->mpos = pos;
		if(size.x >= 50 && size.x < 2000 && size.y >= 50 && size.y < 2000) toolset->box[boxindex]->boxsize = size;

		readline = infile.ReadLine();          // Read next line
		//tofp.WriteLine(readline);
	}
	infile.Close();

	for(i=0; i<toolset->numtools; i++) {
		toolset->box[i]->ReSize();
		toolset->box[i]->Show(toolset->box[i]->visible);
	}
}
开发者ID:HypoModel,项目名称:HypoModBase,代码行数:48,代码来源:hypobase.cpp

示例3: LoadBatchList

  /**
   * Loads the user entered batchlist file into a private variable for later use
   *
   * @param file The batchlist file to load
   *
   *  @history 2010-03-26 Sharmila Prasad - Remove the restriction of the number of
   *           columns in the batchlist file to 10.
   * @throws Isis::IException::User - The batchlist does not contain any data
   */
  void UserInterface::LoadBatchList(const QString file) {
    // Read in the batch list
    TextFile temp;
    try {
      temp.Open(file);
    }
    catch (IException &e) {
      QString msg = "The batchlist file [" + file
                   + "] could not be opened";
      throw IException(IException::User, msg, _FILEINFO_);
    }

    p_batchList.resize(temp.LineCount());

    for(int i = 0; i < temp.LineCount(); i ++) {
      QString t;
      temp.GetLine(t);

      // Convert tabs to spaces but leave tabs inside quotes alone
      t = IString(t).Replace("\t", " ", true).ToQt();

      t = IString(t).Compress().ToQt().trimmed();
      // Allow " ," " , " or ", " as a valid single seperator
      t = IString(t).Replace(" ,", ",", true).ToQt();
      t = IString(t).Replace(", ", ",", true).ToQt();
      // Convert all spaces to "," the use "," as delimiter
      t = IString(t).Replace(" ", ",", true).ToQt();
      int j = 0;

      QStringList tokens = t.split(",");

      foreach(QString token, tokens) {
        // removes quotes from tokens. NOTE: also removes escaped quotes.
        token = token.remove(QRegExp("[\"']"));
        p_batchList[i].push_back(token);
        j ++ ;
      }

      p_batchList[i].resize(j);
      // Every row in the batchlist must have the same number of columns
      if(i == 0)
        continue;
      if(p_batchList[i - 1].size() != p_batchList[i].size()) {
        QString msg =
          "The number of columns must be constant in batchlist";
        throw IException(IException::User, msg, _FILEINFO_);
      }
    }
开发者ID:corburn,项目名称:ISIS,代码行数:57,代码来源:UserInterface.cpp

示例4: OnClose

void ToolBox::OnClose(wxCloseEvent& event)
{
	TextFile ofp;
	wxString text;
	ofp.Open("boxdiag.txt");

	if(servant || child) {
		Show(false);
		ofp.WriteLine(text.Format("hide box %d, child %d", boxindex, child));
	}
	else if(canclose) {
		ofp.WriteLine(text.Format("close box %d, mod boxes %d", boxindex, toolset->numtools));
		//if(mod != NULL) mod->modtools.RemoveBox(boxindex);
		//mainwin->toolset.RemoveBox(boxindex);
		toolset->RemoveBox(boxindex);
		Destroy();
	}

	ofp.Close();
}
开发者ID:HypoModel,项目名称:HypoModBase,代码行数:20,代码来源:hypocontrols.cpp

示例5: BaseLoad

void GraphBase::BaseLoad(wxString path, wxString tag, wxTextCtrl *textbox)
{
	int i, index;
	TextFile infile;
	wxString readline, filename, filetag;
	wxString text, numstring, namestring, basestring;
	wxString gtag, gname;
	double numdat;
	GraphDat *graph;
	int version;

	filename = "gbase-" + tag + ".dat";

	//if(!infile.Open(initpath + "/Graphs/" + filename)) return;
	if(!infile.Open(path + "/" + filename)) return;

	if(textbox) textbox->AppendText(text.Format("Loading %d graphs\n", numgraphs));

	i = 0;
	readline = infile.ReadLine();

	// Version check

	//fileversion = ParseLong(&vstring, 'v');
	//textbox->AppendText(text.Format("Base file version %d\n", fileversion));
	//if(fileversion < version) textbox->AppendText(text.Format("Create base index\n"));

	while(!readline.IsEmpty()) {

		if(readline.GetChar(0) == 'v') version = ParseLong(&readline, 'v');          // check file version for backwards compatability
		else version = 0;
		//textbox->AppendText(text.Format("Base file version %d\n", version));
		//textbox->AppendText(text.Format("Readline %s\n", readline));

		if(version >= 2) {                                                  // Modern, reference by tag
			gtag = ParseString(&readline, 'g');
			graph = GetGraph(gtag);
			if(graph) graph->LoadDat(readline, version);
		}
		else {
			//GetGraphFromName(gname)->LoadDat(readline, version);              // Should add code to chop off any tag first
			//int ndex = readline.Find("name");
			//textbox->AppendText(text.Format("Base file version %d\n", version));
			//textbox->AppendText(text.Format("Readline %s\n", readline));
			namestring = readline.Mid(readline.Find("name"));
			//textbox->AppendText(text.Format("Name string %s\n", namestring));
			gname = ParseString(&namestring, 'e');
			gname.Replace("_", " ");
			if(textbox) textbox->AppendText(text.Format("gname %s\n", gname));
			graph = GetGraphFromName(gname);
			if(graph) graph->LoadDat(readline, version);
		}
			
		//graphstore[i].LoadDat(readline, version);
			
		if(infile.End()) break;
		readline = infile.ReadLine();	
		i++;	
	}
	infile.Close();


	// Read graphbase entries

	/*
	while(!readline.IsEmpty()) {
		graphstore[i].diagbox = mainwin->diagbox;
		graphstore[i].LoadDat(readline, version);
			
		if(infile.End()) break;
		readline = infile.ReadLine();	
		i++;	
	}
	infile.Close();
	*/
}
开发者ID:hypomod,项目名称:HypoModelBase,代码行数:76,代码来源:hypodat.cpp

示例6: OptionLoad

void HypoMain::OptionLoad()
{
    long numdat;
    int check;
    
    wxString filename;
    wxString readline, numstring, tag;
    
    filename = "Init/hypoprefs.ini";
    
    wxTextFile opfile(filename);
    
    if(!opfile.Exists()) {
        startmod = 13;
        numdraw = 3;
        ylabels = 5;
        diagnostic = 1;
        datsample = 1;
        basic = 0;
    }
    else {
        
        opfile.Open();
        
        readline = opfile.GetFirstLine();
        
        while(!readline.IsEmpty()) {
            tag = readline.BeforeFirst(' ');
            readline = readline.AfterFirst(' ');
            readline.Trim();
            readline.ToLong(&numdat);
            prefstore[tag] = numdat;
            //if(diagnostic) ofp.WriteLine(text.Format("Model Param ID %d, Value %.4f\n", id, datval));
            if(opfile.Eof()) return;
            readline = opfile.GetNextLine();
        }
        
        opfile.Close();
        
        startmod = prefstore["startmod"];
        numdraw = prefstore["numdraw"];
        viewheight = prefstore["viewheight"];
        viewwidth = prefstore["viewwidth"];
        ylabels = prefstore["ylabels"];
        datsample = prefstore["datsample"];
        basic = prefstore["basic"];
        diagnostic = prefstore["diagnostic"];
        
    }
    
    filename = "Init/hypopaths.ini";
    TextFile infile;
    check = infile.Open(filename);
    
    if(!check) {
        datapath = "Data";
        parampath = "Params";
        outpath = "";
        modpath = "";
        return;
    }
    
    readline = infile.ReadLine();
    datapath = readline.Trim();
    readline = infile.ReadLine();
    parampath = readline.Trim();
    readline = infile.ReadLine();
    outpath = readline.Trim();
    readline = infile.ReadLine();
    modpath = readline.Trim();
    
    opfile.Close();
}
开发者ID:hypomod,项目名称:HypoModelBase,代码行数:73,代码来源:hypomodel.cpp

示例7: IsisMain

void IsisMain() {
  //Create a process to create the input cubes
  Process p;
  //Create the input cubes, matching sample/lines
  Cube *inCube = p.SetInputCube ("FROM");
  Cube *latCube = p.SetInputCube("LATCUB", SpatialMatch);
  Cube *lonCube = p.SetInputCube("LONCUB", SpatialMatch);

  //A 1x1 brick to read in the latitude and longitude DN values from
  //the specified cubes
  Brick latBrick(1,1,1, latCube->PixelType());
  Brick lonBrick(1,1,1, lonCube->PixelType());

  UserInterface &ui = Application::GetUserInterface();

  //Set the sample and line increments
  int sinc = (int)(inCube->Samples() * 0.10);
  if(ui.WasEntered("SINC")) {
    sinc = ui.GetInteger("SINC");
  }

  int linc = (int)(inCube->Lines() * 0.10);
  if(ui.WasEntered("LINC")) {
    linc = ui.GetInteger("LINC");
  }

  //Set the degree of the polynomial to use in our functions
  int degree = ui.GetInteger("DEGREE");

  //We are using a polynomial with two variables
  PolynomialBivariate sampFunct(degree); 
  PolynomialBivariate lineFunct(degree);

  //We will be solving the function using the least squares method
  LeastSquares sampSol(sampFunct);
  LeastSquares lineSol(lineFunct);

  //Setup the variables for solving the stereographic projection
  //x = cos(latitude) * sin(longitude - lon_center)
  //y = cos(lat_center) * sin(latitude) - sin(lat_center) * cos(latitude) * cos(longitude - lon_center)

  //Get the center lat and long from the input cubes
  double lat_center = latCube->Statistics()->Average() * PI/180.0;
  double lon_center = lonCube->Statistics()->Average() * PI/180.0;


  /**
   * Loop through lines and samples projecting the latitude and longitude at those
   * points to stereographic x and y and adding these points to the LeastSquares 
   * matrix. 
   */
  for(int i = 1; i <= inCube->Lines(); i+= linc) {
    for(int j = 1; j <= inCube->Samples(); j+= sinc) {
      latBrick.SetBasePosition(j, i, 1);
      latCube->Read(latBrick);
      if(IsSpecial(latBrick.at(0))) continue;
      double lat = latBrick.at(0) * PI/180.0;
      lonBrick.SetBasePosition(j, i, 1);
      lonCube->Read(lonBrick);
      if(IsSpecial(lonBrick.at(0))) continue;
      double lon = lonBrick.at(0) * PI/180.0;

      //Project lat and lon to x and y using a stereographic projection
      double k = 2/(1 + sin(lat_center) * sin(lat) + cos(lat_center)*cos(lat)*cos(lon - lon_center));
      double x = k * cos(lat) * sin(lon - lon_center);
      double y = k * (cos(lat_center) * sin(lat)) - (sin(lat_center) * cos(lat) * cos(lon - lon_center));

      //Add x and y to the least squares matrix
      vector<double> data;
      data.push_back(x);
      data.push_back(y);
      sampSol.AddKnown(data, j);
      lineSol.AddKnown(data, i);

      //If the sample increment goes past the last sample in the line, we want to
      //always read the last sample..
      if(j != inCube->Samples() && j + sinc > inCube->Samples()) {
        j = inCube->Samples() - sinc;
      }
    }
    //If the line increment goes past the last line in the cube, we want to
    //always read the last line..
    if(i != inCube->Lines() && i + linc > inCube->Lines()) {    
      i = inCube->Lines() - linc;
    }
  }

  //Solve the least squares functions using QR Decomposition
  sampSol.Solve(LeastSquares::QRD);
  lineSol.Solve(LeastSquares::QRD);

  //If the user wants to save the residuals to a file, create a file and write
  //the column titles to it.
  TextFile oFile;
  if(ui.WasEntered("RESIDUALS")) {
    oFile.Open(ui.GetFilename("RESIDUALS"), "overwrite");
    oFile.PutLine("Sample,\tLine,\tX,\tY,\tSample Error,\tLine Error\n");
  }

  //Gather the statistics for the residuals from the least squares solutions
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:nocam2map.cpp


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