コード例 #1
0
 void process(std::istream& input) {
     if (m_state == hybi_legacy_state::INIT) {
         // we are looking for a 0x00
         if (input.peek() == 0x00) {
             // start a message
             input.ignore();
             
             m_state = hybi_legacy_state::READ;
             
             m_data_message = m_connection.get_data_message();
             
             if (!m_data_message) {
                 throw processor::exception("Out of data messages",processor::error::OUT_OF_MESSAGES);
             }
             
             m_data_message->reset(frame::opcode::TEXT);
         } else {
             input.ignore();
             // TODO: ignore or error
             //std::stringstream foo;
             
             //foo << "invalid character read: |" << input.peek() << "|";
             
             std::cout << "invalid character read: |" << input.peek() << "|" << std::endl;
             
             //throw processor::exception(foo.str(),processor::error::PROTOCOL_VIOLATION);
         }
     } else if (m_state == hybi_legacy_state::READ) {
         if (input.peek() == 0xFF) {
             // end
             input.ignore();
             
             m_state = hybi_legacy_state::DONE;
         } else {
             if (m_data_message) {
                 size_t num;
                 
                 input.get(m_payload_buffer, PAYLOAD_BUFFER_SIZE, 0xFF);
                 
                 num = static_cast<size_t>(input.gcount());
                 
                 if (input.bad()) {
                     throw processor::exception("istream readsome error",
                                                processor::error::FATAL_ERROR);
                 }
                 
                 m_data_message->process_payload(m_payload_buffer,num);
             }
         }
     }
 }
コード例 #2
0
void BarGeraImporter::readInNetwork(InputGraph& graph, std::istream& is)
{
	/*
	TODO: format is:
	
	<NUMBER OF ZONES> Z
	<NUMBER OF NODES> N
	<FIRST THRU NODE> F
	<NUMBER OF LINKS> E
	<END OF METADATA>
	
	We should also deal with comments properly.
	*/
	skipComments(is);
	is.ignore(numeric_limits<streamsize>::max(),'\n');//Skip #zones - not important
	
	skipComments(is);
	is.ignore(numeric_limits<streamsize>::max(),'>');//Skip to #nodes
	is >> nodes;//Read in #nodes
	skipComments(is);
	is.ignore(numeric_limits<streamsize>::max(),'>');//Skip to First Through Node
	unsigned firstThroughNode;
	is >> firstThroughNode;
	zones = firstThroughNode - 1;
	graph.setNodes(nodes+zones);
	skipComments(is);
	is.ignore(numeric_limits<streamsize>::max(),'>');//Skip to #edges
	unsigned arcs;
	is >> arcs;
	
	endMetadata(is);
	
	while (arcs --> 0) {
		skipComments(is);
		unsigned to, from;
		is >> from >> to;
		
		if(to <= zones) to += nodes;
		
		double capacity, length, speed, toll, zeroFlowTime, alpha;
		double beta;
		
		is >> capacity >> length >> zeroFlowTime >> alpha >> beta >> speed >> toll;
		//Don't use speed, type?
		BarGeraBPRFunction func(zeroFlowTime, capacity, alpha, beta, length*distanceCost+toll*tollCost);
		graph.addEdge(from-1, to-1, func.costFunction());
		
		is.ignore(numeric_limits<streamsize>::max(),';');//Skip to end of row
	}
}
コード例 #3
0
ファイル: Features.hpp プロジェクト: shoppel/slam-envire
 void load(std::istream& is)
 {
   double d1, d2;
   is >> d1;
   is >> d2;
   is.ignore(10, '\n');
   point = base::Vector2d(d1, d2);
   is >> size;
   is.ignore(10, '\n');
   is >> angle;
   is.ignore(10, '\n');
   is >> response;
   is.ignore(10, '\n');
 }
