コード例 #1
0
/*
 *   TRADE_TYPE
 */
void TRADE_TYPE_ROW::Load(istream &file)
{
    char buf[1024];
    UINT is_market;
    UINT is_sell;
    file.getline(buf, sizeof(buf));
    if (file.eof()) {
        return;
    }
    int rc = sscanf(buf, "%[^\t]\t%[^\t]\t%d\t%d",
            TT_ID, TT_NAME, &is_sell, &is_market);
    /* handle integer to boolean conversion.  We can't use TT_* directly */
    /* in the sscanf above since sscanf doesn't know how to deal with    */
    /* boolean variables for storage.                                    */
    TT_IS_SELL = (is_sell == 1 ? true : false);
    TT_IS_MRKT = (is_market == 1 ? true : false);
    if (rc != 4) {
        std::ostringstream strm;
        strm << "TRADE_TYPE_ROW::Load only loaded " << rc << " values from line";
        throw std::runtime_error(strm.str());
    }
#if 0
    file>>TT_ID>>ws;
    file.get(TT_NAME, sizeof(TT_NAME), '\t');
    file>>ws;
    file>>TT_IS_SELL;
    file>>TT_IS_MRKT;
#endif
}
コード例 #2
0
ファイル: MapLine.cpp プロジェクト: clerkma/texlive-mobile
/** Constructs a MapLine object by parsing a single mapline from the given stream. */
MapLine::MapLine (istream &is)
	: _sfd(0), _fontindex(0), _slant(0), _bold(0), _extend(1)
{
	char buf[256];
	is.getline(buf, 256);
	parse(buf);
}
コード例 #3
0
/*
 *   EXCHANGE
 */
void EXCHANGE_ROW::Load(istream &file)
{
    char buf[1024];
    file.getline(buf, sizeof(buf));
    if (file.eof()) {
        return;
    }
    int rc = sscanf(buf, "%[^\t]\t%[^\t]\t%d\t%d\t%[^\t]%"PRId64,
            EX_ID, EX_NAME, &EX_OPEN, &EX_CLOSE, EX_DESC, &EX_AD_ID);
    if (rc != 6) {
        std::ostringstream strm;
        strm << "EXCHANGE_ROW::Load only loaded " << rc << " values from line";
        throw std::runtime_error(strm.str());
    }
#if 0
    file>>ws;
    file.get(EX_ID, sizeof(EX_ID), '\t');   //read and skip past the next tab
    file>>ws;
    file.get(EX_NAME, sizeof(EX_NAME), '\t');   //read up to the delimiter
    file>>ws;
    file>>EX_OPEN;
    file>>ws;
    file>>EX_CLOSE;
    file>>ws;
    file.get(EX_DESC, sizeof(EX_DESC), '\t');   //read up to the delimiter
    file>>ws;
    file>>EX_AD_ID;
#endif
}
コード例 #4
0
ファイル: testfp.C プロジェクト: tripleee/la-strings
static void rmuser_command(ostream &out, istream &in)
{
   if (get_access_level() < ADMIN_ACCESS_LEVEL)
      {
      cout << "You must be logged in with administrator privileges\n"
	      "(access level " << ADMIN_ACCESS_LEVEL
	    << " or higher) to add users." << endl ;
      return ;
      }
   char username[200] ;

   out << "Name of user to remove: " << flush ;
   in.ignore(1000,'\n') ;
   in.getline(username,sizeof(username)) ;
   if (!retrieve_userinfo(username))
      {
      cout << "No such user!" ;
      return ;
      }
   if (remove_user(username))
      cout << "User information file updated." << endl ;
   else
      cout << "User information file update failed!" << endl ;
   return ;
}
コード例 #5
0
// Initialize the zscores with means and standard dev, and other phoneme info
ZPhoneme::ZPhoneme(istream& zs )
{
  char line[255];
  while(zs.getline(line,sizeof(line)))
	 {
		int pos=0;
		
		// Check if it's a comment
		sscanf(line," ##%n",&pos);
		if (pos==0)
		  {
			 double avg;
			 double std;
			 char phonename[255];
			 
			 // Skip empty lines or non conform ones
			 if (sscanf(line," %s %lf %lf %n", phonename, &avg, &std, &pos) == 3)
				{
				  ZPhone zf;
				  zf.zratio=Zratio(avg,std);
				  zf.flags= &line[pos];
				  insert( ZPhoneme::value_type(Phoneme(phonename),zf) );
				}
		  }
	 }
}
コード例 #6
0
/*
 *   Function to read one row from the input stream.
 */
