本文整理汇总了C++中std::istringstream类的典型用法代码示例。如果您正苦于以下问题:C++ istringstream类的具体用法?C++ istringstream怎么用?C++ istringstream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了istringstream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CEvent
//unserialize l'objet
CHeroSyncEvent::CHeroSyncEvent(std::istringstream& data)
: CEvent(EVENT_HEROSYNC), COORD_ERROR_MARGIN(50)
{
data.read((char*)&m_dir,sizeof(UInt8));
data.read((char*)&m_coord.x,sizeof(float));
data.read((char*)&m_coord.y,sizeof(float));
}
示例2: skipOverQuotes
/// directly sends the quoted text to oss
/// and returns if a quote was found
/// empties the given buffer in to oss if one is given
/// works only if a quote char is found where the iss cursor is.
bool JLDIO::skipOverQuotes(std::ostringstream& oss, std::istringstream& iss, std::list<char> *bufferToEmpty)
{
char charBuffer = iss.peek();
if(charBuffer == '\'' || charBuffer == '\"')
{
if(bufferToEmpty && !bufferToEmpty->empty())
{
oss << listToString(*bufferToEmpty);
bufferToEmpty->clear();
}
// std::cout<<"Skipping: ";
char matchedChar = charBuffer;
iss.get(charBuffer);
assert(matchedChar == charBuffer);
do
{
oss << charBuffer;
// std::cout<<charBuffer;
} while(iss.get(charBuffer) && charBuffer != matchedChar);
if(iss.good())
oss << charBuffer;
// std::cout<<charBuffer<<"\n";
return true;
}
return false;
}
示例3: factor
void factor( std::istringstream &ss, char &lookahead ) {
if ( isDigit {}( lookahead ) ){
int value = 0;
do {
value = value * 10 + ToDigit {}( lookahead );
lookahead = ss.get();
} while ( !ss.eof() && isDigit {} ( lookahead ) );
print ( value );
} else if ( lookahead == '(' ) {
match ( ss, lookahead, '(' );
expr( ss, lookahead );
if( lookahead != ')' ){
throw fail { "Expected a closing parenthesis before end of line." };
}
match ( ss, lookahead, ')' );
} else if ( isWhiteSpace {} ( lookahead ) ) {
for (;; lookahead = ss.get() ){
if( isWhiteSpace {}( lookahead ) ) continue;
else break;
}
} else {
std::cerr << "Syntax Error: expecting a digit, got '" << lookahead << "' instead." << std::endl;
abort();
}
}
示例4:
// This resets the flags of streamToReset and sets its string to be
// newString.
inline void
ParsingUtilities::ResetStringstream( std::istringstream& streamToReset,
std::string const& newString )
{
streamToReset.clear();
streamToReset.str( newString );
}
示例5: parseObject
bool ossimWkt::parseObject( std::istringstream& is,
const std::string& prefix,
const std::string& object,
ossimKeywordlist& kwl )
{
bool result = false;
result = parseName( is, prefix, object, kwl );
if ( result && is.good() )
{
char c;
ossim_uint32 myObjectIndex = 0;
ossim_uint32 paramIndex = 0;
while ( is.good() )
{
is.get(c);
if ( is.good() )
{
if ( c == ',' )
{
parseParam( is, prefix, object, myObjectIndex, paramIndex, kwl );
}
else if ( (c == ']') || (c == ')') )
{
break; // End of object.
}
}
}
}
return result;
}
示例6: extractEnd
static bool extractEnd(std::istringstream &strm, std::string &end)
{
std::stringbuf temp;
strm.get(temp);
end = temp.str();
return !strm.fail();
}
示例7:
int PacketHelper::getUnreadSize(std::istringstream& st)
{
std::streampos pos = st.tellg();
st.seekg(0, st.end);
int length = (int)(st.tellg() - pos);
st.seekg(pos, st.beg);
return length;
}
示例8: insert_spaces
/**
* Read from input title and insert spaces into the title vector
* @param iss input stream
* @param word space word to insert
* @param title vector where to store the words
*/
void insert_spaces( std::istringstream& iss, std::string& word, std::vector<std::string>& title ){
while( iss.peek() == ' ' ){
iss.get();
word += ' ';
}
if ( !word.empty() )
title.push_back( std::move(word) );
}
示例9: convert
void convert( unsigned int count, std::istringstream& inputStream, T * value )
{
DP_ASSERT( count );
for ( unsigned int i=0 ; i<count ; i++ )
{
DP_ASSERT( !inputStream.eof() && !inputStream.bad() );
value[i] = convert<T>( inputStream );
}
}
示例10: ignoreWhiteSpace
/// moves the iss's cursor to the next non-WS char
bool JLDIO::ignoreWhiteSpace(std::istringstream& iss)
{
char charBuffer = iss.peek();
bool output = false;
while(std::isspace(charBuffer))
{
iss.get(charBuffer);
charBuffer = iss.peek();
output = true;
}
return output;
}
示例11: match
void match ( std::istringstream &ss, char &lookahead, const char &currToken ) noexcept
{
if ( lookahead == currToken ){
lookahead = ss.get();
if( isWhiteSpace {}( lookahead ) ){
for(;; lookahead = ss.get() ){
if(isWhiteSpace {}( lookahead ) ) continue;
else break;
}
}
}
//otherwise we have an epsilon production
}
示例12: skipCharacter
void skipCharacter(std::istringstream& is, char char_to_skip)
{
for (;;) {
int c = is.get();
if ( !is.good() ) {
break;
} else {
if (c != char_to_skip) {
is.unget();
break;
}
}
}
}
示例13: commandLine
void TaskConti::
commandLine( const std::string& cmdLine
,std::istringstream& cmdArgs
,std::ostream& os )
{
if( cmdLine=="help" )
{
os << "TaskConti: "<<endl
<< " - touch <sot.control>"<<endl
<< " - timeRef" << endl
<< " - mu [<val>]" << endl;
Task::commandLine( cmdLine,cmdArgs,os );
}
else if( cmdLine=="touch" )
{
Signal<ml::Vector,int> & sig
= dynamic_cast< Signal<ml::Vector,int>& >
(dg::PoolStorage::getInstance()->getSignal(cmdArgs));
timeRef = TIME_REF_TO_BE_SET; //sig.getTime();
q0 = sig.accessCopy();
}
else if( cmdLine=="timeRef" )
{
os << "timeRef = ";
if( timeRef == TIME_REF_TO_BE_SET ) os << "to be set.";
else if( timeRef == TIME_REF_UNSIGNIFICANT ) os << "no signaificant";
else os << timeRef;
os << std::endl;
}
else if( cmdLine=="mu" )
{
cmdArgs >> std::ws; if(! cmdArgs.good() ) os << "mu = " << mu << std::endl;
else { cmdArgs >> mu; }
}
示例14: readHex
// Parse input string stream. Read and convert a hexa-decimal number up
// to a ``,'' or ``:'' or ``\0'' or end of stream.
uint_least32_t SidTuneTools::readHex( std::istringstream& hexin )
{
uint_least32_t hexLong = 0;
char c;
do
{
hexin >> c;
if ( !hexin )
break;
if (( c != ',') && ( c != ':' ) && ( c != 0 ))
{
// machine independed to_upper
c &= 0xdf;
( c < 0x3a ) ? ( c &= 0x0f ) : ( c -= ( 0x41 - 0x0a ));
hexLong <<= 4;
hexLong |= (uint_least32_t)c;
}
else
{
if ( c == 0 )
hexin.putback(c);
break;
}
} while ( hexin );
return hexLong;
}
示例15: commandLine
void TimeStamp::
commandLine( const std::string& cmdLine,
std::istringstream& cmdArgs,
std::ostream& os )
{
if( cmdLine=="help" )
{
os << "TimeStamp: "<<std::endl
<< " - offset [{<value>|now}] : set/get the offset for double sig." << std::endl;
Entity::commandLine( cmdLine,cmdArgs,os );
}
else if( cmdLine=="offset" )
{
cmdArgs >> std::ws;
if( cmdArgs.good() )
{
std::string offnow;
cmdArgs >> offnow;
if(offnow=="now")
{
gettimeofday( &val,NULL );
offsetValue = val.tv_sec;
}
else { offsetValue = atoi(offnow.c_str()); }
offsetSet = ( offsetValue>0 );
} else {