コード例 #4
0
ファイル: CSliderUI.cpp プロジェクト: XmakerenX/ShaderUIChess
//-----------------------------------------------------------------------------
// Name : CSliderUI(constructor from InputFile) 
//-----------------------------------------------------------------------------
CSliderUI::CSliderUI(std::istream& inputFile)
	:CControlUI(inputFile)
{
	m_type = CControlUI::SLIDER;

	inputFile >> m_nMin;
	inputFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //skips to next line
	inputFile >> m_nMax;
	inputFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //skips to next line

	m_nValue = (m_nMax - m_nMin) / 2;

	m_bPressed = false;
}
コード例 #5
0
ファイル: datatest.cpp プロジェクト: hon1nbo/BCTt
bool GetField(std::istream &is, std::string &name, std::string &value)
{
	name.resize(0);		// GCC workaround: 2.95.3 doesn't have clear()
	is >> name;
	if (name.empty())
		return false;

	if (name[name.size()-1] != ':')
		SignalTestError();
	name.erase(name.size()-1);

	while (is.peek() == ' ')
		is.ignore(1);

	// VC60 workaround: getline bug
	char buffer[128];
	value.resize(0);	// GCC workaround: 2.95.3 doesn't have clear()
	bool continueLine;

	do
	{
		do
		{
			is.get(buffer, sizeof(buffer));
			value += buffer;
		}
		while (buffer[0] != 0);
		is.clear();
		is.ignore();

		if (!value.empty() && value[value.size()-1] == '\r')
			value.resize(value.size()-1);

		if (!value.empty() && value[value.size()-1] == '\\')
		{
			value.resize(value.size()-1);
			continueLine = true;
		}
		else
			continueLine = false;

		std::string::size_type i = value.find('#');
		if (i != std::string::npos)
			value.erase(i);
	}
	while (continueLine);

	return true;
}
コード例 #6
0
Patron::Patron(std::istream& in)
{
	std::string toBeName{};
	std::getline(in, toBeName);
	name = toBeName;
	in >> MaxCheckedOut;
	int numCheckOut;
	in >> numCheckOut;
	in.ignore();
	//Consider replacing this code with a factory method
	int toCast;
	//for (int i = 0; i < numCheckOut; i++)
	//{
	//	in >> toCast;
	//	switch (static_cast<Item::ITEMTYPES>(toCast))
	//	{
	//	case Item::ITEMTYPES::ADULTBOOK:
	//		checkedOut.push_back(new AdultBook(in));
	//		break;
	//	case Item::ITEMTYPES::CHILDRENSBOOK:
	//		checkedOut.push_back(new ChildBook(in));
	//		break;
	//	case Item::VHS: 
	//		checkedOut.push_back(new VHS(in));
	//		break;
	//	case Item::DVD: 
	//		checkedOut.push_back(new DVD(in));
	//		break;
	//	default: break;
	//	}
	//}
}
コード例 #7
0
ファイル: filedrawnode.cpp プロジェクト: KPWhiver/DimLib
  void FileDrawNode::extract(std::istream &in)
  {
    string filename;
    vec3 l_coor;
    quat l_rotation;

    in >> l_coor.x >> l_coor.y >> l_coor.z >> l_rotation.x >> l_rotation.y >> l_rotation.z >> l_rotation.w >> d_sceneIdx >> filename;
    in.ignore();

    if(not in)
      return;

    bool present = false;

    for(size_t idx = 0; idx != objects().size(); ++idx)
    {
      if(objects()[idx].filename == filename)
      {
        d_index = idx;
        present = true;
        break;
      }
    }

    if(not present)
      throw log(__FILE__, __LINE__, LogType::error, "The file " + filename + " needs to be loaded first with the static 'load' member");

    setLocation(l_coor);
    setOrientation(l_rotation);
  }
コード例 #8
0
bool Order::receive(std::istream & is) {
    int delivered_;
    bool ret = false;
    bool keepgoing = true;

    int onOrder = ordered - delivered;

    while (keepgoing) {
        std::cout << "Quantity (0 to quit) : ";
        is >> delivered_;
        is.ignore();

        if (delivered_ == 0) {
            std::cout << "**No delivery recorded!" << std::endl;
            keepgoing = false;
        }
        else if (delivered_ > onOrder) {
            std::cout << delivered_ << " not on order. Only " << onOrder;
            std::cout << " are on order. Try again." << std::endl;
        }
        else if (delivered_ < 0) {
            std::cout << "Enter a positive number. Try again." << std::endl;
        }
        else {
            delivered += delivered_;
            ret = true;
            keepgoing = false;
        }
    }

    return ret;
}
コード例 #9
0
SpellView SpellView::deserialize(std::istream& input) {
	SpellView _obj = SpellView();
	// CurrentCooldown
	float _obj_CurrentCooldown; input >> _obj_CurrentCooldown; input.ignore(1000, '\n');
	_obj.CurrentCooldown = (float)_obj_CurrentCooldown;
	// SourceCaster
	int _obj_SourceCaster; input >> _obj_SourceCaster; input.ignore(1000, '\n');
	_obj.SourceCaster = (int)_obj_SourceCaster;
	// Model
	int _obj_Model; input >> _obj_Model; input.ignore(1000, '\n');
	_obj.Model = (int)_obj_Model;
	// Level
	int _obj_Level; input >> _obj_Level; input.ignore(1000, '\n');
	_obj.Level = (int)_obj_Level;
	return _obj;
}
コード例 #10
0
 /*!
  * @if jp
  * @brief 入力ストリームから1行読み込む
  * @else
  * @brief Read a line from input stream
  * @endif
  */
 int getlinePortable(std::istream& istr, std::string& line)
 {
   char c;
   std::stringstream s;
   
   while (istr.get(c))
     {
       if (c == '\n')
         {
           break;
         }
       else if (c == '\r')
         {
           if (istr.peek() == '\n')
             {
               istr.ignore();
             }
           break;
         }
       else
         {
           s << c;
         }
     }
   line = s.str();
   return static_cast<int>(line.size());
 }