void TZipCodeInputRow::Load(istream &file)
{
    char buf[1024];
    file.getline(buf, sizeof(buf));
    if (file.eof()) {
        return;
    }
    int rc = sscanf(buf, "%d\t%[^\t]\t%[^\t]\t%[^\n]",
            &iDivisionTaxKey, ZC_CODE, ZC_TOWN, ZC_DIV);
    if (rc != 4) {
        std::ostringstream strm;
        strm << "TZipCodeInputRow::Load only loaded " << rc << " values from line";
        throw std::runtime_error(strm.str());
    }
#if 0
    file>>ws;
    file>>iDivisionTaxKey;
    file>>ws;
    file.get( ZC_CODE, sizeof( ZC_CODE ), '\t' );
    file>>ws;
    file.get( ZC_TOWN, sizeof( ZC_TOWN ), '\t' );   //read up to the delimiter
    file>>ws;
    file.get( ZC_DIV, sizeof( ZC_DIV ), '\n' );
#endif
}
コード例 #7
0
ファイル: predict.cpp プロジェクト: awarrior/mySVM
void read_input(istream& input_stream, char* filename){
  // returns number of examples sets read
  char* s = new char[MAXCHAR];
  char next;
  next = input_stream.peek();
  if(next == EOF){ 
    // set stream to eof
    next = input_stream.get(); 
  };
  while(! input_stream.eof()){
    if('#' == next){
      // ignore comment
      input_stream.getline(s,MAXCHAR);
    }
    else if('\n' == next){
      // ignore newline
      next = input_stream.get();
    }
    else if('@' == next){
      // new section
      input_stream >> s;
      if(0==strcmp("@parameters",s)){
	// read parameters
	if(parameters == 0){
	  parameters = new parameters_c();
	  input_stream >> *parameters;
	}
	else{
	  cout <<"*** ERROR: Parameters multiply defined"<<endl;
	  throw input_exception();
	};
      }
コード例 #8
0
ファイル: getarg.cpp プロジェクト: electricFeel/BeatKeeperHRM
string getSLine(istream &str)
{ char line[1024];
  str.getline(line, 1024);
  if (str.gcount()==1024-1)
    raiseError("line too long");
  return line;
}
コード例 #9
0
ファイル: util.cpp プロジェクト: shyamjvs/cs626_project
int parseline(istream& inp, int Order,ngram& ng,float& prob,float& bow)
{

  const char* words[1+ LMTMAXLEV + 1 + 1];
  int howmany;
  char line[MAX_LINE];

  inp.getline(line,MAX_LINE);
  if (strlen(line)==MAX_LINE-1) {
    cerr << "parseline: input line exceed MAXLINE ("
         << MAX_LINE << ") chars " << line << "\n";
    exit(1);
  }

  howmany = parseWords(line, words, Order + 3);

  if (!(howmany == (Order+ 1) || howmany == (Order + 2)))
    assert(howmany == (Order+ 1) || howmany == (Order + 2));

  //read words
  ng.size=0;
  for (int i=1; i<=Order; i++)
    ng.pushw(strcmp(words[i],"<unk>")?words[i]:ng.dict->OOV());

  //read logprob/code and logbow/code
  assert(sscanf(words[0],"%f",&prob));
  if (howmany==(Order+2))
    assert(sscanf(words[Order+1],"%f",&bow));
  else
    bow=0.0; //this is log10prob=0 for implicit backoff

  return 1;
}
コード例 #10
0
void extractParams(istream& stream, vector<string>& params)
{
	char line[400];					// space for a line

	params.clear();					// reset the params
	stream.getline(line, 400);		// read a full line
	string loadLine = line;			// line for tokenizing
	int commaPos, prevPos = 0;		// position of commas
	
	do
	{
		commaPos = loadLine.find(',', prevPos);			// find next comman position

		// extract from previous comma to current comma as one string
		string param = loadLine.substr(prevPos, commaPos==string::npos ? commaPos : commaPos-prevPos);
		
		// trim the string (no white space before or after)
		param = trim(param);

		// include the param in result
		params.push_back(param);

		prevPos = commaPos+1;
	}
	while (commaPos != string::npos);
}
コード例 #11
0
// Parte un fichero en varios
void partir(istream & entrada, char *nombreFichero, int lineas) {

    // Atributos
    ofstream fileSalida;
    ofstream fileControl;

    string nomFicheroCtrl = "." + string(nombreFichero) + ".ctrl";

    int num_ficheros = 0;
    int num_linea = 0;
    
    const int BUFF_SIZE = 500;
    char linea[BUFF_SIZE];

    // Recorremos las lineas
    while (entrada.getline(linea, BUFF_SIZE)) {

        // Incrementamos el contador
        num_linea++;

        // Si hemos sobrepasado las lineas maximas...
        if (num_linea >= lineas) {
            num_linea = 0; //Reseteamos el numero de lineas
            num_ficheros++;
            fileSalida.close(); // Cerramos el archivo
            string nomFichero = string(nombreFichero) + "_" + to_string(num_ficheros) ;

            // Abrimos otro archivo
            fileSalida.open (nomFichero);
            if (!fileSalida) {
                cerr << "Error: no puedo crear el fichero " << nomFichero << endl;
                exit(1); // Salimos con error
            }


        }

        // Escribimos la linea
        fileSalida << linea << endl;


    }

    // Cerramos el archivo
    fileSalida.close();
    

    // Creamos el fichero de control, lo escribimos y lo cerramos
    fileControl.open (nomFicheroCtrl);
    if (!fileControl) {
        cerr << "Error: no puedo crear el fichero de control" << endl;
        exit(1); // Salimos con error
    }
    fileControl << nombreFichero << endl;
    fileControl << num_ficheros << endl;

    fileControl.close();

}
コード例 #12
0
void Monster::load(istream &in) {
    Unit::load(in);
        
    char buf[MAX_LEN_BUF];
    
    //out << "#-------------------- class Monster" << endl;
    in.getline(buf, MAX_LEN_BUF); // skip comment
}
コード例 #13
0
//extends fstream::getline with check on exceeding the buffer size
std::streamsize getLineExt(istream& fin, char* buf)
{
    fin.getline(buf, LINE_LEN);
    std::streamsize bufLen = fin.gcount();
    if(bufLen == LINE_LEN - 1)
        throw LONG_LINE_ERR;
    return bufLen;
}
コード例 #14
0
ファイル: motif.cpp プロジェクト: rakarnik/scanmot
void Motif::read(istream& motin) {
	char line[200];
	vector<int> c;
	vector<int> p;
	vector<bool> s;
	
	// Read sites
	// (don't add yet, as they will get screwed up by the column changes)
	while(motin.getline(line, 200)) {
		if(line[0] == '*') break;
		strtok(line, "\t");
		c.push_back(atoi(strtok(NULL, "\t")));
		p.push_back(atoi(strtok(NULL, "\t")));
		s.push_back(atoi(strtok(NULL, "\0")));
	}
	
	int motwidth = strlen(line);
	columns.clear();
	for(int i = 0; i < motwidth; i++) {
		if(line[i] == '*') add_col(i);
	}
	
	// Add sites
	sitelist.clear();
	int num_sites = c.size();
	for(int i = 0; i < num_sites; i++) {
		assert(p[i] >= 0);
		add_site(c[i], p[i], s[i]);
	}
	
	// Read MAP score
	motin.getline(line, 200);
	strtok(line, ":");
	set_map(atof(strtok(NULL, "\0")));
	
	// Read specificity
	motin.getline(line, 200);
	strtok(line, ":");
	set_spec(atof(strtok(NULL, "\0")));
	
	// Read sequence cutoff
	motin.getline(line, 200);
	strtok(line, ":");
	set_seq_cutoff(atof(strtok(NULL, "\0")));
	
	// Read expression cutoff
	motin.getline(line, 200);
	strtok(line, ":");
	set_expr_cutoff(atof(strtok(NULL, "\0")));
	
	// Read iteration found
	motin.getline(line, 200);
	strtok(line, ":");
	set_iter(strtok(NULL, "\0"));
	
	// Read dejavu
	motin.getline(line, 200);
	strtok(line, ":");
	set_dejavu(atoi(strtok(NULL, "\0")));
}
コード例 #15
0
ファイル: UT_String.cpp プロジェクト: ptierney/inc
std::string utGetTokenInStream(istream & stream, int maxLength, char delimiter)
{
	assert(maxLength <= 1024);

	char StringBuffer[1024];
	eatwhite(stream);
	stream.getline(StringBuffer, maxLength, delimiter);
	return StringBuffer;
}
コード例 #16
0
/***
IMP::
maze:
- It must have odd number of lines.
- Each line in the input must have odd number of characters and all lines must have the same length.
- Finally, it has to be a valid maze in the sense that all rooms are connected.
  Once you convert an input into a maze, the size of the maze must be within the limits of the mazegen command.

*/
void readFile(istream& in) {


    char* buf = new char[MAXBUFSIZE];
    in.getline(buf,MAXBUFSIZE);
    int linelength = strlen(buf);
    while (!in.eof()) {

#ifdef DEBUG1
        fprintf(stdout,"line read: %s\n",buf);
#endif

        strcpy(linebuf[linebufcount++],buf);
        in.getline(buf,MAXBUFSIZE);
        int len = strlen(buf);
        if(!in.eof()) {
            if(linelength!=len) {
                fprintf(stderr,"(malformed input file)-Not all lines are of the same length in input file %d != %d\n",linelength,len);
                exit(-1);
            }
        }
    }
#ifdef DEBUG1
    fprintf(stdout,"EOF REACHED\n");
#endif


    if(linebufcount%2==0) {
        fprintf(stderr,"(malformed input file): even number of lines found\n");
        exit(-1);
    }

    if(linebufcount==1) {
        fprintf(stderr,"(malformed input file): just one line found in input\n");
        exit(-1);
    }

    int widthtest = strlen(linebuf[0]);
    if(widthtest%2==0) {
        fprintf(stderr, "(malformed input file):even number of characters found on the input line\n");
        exit(-1);
    }
    updateheightwidth();
}
コード例 #17
0
ファイル: testfp.C プロジェクト: tripleee/la-strings
static void newuser_command(ostream &out, istream &in)
{
   if (get_access_level() < ADMIN_ACCESS_LEVEL)
      {
      cout << "You must be logged in with administrator privileges\n"
	      "(access level " << ADMIN_ACCESS_LEVEL
	    << " or higher) to add users." << endl ;
      return ;
      }
   char username[200] ;
   char password[200] ;
   FrObject *ulevel ;
   int level ;

   out << "New user's name: " << flush ;
   in.ignore(1000,'\n') ;
   in.getline(username,sizeof(username)) ;
   out << "New password: "******"User's access level: " << flush ;
   in >> ulevel ;
   if (ulevel && ulevel->numberp())
      {
      level = ulevel->intValue() ;
      if (level < GUEST_ACCESS_LEVEL)
	 level = GUEST_ACCESS_LEVEL ;
      else if (level > ROOT_ACCESS_LEVEL)
	 level = ROOT_ACCESS_LEVEL ;
      }
   else
      level = GUEST_ACCESS_LEVEL ;
   FrStruct *userinfo = retrieve_userinfo(username) ;
   if (userinfo)
      {
      cout << "That user is already registered!" ;
      return ;
      }
   userinfo = make_userinfo(username,password,level) ;
   if (update_user(userinfo))
      cout << "User information file updated." << endl ;
   else
      cout << "User information file update failed!" << endl ;
   return ;
}
コード例 #18
0
ファイル: ossimDblGrid.cpp プロジェクト: LucHermitte/ossim
//*****************************************************************************
//  METHOD: ossimDblGrid::load()
//  
//  Loads the grid from the stream in compact ASCII format (not necessarily
//  human readable).
//  
//*****************************************************************************
bool ossimDblGrid::load(istream& is)
{
   static const char MODULE[] = "ossimDblGrid::load()";
   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entering...\n";

   char strbuf[128];

   //***
   // Read magic number tag to insure it is an ossimDblGrid record:
   //***
   is >> strbuf;
   if (std::strncmp(strbuf, MAGIC_NUMBER.c_str(), MAGIC_NUMBER.length()))
   {
      ossimNotify(ossimNotifyLevel_FATAL) << MODULE << "Error reading OSSIM_DBL_GRID magic number from stream. "
         << "Aborting...\n";
      return false;
   }
   is.getline(strbuf, 128, '\n');
   theSize           = ossimDpt(0,0);
   theOrigin         = ossimDpt(0,0);
   theSpacing        = ossimDpt(0,0);
   theMinValue       = OSSIM_DEFAULT_MAX_PIX_DOUBLE;
   theMaxValue       =  OSSIM_DEFAULT_MIN_PIX_DOUBLE;
  // theNullValue      = theNullValue;
   theMeanIsComputed = false;


   //***
   // Read the grid size, origin, and spacing:
   //***
   ossimIpt size;
   ossimDpt origin, spacing;
   double null_value;
   is >> size.x 
      >> size.y 
      >> origin.u 
      >> origin.v 
      >> spacing.u
      >> spacing.v
      >> null_value;

   initialize(size, origin, spacing, null_value);

   //***
   // Loop to read grid points:
   //***
   int max_index = theSize.x*theSize.y;
   for (int i=0; i<max_index; i++)
   {
      is >> theGridData[i];
   }

   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " returning...\n";

   return true;
}
コード例 #19
0
ファイル: lmccore.cpp プロジェクト: yagshi/lmcdev
void parseLMC(istream &ifs, cv::Point3d &qrPos, vector<cv::Point3d> &obj, string &rotOrder, double rotAngle[]) {
  char buf[1024];
  double len;

  while (ifs){
    ifs.getline(buf, 1024);
    char *ptr = skipWhiteSpace(buf);
    if (*ptr == 0) continue;
    if (strncmp("pos:", ptr, 4) == 0) {
      // 中心座標読み込み
      ptr += strlen("pos:");
      qrPos.x = atof(ptr);
      ptr = skipWhiteSpace(skipTo(ptr, ',') + 1);
      qrPos.y = atof(ptr);
      ptr = skipWhiteSpace(skipTo(ptr, ',') + 1);
      qrPos.z = atof(ptr);
      continue;
    }
    if ((tolower(*ptr) == 'x' || tolower(*ptr) == 'y' || tolower(*ptr) == 'z')
	&& ((tolower(*(ptr + 1)) == 'x'
	     || tolower(*(ptr + 1)) == 'y'
	     || tolower(*(ptr + 1)) == 'z'))
	&& ((tolower(*(ptr + 2)) == 'x'
	     || tolower(*(ptr + 2)) == 'y'
	     || tolower(*(ptr + 2)) == 'z'))) {
      // オイラー角読み込み
      rotOrder += tolower(*ptr);
      rotOrder += tolower(*(ptr + 1));
      rotOrder += tolower(*(ptr + 2));
      ptr = skipWhiteSpace(skipTo(ptr, ':') + 1);
      rotAngle[0] = atof(ptr);
      ptr = skipWhiteSpace(skipTo(ptr, ',') + 1);
      rotAngle[1] = atof(ptr);
      ptr = skipWhiteSpace(skipTo(ptr, ',') + 1);
      rotAngle[2] = atof(ptr);
      continue;
    }
    if (strncmp("len:", ptr, 4) == 0) {
      // サイズ読み込み
      len = atof(ptr + 4);
      continue;
    }
  }
  obj[0].x = len / 2;
  obj[0].y = len / 2;
  obj[0].z = 0;
  obj[1].x = len / 2;
  obj[1].y = -len / 2;
  obj[1].z = 0;
  obj[2].x = -len / 2;
  obj[2].y = len / 2;
  obj[2].z = 0;
  obj[3].x = -len / 2;
  obj[3].y = -len / 2;
  obj[3].z = 0;
}
コード例 #20
0
ファイル: sort.cpp プロジェクト: chetanankola/AlgorithmsCode
/*
 * Begin code I did not write.
 * This code is partly derived from http://merlot.usc.edu/cs570-f11/homeworks/prog-faq/#cpp_process
 * If the source code requires you to include copyright, put copyright here.
 */
void Process(istream& in) {
	int count = 0;
	char* buf = new char[MAXBUFSIZE];
	in.getline(buf,MAXBUFSIZE);
	if(strlen(buf)==0) {
		fprintf(stderr,"Input/File is empty\n");
		exit(-1);
	}
	
	My570List *list=new My570List();				///< CREATING LIST to push all the struct elems 
	while (!in.eof()) {
		count++;									///< Count all records
		struct record *temp_str;					///< Create record pointer
		temp_str = isRecordOk(buf,count);			///< Validate BUFFER and get back record
		//(void)list->Append((void*)temp_str);		///< Push records into the LIST unsorted
		SortedInsert(list,temp_str);				///< push records into the list in a sorted manner
		#ifdef DEBUG1
		fprintf(stdout,"%s %d %0.2f %s\n",temp_str->sign,temp_str->timestamp,temp_str->amount,temp_str->description); ///< display record
		#endif		
		
		#ifdef DEBUG1
			fprintf(stdout,"%s\n",buf);				///< PRINT THE RAW BUFFER
		#endif 
		in.getline(buf,MAXBUFSIZE);					///< GET THE NEXT LINE
	}
	
	#ifdef DEBUG0
	fprintf(stdout,"*******************SORTED DISPLAY*******************\n");
	displayRecords(list);							///< DISPLAY THE RECORDS from list
	#endif
	
	
	tableDisplay(list);								///< DISPLAY FORMATTED OUTPUT!!!! THIS WILL GIVE ME MARKS !!!! :--/ @#@!#!
	
	#ifdef DEBUG1
		fprintf(stdout,"EOF REACHED\n");
	#endif
	
	#ifdef DEBUG0
		fprintf(stdout,"total number of records processed = %d\n",count);
	#endif
	
}
コード例 #21
0
ファイル: arpa_slm.cpp プロジェクト: WilliamRen/sunpinyin
void
CArpaSlm::TNode::load_level0(istream& is)
{
    hw[0] = 0;
    char buf[1024];
    is.getline(buf, sizeof(buf));
    sscanf(buf, "%f %f (%1u, %u)",
           &pr, &bow, &bol, &bon);
    wid = 0;
}
コード例 #22
0
void Boss::load(istream &in) {
    Monster::load(in);
        
    char buf[MAX_LEN_BUF];
    
    //out << "#-------------------- class Boss" << endl;
    in.getline(buf, MAX_LEN_BUF); // skip comment
    
//    path = false;
//    numPath = 0;
//    curPathIndex = 0;
    pathAStar = NULL;
    
    //out << "# range" << endl;
    in.getline(buf, MAX_LEN_BUF); // skip comment
    //out << range << endl;
    in >> range;
    in.get(); // skip enter code.
}
コード例 #23
0
ファイル: types.cpp プロジェクト: yueying/osg
    // Parse 'Material'
    void parseMaterial(istream & fin, Material & material)
    {
        char buf[256];
        vector<string> token;

        unsigned int i = 0;

        //cerr << "*** Material\n";
        while (fin.getline(buf, sizeof(buf))) {

            // Tokenize
            token.clear();
            tokenize(buf, token);
            if (token.size() == 0)
                continue;
            if (token[0] == "}")
                break;
            if (token[0] == "TextureFilename") {
                TextureFilename tf;
                readTexFilename(fin, tf);
                material.texture.push_back(tf);
                //cerr << "* num tex=" << material.texture.size() << endl;
            } else {
                switch (i) {
                    case 0: {
                                // ColorRGBA
                                material.faceColor.red = osg::asciiToFloat(token[0].c_str());
                                material.faceColor.green = osg::asciiToFloat(token[1].c_str());
                                material.faceColor.blue = osg::asciiToFloat(token[2].c_str());
                                material.faceColor.alpha = osg::asciiToFloat(token[3].c_str());
                                i++;
                            } break;
                    case 1: {
                                // Power
                                material.power = osg::asciiToFloat(token[0].c_str());
                                i++;
                            } break;
                    case 2: {
                                // ColorRGB
                                material.specularColor.red = osg::asciiToFloat(token[0].c_str());
                                material.specularColor.green = osg::asciiToFloat(token[1].c_str());
                                material.specularColor.blue = osg::asciiToFloat(token[2].c_str());
                                i++;
                            } break;
                    case 3: {
                                // ColorRGB
                                material.emissiveColor.red = osg::asciiToFloat(token[0].c_str());
                                material.emissiveColor.green = osg::asciiToFloat(token[1].c_str());
                                material.emissiveColor.blue = osg::asciiToFloat(token[2].c_str());
                                i++;
                            } break;
                }
            }
        }
    }
コード例 #24
0
ファイル: unit.cpp プロジェクト: changyook21/Classic-RPG-game
void Merchant::load(istream &in) {
    Unit::load(in);
        
    char buf[MAX_LEN_BUF];
    
    //out << "#-------------------- class Merchant" << endl;
    in.getline(buf, MAX_LEN_BUF); // skip comment
    
    itemsToSell->load(in);
    itemsBought->load(in);
}
コード例 #25
0
ファイル: arpa_slm.cpp プロジェクト: WilliamRen/sunpinyin
void
CArpaSlm::TNode::load(istream& is, const TLexicon& lexicon)
{
    char buf[1024];
    is.getline(buf, sizeof(buf));
    char* next = 0;
    char* words = getwords(buf, &next);
    load_words(words, lexicon);
    sscanf(next, "%f %f (%1u, %u)",
           &pr, &bow, &bol, &bon);
}
コード例 #26
0
ファイル: kfm.cpp プロジェクト: europop/morrgraphext
unsigned int Kfm::Read( istream & in ) {
    //--Read Header--//
    char header_string[64];
    in.getline( header_string, 64 );
    string headerstr(header_string);

    // make sure this is a KFM file
    if ( headerstr.substr(0, 26) != ";Gamebryo KFM File Version" ) {
        version = VER_INVALID;
        return version;
    };

    // supported versions
    if ( headerstr == ";Gamebryo KFM File Version 2.0.0.0b" ) version = VER_KFM_2_0_0_0b;
    else if ( headerstr == ";Gamebryo KFM File Version 1.2.4b" ) version = VER_KFM_1_2_4b;
    //else if ( headerstr == ";Gamebryo KFM File Version 1.0" ) version = VER_KFM_1_0;
    //else if ( headerstr == ";Gamebryo KFM File Version 1.0\r" ) version = VER_KFM_1_0; // Windows eol style
    else {
        version = VER_UNSUPPORTED;
        return version;
    };

    //--Read remainder--//
    if (version == VER_KFM_1_0) {
        // TODO write a parser
    } else {
        if (version >= VER_KFM_2_0_0_0b) unk_byte = ReadByte(in);
        else unk_byte = 1;
        nif_filename = ReadString(in);
        master = ReadString(in);
        unk_int1 = ReadUInt(in);
        unk_int2 = ReadUInt(in);
        unk_float1 = ReadFloat(in);
        unk_float2 = ReadFloat(in);
        actions.resize(ReadUInt(in));
        unk_int3 = ReadUInt(in);
        for ( vector<KfmAction>::iterator it = actions.begin(); it != actions.end(); it++ ) it->Read(in, version);
    };

    // Retrieve action names
    if ( version >= VER_KFM_2_0_0_0b ) {
        string model_name = nif_filename.substr(0, nif_filename.length()-4); // strip .nif extension
        for ( vector<KfmAction>::iterator it = actions.begin(); it != actions.end(); it++ ) {
            string action_name = it->action_filename.substr(0, it->action_filename.length()-3); // strip .kf extension
            if (action_name.find( model_name + "_" ) == 0)
                action_name = action_name.substr(model_name.length() + 1, string::npos);
            if (action_name.find( master + "_" ) == 0)
                action_name = action_name.substr(master.length() + 1, string::npos);
            it->action_name = action_name;
        };
    };

    return version;
};
コード例 #27
0
ファイル: GameField.cpp プロジェクト: jiwaharlal/RunningMan
void
GameField::populateFromStream(istream& in)
{
    char buffer[128];
    in.getline(buffer, 128);
    Size size = readSize(buffer);
    myHeight = size.height;
    myWidth = size.width;
    myCells.resize(myHeight);

    for ( auto cellsRow = myCells.begin(); cellsRow != myCells.end(); ) {
        cellsRow->clear();
        cellsRow->reserve(myWidth);
        for (int i = 0; i < myWidth; i++) {
            in.getline(buffer, 128);
            cellsRow->emplace_back(readCell(buffer));
        }
        ++cellsRow;
    }
}
コード例 #28
0
void _get_data(istream& in, char*& data)
{
   static char buf[LBUFSIZ];
   in.getline(buf, LBUFSIZ);

   if ( buf[0] != 'd' || buf[1] != '\t' ) {
       debug(cerr, buf);
     throw(stringException("_get_data(): missing d\t"));
   }

   data = buf + 2;
}
コード例 #29
0
void _get_key(istream& in, char*& key)
{
   static char buf[LBUFSIZ];
   in.getline(buf, LBUFSIZ);

   if ( buf[0] != 'k' || buf[1] != '\t' ) {
       debug(cerr, buf);
     throw(stringException("_get_key(): missing k\t"));
   }

   key = buf + 2;
}
コード例 #30
0
ファイル: TabTable.C プロジェクト: Starlink/skycat
/*
 * static method: 
 * read the heading info from the given stream and put it in the given object
 */
int TabTable::head(istream& is, TabTable& t)
{
    ostringstream os;
    char buf[MAX_HEADER_SIZE];
    while (is.getline(buf, sizeof(buf))) {
	os << buf << endl;
	if (buf[0] == '-') 
	    break;
    }
    int status = t.init(os.str().c_str());
    return status;
}