Beispiel #1
0
/*===========================================================================*/
bool MeshData::read_element( std::string& line, std::ifstream& ifs )
{
    m_element_type = ElementTypeUnknown;
    {
        std::istringstream line_stream( line );
        std::string svalue;

        // !ELEMENT
        if ( !std::getline( line_stream, svalue, ',' ) ) return false;

        // Reading element type.
        while ( std::getline( line_stream, svalue, ',' ) )
        {
            // Trim whitespace.
            svalue.erase( 0, svalue.find_first_not_of(" ") );

            kvs::Tokenizer t( svalue, "=");
            const std::string name = t.token();
            if ( name == "TYPE" )
            {
                const int element_type = atoi( t.token().c_str() );
                m_element_type = ::GetElementType( element_type );
            }
        }
    }

    size_t counter = 0;
    std::vector<kvs::UInt32> connections;
    const size_t nnodes_per_cell = ::NumberOfNodes[m_element_type];
    while ( std::getline( ifs, line ) )
    {
        if ( line.size() > 2 ) if ( line[0] == '!' && line[1] != '!' ) break;

        std::istringstream line_stream( line );
        std::string svalue;

        // element ID
        if ( !std::getline( line_stream, svalue, ',' ) ) return false;

        // Reading connections.
        for ( size_t i = 0; i < nnodes_per_cell; i++ )
        {
            std::getline( line_stream, svalue, ',' );

            const kvs::UInt32 value = static_cast<kvs::UInt32>( atoi( svalue.c_str() ) - 1 );
            connections.push_back( value );
        }

        // Adjust connections for KVS.
        kvs::UInt32* c = &(connections[ nnodes_per_cell * counter ]);
        this->adjust_connection( c );

        counter++;
    }

    m_ncells = counter;
    m_connections = kvs::ValueArray<kvs::UInt32>( connections );

    return true;
}
typename std::vector<TPointType> ReadLandmarkFile(std::string landmarkFilename){
	std::vector<TPointType> pointVector;
	
	const unsigned int x=0, y=1, z=2;
	double p[3];
	
	std::ifstream infile;
	infile.open( landmarkFilename.c_str() ); // ASCII mode
	std::string line;
	while(std::getline(infile, line)){	
		std::stringstream line_stream(line);
		if(!(line_stream >> p[x] && line_stream >> p[y] && line_stream >> p[z])){
			std::stringstream error_message;
			error_message << "ReadLandmarkFile: landmark file is corrupt (filename " << landmarkFilename << ")." << std::endl;
			throw error_message.str();
		}

		TPointType point;
		for(unsigned i=0; i<VImageDimension; i++){
			point[i] = p[i]; 
		}
		pointVector.push_back(point);
	}
	infile.close();

	return pointVector;
}
Beispiel #3
0
std::vector<imputed_info>
parse_info(const std::string &path)
{
    std::ifstream stream( path.c_str( ) );

    std::vector<imputed_info> info_list;
    std::string line;
    
    /* Ignore header */
    std::getline( stream, line );
    while( std::getline( stream, line ) )
    {
        std::string tmp;
        std::istringstream line_stream( line );

        imputed_info info;
        
        line_stream >> tmp;
        line_stream >> info.name;
        line_stream >> info.pos;
        line_stream >> info.maf;
        line_stream >> info.info;

        info_list.push_back( info );
    }

    return info_list;
}
void MapStorage::loadWalls(std::string fn, double thickness)
{
    std::ifstream ifs(fn);
    assert(ifs.is_open());

    std::string line;
    int wall_id = 0;
    while (getline(ifs, line)){

        if (line[0] == '#') {
            // comment -> skip
            continue;
        }

        double max_num = std::numeric_limits<double>::max();
        double x1= max_num,
               x2= max_num,
               y1= max_num,
               y2= max_num;

        std::istringstream line_stream(line);

        line_stream >> x1 >> y1 >> x2 >> y2;

        if ((x1 == max_num) || ( x2 == max_num) || (y1 == max_num) || (y2 == max_num)){
            ROS_WARN("Segment error. Skipping line: %s",line.c_str());
            continue;
        }

        stackWall(x1, y1, x2, y2, thickness);
        wall_id++;
    }
    ROS_INFO_STREAM("Read "<<wall_id<<" walls from map file.");
}
Beispiel #5
0
std::vector<std::string>
parse_sample(const std::string &path)
{
    std::ifstream stream( path.c_str( ) );
    std::vector<std::string> sample_list;
    std::string line;
    
    /* Ignore header lines */
    std::getline( stream, line );
    std::getline( stream, line );

    while( std::getline( stream, line ) )
    {
        std::string fid;
        std::string iid;
        std::istringstream line_stream( line );

        line_stream >> fid;
        line_stream >> iid;

        sample_list.push_back( iid );
    }

    return sample_list;
}
Beispiel #6
0
/*===========================================================================*/
bool MeshData::read_node( std::string& line, std::ifstream& ifs )
{
    size_t counter = 0;
    std::vector<kvs::Real32> coords;
    while ( std::getline( ifs, line ) )
    {
        if ( line.size() > 2 ) if ( line[0] == '!' && line[1] != '!' ) break;

        std::istringstream line_stream( line );
        std::string svalue;

        // node ID (skip)
        if ( !std::getline( line_stream, svalue, ',' ) ) return false;

        // x, y, z
        while ( std::getline( line_stream, svalue, ',' ) )
        {
            const kvs::Real32 value = static_cast<kvs::Real32>( atof( svalue.c_str() ) );
            coords.push_back( value );
        }

        counter++;
    }

    m_nnodes = counter;
    m_coords = kvs::ValueArray<kvs::Real32>( coords );

    return true;
}
Beispiel #7
0
void Stdout_Worker::run() {
    std::cerr << "Waiting:" << std::endl;
#ifdef PROFILE
    //ProfilerStart("zmq_worker.log");
    HeapProfilerStart("worker_heap_2.log");
#endif
    std::string line;
    unsigned x, y;
    int z;
    while(std::getline(std::cin, line)) {
        std::istringstream line_stream(line);
        //std::cerr << "LINE:" << line << std::endl;
        if (line_stream.get() == '[') {
          line_stream >> x;
          line_stream >> y;
          line_stream >> z;
          auto tileData = this->tileReader.get_tile(z, x, y);
#ifdef PROFILE
          if (this->received_tiles%50==0) {
            HeapProfilerDump("TileRead");
          }
#endif
          this->received_tiles++;
          if (tileData) {
              //std::cerr << " Found tile" << std::endl;
              map(std::move(tileData));
          } else{
              send(0);
          }
        }
    }
text_generator::text_generator(std::string input_file)
    : words_number(0)
{
    std::ifstream input_stream(input_file.c_str());
    std::string line;
    const char space_delimeter = ' ';
    while (getline(input_stream, line)) {
        std::istringstream line_stream(line);
        std::string word;
        while (getline(line_stream, word, space_delimeter)) {
            word.erase(std::remove_if(word.begin(), word.end(),
                                      [](char c)
                                      { return std::ispunct(c) || !std::isprint(c); }),
                       word.end());
            if (word.length()) {
                std::map<std::string, long long>::iterator it = words_frequency.find(word);
                if (it != words_frequency.end()) {
                    it->second++;
                }
                else {
                    words_frequency.insert(std::pair<std::string, long long>(word, 1));
                }
                words_number++;
            }
        }
    }
    double cur_border = 0;
    for (auto &map_entry : words_frequency) {
        std::string word = map_entry.first;
        long long frequency = map_entry.second;
        double probability = ((double) frequency) / words_number;
        words_probability.insert(std::pair<double, std::string>(cur_border + probability, word));
        cur_border += probability;
    }
}
Beispiel #9
0
static bool CheckCPUFeature(const std::string& feature)
{
	const std::string marker = "Features\t: ";

	std::string line;
	std::ifstream file(procfile);

	if (!file)
		return 0;

	while (std::getline(file, line))
	{
		if (line.find(marker) != std::string::npos)
		{
			std::stringstream line_stream(line);
			std::string token;

			while (std::getline(line_stream, token, ' '))
			{
				if (token == feature)
					return true;
			}
		}
	}

	return false;
}
Beispiel #10
0
void ResourceManager::AddMesh( sf::Uint32 id, std::string mesh_file ) {
	std::ifstream file( mesh_file.c_str() );

	if( !file.good() ) {
		LogConsole( "Failed to load Mesh resource " + string_cast( id ) + ", file not good." );
		return;
	}

	std::vector<sf::Vector3f> vertices;
	std::vector<sf::Vector3i> faces;

	std::string line;

	getline( file, line );

	char type;
	sf::Vector3f vertex;
	sf::Vector3i face;

	while( file.good() ) {
		std::stringstream line_stream( line );
		line_stream >> type;

		if( !line_stream.good() ) {
			LogConsole( "Failed to load Mesh resource " + string_cast( id ) + ", line stream not good." );
			return;
		}

		if( type == 'v' ) {
			line_stream >> vertex.x >> vertex.y >> vertex.z;

			vertices.push_back( vertex );
		} else if( type == 'f' ) {
bool LoadDataset(std::string filename, Dataset * dataset){
  // Variable declarations
  std::ifstream infile(filename.c_str());
  std::string line;
  dataset->name = filename;

  // Check if file opened correctly
  if(!infile.is_open()) {
    // Error!
    return false;
  }
  
  // Read file into vector line by line
  while(std::getline(infile,line)) {
    // Break line into tokens
    std::istringstream line_stream(line);
    std::string element;
    // Create vector of tokens
    std::vector<std::string> tokens;
    while(std::getline(line_stream, element, ' ')) {
      tokens.push_back(element);
    }   
    // Reserve space for new elements
    dataset->bytes.reserve(dataset->bytes.size()+tokens.size());
    // Copy data
    for(int i = 0; i < tokens.size(); i++)
      dataset->bytes.push_back(atoi(tokens.at(i).c_str()));
  }

  // Close file and return
  infile.close();
  return true;
}
void convert_matrices(const std::string &in, const std::string &out) {
    std::ifstream in_file(in);
    // TODO check if in file exists
    std::ofstream out_file(out, std::ofstream::trunc);

    std::string line;
    int line_num = 0;

    while (std::getline(in_file, line)) {
        std::istringstream line_stream(line);
        std::stringstream output_stream;

        out_file << line_num << ' ';
        ++line_num;

        bool c;
        int c_num = 0;
        int matches = 0;
        while (line_stream >> c) {
            if (c) {
                ++matches;
                output_stream << ' ' << c_num;
            }
            ++c_num;
        }

        // construct line
        out_file << matches << output_stream.str() << std::endl;
    }

    in_file.close();
    out_file.close();
}
Beispiel #13
0
bool Data::loadFromFileWhitespace(std::ifstream& input_file, std::string header_line) {

  // Read header
  std::string header_token;
  std::stringstream header_line_stream(header_line);
  while (header_line_stream >> header_token) {
    variable_names.push_back(header_token);
  }
  num_cols = variable_names.size();
  num_cols_no_sparse = num_cols;

  // Read body
  reserveMemory();
  bool error = false;
  std::string line;
  size_t row = 0;
  while (getline(input_file, line)) {
    double token;
    std::stringstream line_stream(line);
    size_t column = 0;
    while (line_stream >> token) {
      set(column, row, token, error);
      ++column;
    }
    if (column > num_cols) {
      throw std::runtime_error("Could not open input file. Too many columns in a row.");
    } else if (column < num_cols) {
      throw std::runtime_error("Could not open input file. Too few columns in a row. Are all values numeric?");
    }
    ++row;
  }
  num_rows = row;
  return error;
}
Beispiel #14
0
bool Data::loadFromFileOther(std::ifstream& input_file, std::string header_line, char seperator) {

  // Read header
  std::string header_token;
  std::stringstream header_line_stream(header_line);
  while (getline(header_line_stream, header_token, seperator)) {
    variable_names.push_back(header_token);
  }
  num_cols = variable_names.size();
  num_cols_no_sparse = num_cols;

  // Read body
  reserveMemory();
  bool error = false;
  std::string line;
  size_t row = 0;
  while (getline(input_file, line)) {
    std::string token_string;
    double token;
    std::stringstream line_stream(line);
    size_t column = 0;
    while (getline(line_stream, token_string, seperator)) {
      std::stringstream token_stream(token_string);
      token_stream >> token;
      set(column, row, token, error);
      ++column;
    }
    ++row;
  }
  num_rows = row;
  return error;
}
Beispiel #15
0
imputed_matrix_ptr
parse_genotypes(const std::string &path, float call_rate, const std::vector<std::string> &samples)
{
    std::ifstream stream( path.c_str( ) );
    std::string line;
    
    imputed_matrix_ptr matrix( new std::vector<snp_row>( ) );
    while( std::getline( stream, line ) )
    {
        std::string tmp;
        std::string name;
        unsigned long long pos;
        std::string a1;
        std::string a2;
        float p_AA;
        float p_Aa;
        float p_aa;

        std::istringstream line_stream( line );

        line_stream >> tmp;
        line_stream >> name;
        line_stream >> pos;
        line_stream >> a1;
        line_stream >> a2;

        snp_row row;
        row.resize( samples.size( ) );
        int i = 0;
        while( (line_stream >> p_AA) && (line_stream >> p_Aa) && (line_stream >> p_aa) && i < samples.size( ) )
        {
            if( p_AA > p_Aa && p_AA > p_aa && p_AA > call_rate )
            {
                row.assign( i,  0 );
            }
            else if( p_Aa > p_AA && p_Aa > p_aa && p_Aa > call_rate )
            {
                row.assign( i,  1 );
            }
            else if( p_aa > p_AA && p_aa > p_Aa && p_aa > call_rate )
            {
                row.assign( i,  2 );
            }
            else
            {
                row.assign( i,  3 );
            }
            i++;
        }

        matrix->push_back( row );
    }

    return matrix;
}
Beispiel #16
0
unsigned FibreReader<DIM>::GetTokensAtNextLine()
{
    assert(mTokens.size() == mNumItemsPerLine);

    std::string line;
    bool blank_line;

    do
    {
        getline(mDataFile, line);

        if (line.empty() && mDataFile.eof())
        {
            mDataFile.close();
            std::string error =   "End of file " + mFilePath + " reached. Either file contains fewer "
                                + "definitions than defined in header, or one of the GetNext[..] methods "
                                + "has been called too often";
            EXCEPTION(error);
        }

        // Get rid of any comments
        line = line.substr(0, line.find('#'));

        blank_line = (line.find_first_not_of(" \t",0) == std::string::npos);
    }
    while (blank_line);

    // Get rid of any trailing whitespace
    std::string::iterator iter = line.end();
    iter--;
    unsigned nchars2delete = 0;
    while (*iter == ' ' || *iter == '\t')
    {
        nchars2delete++;
        iter--;
    }
    line.erase(line.length()-nchars2delete);

    std::stringstream line_stream(line);

    unsigned index = 0;
    while (!line_stream.eof())
    {
        double item;
        line_stream >> item;
        if (index >= mNumItemsPerLine)
        {
            EXCEPTION("Too many entries in a line in " + mFilePath);
        }
        mTokens[index++] = item;
    }

    return index; // the number of entries put into mTokens
}
Beispiel #17
0
void CSVReader::read_line(std::ifstream& str) {
    std::string line;
    std::getline(str, line);

    std::stringstream line_stream(line);
    std::string cell;

    _current_line.clear();
    while (std::getline(line_stream, cell, ',')) {
        _current_line.push_back(cell);
    }
}
void
UwTDMA_frame::initializeTopologyS()
{
	topology_index = topology_index ? topology_index : addr;
	ifstream input_file_;
	string line_;
	char *tmp_ = new char[topology_S_file_name_.length() + 1];
	strcpy(tmp_, topology_S_file_name_.c_str());
	input_file_.open(tmp_);
	int slot_number = 0;
	if(tot_slots || tot_nodes) { //initialize the frame again due to frame change
		tot_slots = 0;
		tot_nodes = 0;
		s_.clear();
		my_slot_numbers_.clear();
	}	
	if (input_file_.is_open()) {
		while (std::getline(input_file_, line_)) {
			::std::stringstream line_stream(line_);
			string result_;
			slot_number = 0;
			while (std::getline(
					line_stream, result_, topology_S_token_separator_)) {
				slot_number++;
				int tx_status = atoi(result_.c_str());
				s_[tot_nodes + 1][slot_number] = tx_status;
				if (tot_nodes + 1 == topology_index && tx_status > 0) {
					// cout << "Node " <<addr << "S[" << slot_number << "] = "
					// << tx_status <<endl;
					my_slot_numbers_[slot_number] = tx_status;
				}
				if (!tot_nodes) {
					tot_slots++;
				}
			}
			tot_nodes++;
		}
		// std::cout << NOW << " ID " << addr << " num slots: "
		// <<my_slot_numbers_.size() << std::endl;
	} else {
		cerr << "Impossible to open file " << topology_S_file_name_.c_str() <<
				endl;
	}
	if (debug_) {
		std::cout << NOW << " ID " << addr
				  << ": Topology S initialized, tot_nodes = " << tot_nodes
				  << ", Slots in a frame = " << tot_slots << std::endl;
	}
}
/******************************************************************************
Function:	 Split Strings
Author: 	 Stephanie Athow
Description: 
	Parses a csv file, it will break up a comma sperated line
Parameters:
	in: line		line to break up
	in: delim		character to delineate a break
Returns:
	data_values		a vector of doubles that contains the year, burned acres
					and 12 months of PDSI values
******************************************************************************/
vector<double> split_string( string line, char delim )
{
	vector<double> data_values;				// holds data values to be returned
	stringstream line_stream( line );		// turn into stream to use getline
	string tok;								// holds return from getline
	double val;								// holds double val converted from getline

	while( getline( line_stream, tok, delim ) )
	{
		val = stod( tok );
		data_values.push_back( val );
	}

	return data_values;
}
Beispiel #20
0
TextQuery::TextQuery(std::ifstream &ifs) : input(new StrBlob)
{
    StrBlob::size_type lineNo{0};
    for (string line; std::getline(ifs, line); ++lineNo) {
        input->push_back(line);
        std::istringstream line_stream(line);
        for (string text, word; line_stream >> text; word.clear()) {
            // avoid read a word followed by punctuation(such as: word, )
            std::remove_copy_if(text.begin(), text.end(), std::back_inserter(word), ispunct);
            // use reference avoid count of shared_ptr add. 
            auto &nos = result[word];
            if (!nos) nos.reset(new std::set<StrBlob::size_type>);
            nos->insert(lineNo);
        }
    }
}
Beispiel #21
0
int main() try {
    /* Up to now we've been reading all standard input and then writing
     * everything to standard output.  We could do this again, but we'd much
     * rather be able to enter an expression on a single line and then
     * immediately get the pretty-printed version.
     */

    // We need a variable to store the current line in.
    std::string line;

    // This extracts a line from std::cin into line, and then returns std::cin
    // so that we can check whether we've hit the end of file yet or not.
    while (std::getline(std::cin, line)) {
        // We now have a string that we would like to parse, but our parser
        // expects an std::istream&.  Fortunately, the standard library has an
        // std::istringstream class that can be treated as an istream, and
        // allows us to store an arbitrary string in it.
        std::istringstream line_stream(line);

        // We could just call parse_and_reprint_expression, but that would
        // terminate the program if the expression was invalid.
        //
        // Recall the semantics of an exception.  A throw indicates that the
        // program has entered an invalid state, and a catch sets it back into a
        // valid state it can continue from.  If it wasn't possible to parse a
        // line of input, we can just notify the user of this and then continue
        // with the next line, so we add a catch and do exactly that.
        try {
            parse_and_reprint_expression(line_stream);
        }
        catch (std::exception& e) {
            // Notice that we're catching more than strictly necessary here.
            // We're almost at the point where this can be fixed.
            std::cerr << e.what() << "\n";
        }
    }
}
catch (std::exception& e) {
    std::cerr << "Error: " << e.what() << "\n";
    return -1;
}
catch (...) {
    std::cerr << "Unknown error.\n";
    return -1;
}
void FFM::avito_init_params(const std::string & data_conf_path)
{
    bool debug = false;

    std::ifstream config_stream((char*)data_conf_path.c_str(), std::ios::in);

    std::string line;
    std::string token;
    std::string header;

    // Read header:
    for(unsigned int i = 0; i < 8; i++){
      getline(config_stream, line);
    }

    std::istringstream line_stream(line);
    while(line_stream){	if (!getline( line_stream, token, ':' )) break;	}
    if(debug) std::cout << "Default hash: " << token << std::endl;

    bool useDefaultHash = ( token != "false" ) ? true : false;
    if ( useDefaultHash ){
      num_features = atoi(token.c_str());
    }

    getline(config_stream, line);
    getline(config_stream, line);

    unsigned int feature_count = 0;
    while(getline(config_stream, line)){
      std::istringstream hash_stream(line);
      getline( hash_stream, header, ':' );
      getline( hash_stream, token, ':' );
      
      num_fields++;
      if ( !useDefaultHash ) {
	num_features += atoi(token.c_str());
      }
      if(debug) std::cout << header << ": " << token << " Current inputDim: " << num_features << std::endl;
      feature_count++;
    }

    if(debug) std::cout << "Num-features: " << num_features << std::endl;
    
    initParams();    
}
void HeartGeometryInformation<SPACE_DIM>::ProcessLine(
        const std::string& line,
        std::set<unsigned>& rSurfaceNodeIndexSet,
        unsigned offset) const
{
    std::stringstream line_stream(line);
    while (!line_stream.eof())
    {
        unsigned item;
        line_stream >> item;
        // If offset==1 then shift the nodes, since we are assuming MEMFEM format (numbered from 1 on)
        if (item == 0 && offset != 0)
        {
            EXCEPTION("Error when reading surface file.  It was assumed not to be indexed from zero, but zero appeared in the list.");
        }
        rSurfaceNodeIndexSet.insert(item-offset);
    }
}
Beispiel #24
0
void loadDoubleVectorFromFile(std::vector<double>& result, std::string filename) {

  // Open input file
  std::ifstream input_file;
  input_file.open(filename);
  if (!input_file.good()) {
    throw std::runtime_error("Could not open file: " + filename);
  }

  // Read the first line, ignore the rest
  std::string line;
  getline(input_file, line);
  std::stringstream line_stream(line);
  double token;
  while (line_stream >> token) {
    result.push_back(token);
  }
}
Beispiel #25
0
spool_info::spool_info(std::string spool_info_file) {
  info_file = spool_info_file;
  std::ifstream infile(spool_info_file);

  if (infile) {
    std::string line;

    // The first line is the number of entries
    std::getline(infile, line);
    num_files = stoi(line);

    // The second line is a tab separated list of free ids
    std::getline(infile, line);
    std::istringstream available_ids(line);

    while (std::getline(available_ids, line, '\t'))
      free_ids.push_back(std::stoi(line));

    // The remaining lines are file entries.
    std::string next;
    while (std::getline(infile, line)) {
      std::istringstream line_stream(line);

      std::string name;
      std::getline(line_stream, name, '\t');

      std::string identifier;
      std::getline(line_stream, identifier, '\t');

      std::string owner;
      std::getline(line_stream, owner, '\t');
      uid_t uid = std::stoull(owner);

      files.insert(std::make_pair(identifier, spool_info::file(name, uid)));
    }
  } else if (errno == ENOENT) {
    num_files = 0;
  } else {
    perror("Error");
    exit(1);
  }
}
Beispiel #26
0
bool Sentinel::load_config() {
    std::ifstream config_file(config_path_.c_str());

    if (!config_file.is_open() || config_file.fail())
        return false;
    // split lines of the config file on the ``=`` character, left part becomes
    // the key, right part the value of the config map
    std::string line;
    while (std::getline(config_file, line)) {
        std::istringstream line_stream(line);
        std::string key;
        if (std::getline(line_stream, key, '=')) {
            std::string value;
            if (std::getline(line_stream, value)) {
                config_.insert(std::make_pair(key, value));
            }
        }
    }
    return true;
}
Beispiel #27
0
void Equeue::find_closest_k_stars(stringstream &ss, int k)
{
    priority_queue<Star, vector<Star> > min_queue;
    string line;

    while (std::getline(ss, line))
    {
        stringstream line_stream(line);
        string buf;
        getline(line_stream, buf, ',');

        int id=std::stoi(buf);
        vector<int> data(3);
        for (int i=0; i<3; i++)
        {
            getline(line_stream, buf, ',');
            data[i]=stoi(buf);
        }
        Star t(id, data[0], data[1], data[2]);

        if (min_queue.size()==k)
        {
            Star far_star=min_queue.top();
            if (far_star.distance>t.distance)
            {
                min_queue.pop();
                min_queue.push(t);
            }
        }
        else
            min_queue.push(t);
    }

    while (!min_queue.empty())
    {
        cout << min_queue.top().distance << endl;
        min_queue.pop();
    }

}
Beispiel #28
0
void AnimData::load_properties(const std::string& file_name)
{
    std::ifstream file(file_name + ".anim");
    
    if (!file)
    {
        return;
    }

    for (;;)
    {
        std::string current_line;
        std::getline(file,current_line);

        size_t hashtagpos = current_line.find('#');
        if (hashtagpos != std::string::npos)
        {
            current_line = current_line.substr(0,hashtagpos);
        }

        if (!current_line.empty())
        {
            std::istringstream line_stream(current_line);
            std::string property_name;

            line_stream >> property_name;
            handle_property(property_name,line_stream);
        }

        if (file.eof())
        {
            break;
        }
        else if (file.bad())
        {
            assert(false);
            break;
        }
    }
Beispiel #29
0
void ts::resources::Script_resource::load_resource_config(std::istream& stream)
{
    boost::filesystem::path root_path = root_directory_.string();

    for (std::string line, directive; std::getline(stream, line) && directive != "end";)
    {
        std::istringstream line_stream(line);
        read_directive(line_stream, directive);

        if (directive == "clientscript")
        {
            std::string script_path;
            line_stream >> std::ws;

            if (std::getline(line_stream, script_path))
            {
                auto path = root_path / script_path;

                client_script_files_.push_back(path.string());
            }
        }

        else if (directive == "serverscript")
bool CheckCPUASE(const std::string& ase)
{
	std::string line, marker = "ASEs implemented\t: ";
	std::fstream file;

	if (!File::OpenCPPFile(file, procfile, std::ios::in))
		return 0;
	
	while (std::getline(file, line))
	{
		if (line.find(marker) != std::string::npos)
		{
			std::stringstream line_stream(line);
			std::string token;
			while (std::getline(line_stream, token, ' '))
			{
				if (token == ase)
					return true;
			}
		}
	}
	
	return false;
}