コード例 #11
0
ファイル: llmime.cpp プロジェクト: Nora28/imprudence
void LLMimeParser::Impl::scanPastContent(
	std::istream& istr,
	S32 limit,
	LLSD headers,
	const std::string separator)
{
	if(headers.has(CONTENT_LENGTH))
	{
		S32 content_length = headers[CONTENT_LENGTH].asInteger();
		// Subtract 2 here for the \r\n after the content.
		S32 max_skip = llmin(content_length, limit - mScanCount - 2);
		istr.ignore(max_skip);
		mScanCount += max_skip;

		// *NOTE: Check for hitting the limit and eof here before
		// checking for the trailing EOF, because our mime parser has
		// to gracefully handle incomplete mime entites.
		if((mScanCount >= limit) || istr.eof())
		{
			mContinue = false;
		}
		else if(!eatCRLF(istr))
		{
			mError = true;
			return;
		}
	}
}
コード例 #12
0
ファイル: IpOptionsList.cpp プロジェクト: athrpf/ipopt-trunk
  bool OptionsList::readnexttoken(std::istream& is, std::string& token)
  {
    token.erase();
    int c = is.get();

    // First get rid of all comments and white spaces
    while (!is.eof() && (isspace(c) || c=='#') ) {
      if (c=='#') {
        is.ignore(10000000, '\n');
      }
      c=is.get();
    }

    bool inside_quotes = (c=='"');
    if (inside_quotes) {
      if (is.eof()) return false; // eof after quotation symbol
      c=is.get();
    }

    // Now read the token
    while (!is.eof() && (inside_quotes || !isspace(c))) {
      token += (char)c;
      c = is.get();
      if (inside_quotes && (c=='"')) {
        inside_quotes = false;
        if (!is.eof())
          c = is.get();
      }
    }

    return (!is.eof());
  }
