本文整理汇总了C++中std::istringstream::get方法的典型用法代码示例。如果您正苦于以下问题:C++ istringstream::get方法的具体用法?C++ istringstream::get怎么用?C++ istringstream::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::istringstream
的用法示例。
在下文中一共展示了istringstream::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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();
}
}
示例3: 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;
}
示例4: parseName
bool ossimWkt::parseName( std::istringstream& is,
const std::string& prefix,
const std::string& object,
ossimKeywordlist& kwl )
{
bool result = false;
char c;
std::string name;
// Find the first quote:
while ( is.good() )
{
is.get(c);
if ( is.good() )
{
if ( c == '"' )
{
break;
}
}
}
// Get the name:
while ( is.good() )
{
is.get(c);
if ( is.good() )
{
if ( c != '"' )
{
name.push_back(c);
}
else
{
break; // End quote:
}
}
}
if ( name.size() )
{
// Add to keyword list.
std::string key;
if ( prefix.size() )
{
key += prefix;
}
key += object;
key += ".name";
kwl.addPair( key, name );
result = true;
}
return result;
}
示例5: 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
}
示例6: LoadArray
void LoadArray(std::istringstream &buf, pnlVector<Type> &array, char delim = ' ')
{
char ch;
int ich;
Type val;
buf >> ch;
ASSERT(ch == '[' || !buf.good());
array.reserve(16);
array.resize(0);
for(;buf.good();)
{
do
{
ich = buf.peek();
if(ich == ']')
{
buf >> ch;
return;
}
else if(ich == delim || (delim == ' ' && isspace(ich)))
{
buf.get(ch);
}
} while(buf.good() && (ich == delim || (delim == ' ' && isspace(ich))));
if(!buf.good())
{
break;
}
buf >> val;
array.push_back(val);
}
示例7: extractEnd
static bool extractEnd(std::istringstream &strm, std::string &end)
{
std::stringbuf temp;
strm.get(temp);
end = temp.str();
return !strm.fail();
}
示例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: 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;
}
示例10: 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;
}
}
}
}
示例11: moreItems
bool JLDIO::moreItems(std::istringstream& iss, char delim)
{
char charBuffer;
ignoreWhiteSpace(iss);
if(iss.peek() == ',')
{
iss.get(charBuffer);
return true;
}
else if(iss.peek() != delim)
{
std::cout<<"Expected '"<<delim<<"' but found '"<<(char)iss.peek()<<"'\n";
assert(0 && "Unexpected char");
}
return false;
}
示例12: rest_2
void rest_2( std::istringstream &ss, char &lookahead )
{
while( !ss.eof() ){
char tempToken = lookahead;
if( lookahead == '*' ) {
match( ss, lookahead, '*' );
factor( ss, lookahead );
print( tempToken );
} else if ( lookahead == '/' ) {
match ( ss, lookahead, '/' );
factor( ss, lookahead );
print( '/' );
} else if ( isWhiteSpace {}( lookahead ) ) {
for(;; lookahead = ss.get() ){
if( isWhiteSpace {}( lookahead ) ) continue;
else break;
}
} else {
break;
}
}
}
示例13: rest
void rest( std::istringstream &ss, char &lookahead )
{
while( !ss.eof() ) {
char tempToken = lookahead;
if ( lookahead == '+' ) {
match( ss, lookahead, '+' );
term ( ss, lookahead );
print( tempToken );
rest( ss, lookahead );
} else if ( lookahead == '-' ) {
match( ss, lookahead, '-' );
term( ss, lookahead );
print( tempToken );
rest( ss, lookahead );
} else if ( isWhiteSpace {} ( lookahead ) ) {
for(;; lookahead = ss.get() ){
if( isWhiteSpace {}( lookahead ) ) continue;
else break;
}
} else {
break; //we have an epsilon production
}
}
}
示例14: parseWktGroup
bool ossimWkt::parseWktGroup( std::istringstream& is, ossimKeywordlist& kwl )
{
bool result = false;
if ( is.good() )
{
char c;
// Get the wkt group name up to '[', e.g. "PROJCS[".
std::string prefix = "";
std::string object;
// std::string v;
while ( is.good() )
{
is.get(c);
if ( is.good() )
{
// Look for parens or square brackets.
if ( (c != '[') && (c != '(') )
{
object.push_back(c);
}
else
{
result = parseObject( is, prefix, object, kwl );
}
}
else
{
break;
}
}
}
return result;
}
示例15: parse_header_content
bool HttpResponse::parse_header_content(std::istringstream &istr)
{
static const int eof = std::char_traits<char>::eof();
int ch = istr.get();
while (ch != eof && ch != '\r' && ch != '\n')
{
std::string name;
std::string value;
while (ch != eof && ch != ':' && name.length() < MAX_NAME_LENGTH)
{
name += ch;
ch = istr.get();
}
if (ch != ':') return false;
if (ch != eof) ch = istr.get(); // ':'
while (isspace(ch)) ch = istr.get();
while (ch != eof && ch != '\r' && ch != '\n' && value.length() < MAX_VALUE_LENGTH)
{
value += ch;
ch = istr.get();
}
if (ch == '\r') ch = istr.get();
if (ch == '\n')
{
ch = istr.get();
}else if(ch != eof)
{
return false;
}
while (ch == ' ' || ch == '\t') // folding
{
while (ch != eof && ch != '\r' && ch != '\n' && value.length() < MAX_VALUE_LENGTH)
{
value += ch;
ch = istr.get();
}
if (ch == '\r')
{
ch = istr.get();
}
if (ch == '\n')
{
ch = istr.get();
}else if (ch != eof)
{
return false;
}
}
m_nv_map[name] = value;
}
istr.putback(ch);
return true;
}