本文整理汇总了C++中std::istream::ignore方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::ignore方法的具体用法?C++ istream::ignore怎么用?C++ istream::ignore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::istream
的用法示例。
在下文中一共展示了istream::ignore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
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: readInNetwork
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: load
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:
//-----------------------------------------------------------------------------
// 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: GetField
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:
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: extract
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: receive
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: deserialize
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: getlinePortable
/*!
* @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: if
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: readnexttoken
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: load
//------------------------------------------------------------------------------
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: clearFields
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: load
//--------------------------------------------------------------------------------
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());
}
}