コード例 #13
0
ファイル: Svm.cpp プロジェクト: lscheinkman/nupic.core
//------------------------------------------------------------------------------
void svm_problem::load(std::istream &inStream) {
  int s = 0;
  inStream >> s >> n_dims_;

  if (recover_)
    for (size_t i = 0; i != x_.size(); ++i)
      delete[] x_[i];

  y_.resize(s, 0);
  x_.resize(s, nullptr);

  inStream.ignore(1);
  nupic::binary_load(inStream, y_);

  for (int i = 0; i < size(); ++i) {
#if defined(NTA_OS_WINDOWS) && defined(NTA_COMPILER_MSVC)
    x_[i] = (float *)_aligned_malloc(4 * n_dims(), 16);
#else
    x_[i] = new feature_type[n_dims()];
#endif

    std::fill(x_[i], x_[i] + n_dims(), (float)0);
    nupic::binary_load(inStream, x_[i], x_[i] + n_dims());
  }
}
コード例 #14
0
void ossimNitfTextHeaderV2_0::parseStream(std::istream &in)
{
   if(in)
   {
      clearFields();
      
      in.read(theFilePartType, 2);
      in.read(theTextId, 10);
      in.read(theDataAndTime, 14);
      in.read(theTextTitle, 80);
      in.read(theTextSecurityClassification, 1);
      in.read(theTextCodewords, 40);
      in.read(theTextControlAndHandling, 40);
      in.read(theTextReleasingInstructions, 40);
      in.read(theTextClassificationAuthority, 20);
      in.read(theTextSecurityControlNumber, 20);
      in.read(theTextSecurityDowngrade, 6);
      if(ossimString(theTextSecurityDowngrade) == "999998")
      {
         in.read(theTextSecurityDowngradeEvent, 40);
      }
      in.read(theTextEncyption, 1);
      in.read(theTextFormat, 3);
      in.read(theExtSubheaderDataLength, 5);
      long dataLength = ossimString(theExtSubheaderDataLength).toLong();
      if(dataLength > 0)
      {
         in.read(theExtSubheaderOverflow, 3);

         // ignore the data for now
         in.ignore(dataLength - 3);
      }
   }
}
コード例 #15
0
ファイル: Svm.cpp プロジェクト: Viking93/nupic.core
      //--------------------------------------------------------------------------------
      void svm_problem::load(std::istream& inStream)
      {
	int s = 0;
	inStream >> s >> n_dims_;
  
	if (recover_)
	  for (size_t i = 0; i != x_.size(); ++i)
	    delete [] x_[i];

	y_.resize(s, 0);
	x_.resize(s, 0);

	inStream.ignore(1);
	nta::binary_load(inStream, y_);
	
	for (int i = 0; i < size(); ++i) {

#if defined(NTA_PLATFORM_win32) && defined(_MSC_VER)
          x_[i] = (float*) _aligned_malloc(4*n_dims(), 16);
#else
	  x_[i] = new feature_type[n_dims()];
#endif

          std::fill(x_[i], x_[i] + n_dims(), (float) 0);
	  nta::binary_load(inStream, x_[i], x_[i] + n_dims());
	}
      }
コード例 #16
0
static bool ImageOpen(ImageRec &image, std::istream &is)
{
    image.is = &is;

    is.read(reinterpret_cast<char*>(&image), 12);

    if(is.gcount() != 12)
        return false;

    bool swapFlag = !osgIsBigEndian();

    if(swapFlag == true)
        ConvertShort(&image.imagic, 6);

    if((image.type & 0xFF00) == 0x0100) 
    {
        is.ignore(512 - 12);
        if (is.gcount() != 512 - 12)
            return false;

        int n = image.ysize * image.zsize;
        int len = n * sizeof(unsigned);

        image.rowStart.resize(n);

        is.read(reinterpret_cast<char*>(&(image.rowStart.front())), len);

        if(is.gcount() != len)
            return false;

        image.rowSize.resize(n);

        is.read(reinterpret_cast<char*>(&(image.rowSize.front())), len);

        if(is.gcount() != len)
            return false;

        if(swapFlag == true)
        {
            ConvertLong(&(image.rowStart.front()), n);
            ConvertLong(&(image.rowSize .front()), n);
        }
        unsigned int maxSize = 0;

        for(int i = 0; i < n; ++i)
        {
            if(image.rowSize[i] > maxSize)
                maxSize = image.rowSize[i];
        }

        image.tmp.resize(maxSize);
    }
    else
    {
        image.tmp.resize(image.xsize);
    }

    return true;
}
コード例 #17
0
// helper function: skip commment lines in the header of ppm image
void PPM_Image::skip_comment(std::istream &is) {
    char c; is >> c;
    while (c == '#') { // skipping comment lines
        is.ignore(256, '\n');
        is >> c;
    }
    is.unget();
}
コード例 #18
0
ファイル: main.cpp プロジェクト: jazzcurio/CPP_Ean_Book_Order
// menu prompts for and accepts an option selection from standard input and
// returns the character identifying the selected option
//
char menu(std::istream& is) {
	char c;
	int  ok = false;

	std::cout << '\n';
	std::cout << "Please select from the following options :\n";
	std::cout << " P - Place an order with a publisher\n";
	std::cout << " S - Place a special order with a publisher\n";
	std::cout << " A - Add one copy to an existing order\n";
	std::cout << " D - Record a delivery from a publisher\n";
	std::cout << " F - Change output style\n";
	std::cout << " V - View status of books on order\n";
	std::cout << " Q - Quit\n";
	do {
		std::cout << " Your selection : ";
		c = ' ';
		is.get(c);

		if (c >= 'a' && c <= 'z') {
			c -= 'a' - 'A';
		}

		if (is.fail()) {
			is.clear();
			is.ignore(2000, '\n');
			std::cerr << " Invalid input.  Try again.\n";
		}
		else if (c == '\n') {
			; // no input - try again
		}
		else if (c != 'P' && c != 'S' && c != 'A' && c != 'D' && c != 'V' && c != 'Q' && c != 'F') {
			is.ignore(2000, '\n');
			std::cerr << " Invalid Character.  Try again.\n";
		}
		else if (is.get() != '\n') {
			is.ignore(2000, '\n');
			std::cerr << " Trailing Characters.  Try Again.\n";
		}
		else if (c == 'P' || c == 'S' || c == 'A' || c == 'D' || c == 'V' || c == 'Q' || c == 'F') {
			ok = true;
		}
	} while (ok == 0);

	return c;
}
コード例 #19
0
ファイル: NeuroJet.hpp プロジェクト: jbarrow/NeuroJet
template <class T> void read_without_comments(std::istream &in, T &var)
{
   eat_whitespace(in);
   while (in.peek() == '#' || in.peek() == '\n')
   {
      in.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
      eat_whitespace(in);
   }
   in >> var;
}
コード例 #20
0
ファイル: stc.cpp プロジェクト: matthieuo/codingame
 planed_block(std::istream &cin2)
 {
   for (int i = 0; i < 8; i++) {
     int colorA; // color of the first block
     int colorB; // color of the attached block
     cin2 >> colorA >> colorB; cin2.ignore();
     pair_g tm(colorA,colorB);
     pb[i] = tm;
   }  
 }
