本文整理汇总了C++中std::istringstream::fail方法的典型用法代码示例。如果您正苦于以下问题:C++ istringstream::fail方法的具体用法?C++ istringstream::fail怎么用?C++ istringstream::fail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::istringstream
的用法示例。
在下文中一共展示了istringstream::fail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractEnd
static bool extractEnd(std::istringstream &strm, std::string &end)
{
std::stringbuf temp;
strm.get(temp);
end = temp.str();
return !strm.fail();
}
示例2: e
/**
* @brief Recurse internal function to parse a Boolean formula from a line in the input file
* @param is the input stream from which the tokens in the line are read
* @param allowedTypes a list of allowed variable types - this allows to check that assumptions do not refer to 'next' output values.
* @return a BF that represents the transition constraint read from the line
*/
BF GR1Context::parseBooleanFormulaRecurse(std::istringstream &is,std::set<VariableType> &allowedTypes, std::vector<BF> &memory) {
std::string operation = "";
is >> operation;
if (operation=="") {
SlugsException e(false);
e << "Error reading line " << lineNumberCurrentlyRead << ". Premature end of line.";
throw e;
}
if (operation=="|") return parseBooleanFormulaRecurse(is,allowedTypes,memory) | parseBooleanFormulaRecurse(is,allowedTypes,memory);
if (operation=="^") return parseBooleanFormulaRecurse(is,allowedTypes,memory) ^ parseBooleanFormulaRecurse(is,allowedTypes,memory);
if (operation=="&") return parseBooleanFormulaRecurse(is,allowedTypes,memory) & parseBooleanFormulaRecurse(is,allowedTypes,memory);
if (operation=="!") return !parseBooleanFormulaRecurse(is,allowedTypes,memory);
if (operation=="1") return mgr.constantTrue();
if (operation=="0") return mgr.constantFalse();
// Memory Functionality - Create Buffer
if (operation=="$") {
unsigned nofElements;
is >> nofElements;
if (is.fail()) {
SlugsException e(false);
e << "Error reading line " << lineNumberCurrentlyRead << ". Expected number of memory elements.";
throw e;
}
std::vector<BF> memoryNew(nofElements);
for (unsigned int i=0; i<nofElements; i++) {
memoryNew[i] = parseBooleanFormulaRecurse(is,allowedTypes,memoryNew);
}
return memoryNew[nofElements-1];
}
示例3: seek
bool seek(size_t v, int origin)
{
if (origin == SEEK_CUR)
stream.seekg(v, std::ios_base::cur);
else if (origin == SEEK_END)
stream.seekg(v, std::ios_base::end);
else
stream.seekg(v, std::ios_base::beg);
return !stream.fail();
}
示例4: sizeof
template<typename T> void me_traffic_generator::do_do_store(std::istringstream &iss) {
tlm::tlm_generic_payload *req_transaction_ptr = m_txn_pool.pop();
sc_dt::uint64 addr;
iss >> hex >> addr >> dec;
T *buffer = (T *)m_buffer;
int len;
for(len=0; len < m_buffer_size; len++) {
unsigned tmp;
iss >> hex >> tmp >> dec;
if(iss.fail()) break;
*(buffer++) = T(tmp);
}
if(len == 0) return;
req_transaction_ptr->set_command(tlm::TLM_WRITE_COMMAND);
req_transaction_ptr->set_address(addr);
req_transaction_ptr->set_data_ptr(m_buffer);
req_transaction_ptr->set_data_length(len * sizeof(T));
req_transaction_ptr->set_streaming_width(len * sizeof(T));
req_transaction_ptr->set_byte_enable_ptr(0);
req_transaction_ptr->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE);
if(m_endianness != m_host_endianness)
tlm::tlm_to_hostendian_word<T>(req_transaction_ptr,4);
request_out_port->write(req_transaction_ptr);
tlm::tlm_generic_payload *resp_transaction_ptr = response_in_port->read();
if (resp_transaction_ptr != req_transaction_ptr) {
std::ostringstream msg;
msg << m_ID << "Response to wrong request";
REPORT_FATAL(filename, __FUNCTION__, msg.str());
}
if (resp_transaction_ptr->get_response_status() != tlm::TLM_OK_RESPONSE) {
std::ostringstream msg;
msg << m_ID << "Transaction ERROR";
REPORT_FATAL(filename, __FUNCTION__, msg.str());
}
if(m_endianness != m_host_endianness)
tlm::tlm_from_hostendian_word<T>(req_transaction_ptr,4);
std::cout << m_prompt << ":: " << "write transaction length " << len
<< " (10) x " << sizeof(T)*8 << "-bit completed" << std::endl;
m_txn_pool.push(resp_transaction_ptr);
}