コード例 #21
0
inline void checkAndEatHeader(std::istream& inStream){
        int version = getNamedValue(inStream, "MD5Version");
 
        if(version != MD5_SUPPORTED_VERSION){
            fatalError("MD5 data has wrong version.");
        }

        //get 'commandline' string
        //we don't use it but it must be present
        findNextToken(inStream);
        std::string token;
        std::getline(inStream, token, ' ');
        if(token != "commandline") fatalError("MD5 data must contain 'commandline' variable in its header.");
        findNextToken(inStream);
        //find " character
        inStream.ignore(50, '"');
        //ignore commanline data
        inStream.ignore(10000, '"');
}
コード例 #22
0
VisionMapView VisionMapView::deserialize(std::istream& input) {
	VisionMapView _obj = VisionMapView();
	// Vision
	std::vector<std::vector<VisionFlags>> _obj_Vision = std::vector<std::vector<VisionFlags>>();
	int _obj_Vision_count; input >> _obj_Vision_count; input.ignore(1000, '\n');
	for(int _obj_Vision_i = 0; _obj_Vision_i < _obj_Vision_count; _obj_Vision_i++) {
		std::vector<VisionFlags> _obj_Vision_e = std::vector<VisionFlags>();
		int _obj_Vision_e_count; input >> _obj_Vision_e_count; input.ignore(1000, '\n');
		for(int _obj_Vision_e_i = 0; _obj_Vision_e_i < _obj_Vision_e_count; _obj_Vision_e_i++) {
			int _obj_Vision_e_e_asInt; input >> _obj_Vision_e_e_asInt; input.ignore(1000, '\n');
			VisionFlags _obj_Vision_e_e = (VisionFlags)_obj_Vision_e_e_asInt;
			_obj_Vision_e.push_back((VisionFlags)_obj_Vision_e_e);
		}
		_obj_Vision.push_back((std::vector<VisionFlags>)_obj_Vision_e);
	}

	_obj.Vision = (::std::vector<std::vector<VisionFlags>>)_obj_Vision;
	return _obj;
}
コード例 #23
0
ファイル: main.cpp プロジェクト: jazzcurio/CPP_Ean_Book_Order
// style prompts for and accepts the style from input stream is
//
bool style(std::istream& is, char& s) {
	bool rc = false, ok = false;
	char c;
	do {
		std::cout << " EAN Style ('-', ' ', '\\n' or '0' to quit) : ";
		c = ' ';
		is.get(c);
		if (is.fail()) {
			is.clear();
			is.ignore(2000, '\n');
			std::cerr << " Invalid input. Try again.\n";
		}
		else if (c != '-' && c != ' ' && c != '\n' && c != '0') {
			is.ignore(2000, '\n');
			std::cerr << " Invalid Character.  Try again.\n";
		}
		else if (c == '0') {
			if (is.get() != '\n') {
				is.ignore(2000, '\n');
				std::cerr << " Trailing Characters.  Try Again.\n";
			}
			else {
				ok = true;
			}
		}
		else if (c == '\n') {
			ok = true;
			s = '\0';
			rc = true;
		}
		else if (is.get() != '\n') {
			is.ignore(2000, '\n');
			std::cerr << " Trailing Characters.  Try Again.\n";
		}
		else if (c == '-' || c == ' ') {
			ok = true;
			s = c;
			rc = true;
		}
	} while (!ok);

	return rc;
}
コード例 #24
0
void ossimKeywordlist::skipWhitespace(std::istream& in)const
{
   int c = in.peek();
   while( !in.fail() &&
         ( (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') ) )
   {
      in.ignore(1);
      c = in.peek();
   }
}
コード例 #25
0
ファイル: StringHelper.cpp プロジェクト: c-base/libavg
void skipToken(std::istream& is, char token)
{
    skipWhitespace(is);
    int i = is.peek();
    if (i == token) {
        is.ignore();
    } else {
        is.setstate(ios::failbit);
    }
}
コード例 #26
0
void
SCCircuitDocument::ReadFile
	(
	std::istream& input
	)
{
	assert( itsExprList->IsEmpty() && itsPlotList->IsEmpty() );

	input.ignore(kDataFileSignatureLength);

	JFileVersion vers;
	input >> vers;
	assert( vers <= kCurrentMainFileVersion );

	JString netlistText;
	input >> netlistText;
	itsNetlistText->SetText(netlistText);

	delete itsVarList;
	delete itsCircuit;

	itsCircuit = new SCCircuit(input, vers);
	assert( itsCircuit != NULL );

	itsVarList = new SCCircuitVarList(input, vers);
	assert( itsVarList != NULL );

	ListenTo(itsVarList);
	itsVarListDir->SetVarList(itsVarList);

	GetWindow()->ReadGeometry(input);
	itsVarListDir->ReadSetup(input, vers);

	itsIgnoreNewDirectorFlag = kJTrue;

	JSize exprCount;
	input >> exprCount;

	for (JIndex i=1; i<=exprCount; i++)
		{
		SCDirectorBase* dir = SCDirectorBase::StreamIn(input, vers, this);
		dir->Activate();
		}

	if (vers >= 1)
		{
		JSize plotCount;
		input >> plotCount;

		for (JIndex i=1; i<=plotCount; i++)
			{
			SCPlotDirector* dir = new SCPlotDirector(input, vers, this);
			dir->Activate();
			}
		}
コード例 #27
0
ファイル: Vector2D.cpp プロジェクト: Lyrositor/insa
Vector2D Vector2D::unserialize(std::istream& is)
{
    long x, y;
    std::string temp;
    is.ignore(1);
    std::getline(is, temp, ';');
    x = std::stol(temp);
    std::getline(is, temp, ')');
    y = std::stol(temp);
    return Vector2D(x, y);
}
コード例 #28
0
ファイル: ossimXmlNode.cpp プロジェクト: renyu310/ossim-svn
void ossimXmlNode::skipCommentTag(std::istream& in)
{
    char c;
    while(!in.fail())
    {
        c = in.get();
        if(c == '-')
        {
            if(in.peek() == '-')
            {
                in.ignore();
                if(in.peek() == '>')
                {
                    in.ignore();
                    return;
                }
            }
        }
    }
}
コード例 #29
0
ファイル: SpatialConvex.cpp プロジェクト: esheldon/sdssidl
/////////////READ/////////////////////////////////////////
//
void
SpatialConvex::read(std::istream &in) {
  size_t nconstr;
  SpatialConstraint constr;
  
  in.setf(std::ios::skipws);
  while(in.peek() == COMMENT)  // ignore comments
    in.ignore(10000,'\n');
  in >> nconstr ; in.ignore(); // ignore "\n"
  if(!in.good())
    throw SpatialFailure("SpatialConvex:read: Could not read constraint");
  for(size_t i = 0; i < nconstr; i++) {
    if(in.eof())
      throw SpatialFailure("SpatialConvex:read: Premature end-of-file");
    in >> constr;
    if(!in.good())
      throw SpatialFailure("SpatialConvex:read: Could not read constraint");
    add(constr);
  }
}
コード例 #30
0
void Grid::reset(std::istream& newDataStream)
{
    grid_.clear();
    for (int i = 0; i < GRID_HEIGHT; i++)
    {
        std::string row;
        newDataStream >> row; newDataStream.ignore();
        grid_.push_back(row);
    }
    updateSize();
}