• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ std::istringstream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中std::istringstream的典型用法代码示例。如果您正苦于以下问题:C++ istringstream类的具体用法?C++ istringstream怎么用?C++ istringstream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了istringstream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:isra17,项目名称:toursatan,代码行数:8,代码来源:HeroEvent.cpp


示例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;
}
开发者ID:dare0021,项目名称:October3rd,代码行数:30,代码来源:JLDIO.cpp


示例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();
    }
}
开发者ID:iamOgunyinka,项目名称:MyCC,代码行数:25,代码来源:inTopostfix.cpp


示例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 );
 }
开发者ID:benoleary,项目名称:LesHouchesParserClasses_CPP,代码行数:9,代码来源:ParsingUtilities.hpp


示例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;
}
开发者ID:rkanavath,项目名称:ossim,代码行数:34,代码来源:ossimWkt.cpp


示例6: extractEnd

static bool extractEnd(std::istringstream &strm, std::string &end)
{
	std::stringbuf temp;
	strm.get(temp);
	end = temp.str();
	return !strm.fail();
}
开发者ID:Senzaki,项目名称:tipne_net,代码行数:7,代码来源:KeyMap.cpp


示例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;
}
开发者ID:edd83,项目名称:Skype-like,代码行数:8,代码来源:PacketHelper.cpp


示例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) );
}
开发者ID:Draxent,项目名称:CompetitiveProgramming,代码行数:14,代码来源:main.cpp


示例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 );
   }
 }
开发者ID:raedwulf,项目名称:pipeline,代码行数:9,代码来源:ParameterConversion.cpp


示例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;
}
开发者ID:dare0021,项目名称:October3rd,代码行数:13,代码来源:JLDIO.cpp


示例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
}
开发者ID:iamOgunyinka,项目名称:MyCC,代码行数:13,代码来源:inTopostfix.cpp


示例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;
            }
        }
    }
}
开发者ID:MastAvalons,项目名称:aimp-control-plugin,代码行数:14,代码来源:webctlrpc_request_parser.cpp


示例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; }
    }
开发者ID:andreadelprete,项目名称:sot-core,代码行数:35,代码来源:task-conti.cpp


示例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;
}
开发者ID:QaDeS,项目名称:droidsound,代码行数:28,代码来源:SidTuneTools.cpp


示例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 {
开发者ID:proyan,项目名称:sot-core,代码行数:26,代码来源:time-stamp.cpp


示例16: 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;
}
开发者ID:dare0021,项目名称:October3rd,代码行数:16,代码来源:JLDIO.cpp


示例17: 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];
    }
开发者ID:johnyf,项目名称:slugs,代码行数:36,代码来源:synthesisContextBasics.cpp


示例18: commandLine

void MotionPeriod::
commandLine( const std::string& cmdLine,
	     std::istringstream& cmdArgs,
	     std::ostream& os )
{
  if( cmdLine == "help" )
    {
      os << "MotionPeriod:"<<endl
	 <<"  - size  " <<endl
	 <<"  - period  <rank> [<value>]" <<endl
	 <<"  - amplitude  <rank> [<value>] " <<endl
	 <<"  - init  <rank> [<value>] " <<endl
	 <<"  - type  <rank> [const|sin|cos] " <<endl;
    }
//   else if( cmdLine == "period" )
//     {
//       unsigned int rank; unsigned int period; 
//       cmdArgs >> rank >>std::ws; 
//       if( rank>=this->size ) { os <<"!! Error size too large." << std::endl; }
//       if( cmdArgs.good() ) 
// 	{ cmdArgs>>period; motionParams[rank].period = period; }
//       else { os << "period[" << rank << "] = " <<  motionParams[rank].period << std::endl; }
//     }
  SOT_PARAMS_CONFIG(period,unsigned int)
    SOT_PARAMS_CONFIG(amplitude,double)
    SOT_PARAMS_CONFIG(initPeriod,unsigned int)
    SOT_PARAMS_CONFIG(initAmplitude,double)
    else if( cmdLine == "size" )
      {
	unsigned int rank(0); 
	cmdArgs >> std::ws; 
	if( cmdArgs.good() ) 
	  { cmdArgs>>rank; resize( rank ); }
开发者ID:proyan,项目名称:sot-core,代码行数:33,代码来源:motion-period.cpp


示例19: extractDxySize

// format: [depth *] X [x Y]
// Depth, if omitted, defaults to zero.
// Y, if omitted, defaults to zero.
//
dxySize extractDxySize(std::istringstream &ss)
{
    char ch;
    dxySize size;
    size.depth = 1;  // Default is 1 unless otherwise specified

    ss >> size.x;   // This may actually be the depth, we'll see
    auto pos = ss.tellg();
    ss >> ch;       // Test the next non-space char
    if (ch == '*') {
        // Depth dimension
        size.depth = size.x; // That was the depth we read, not X
        size.x = 0;
        ss >> size.x;
        pos = ss.tellg();
        ss >> ch;       // Test the next non-space char
    }
开发者ID:ayeganov,项目名称:neural2d,代码行数:21,代码来源:parseTopologyConfig.cpp


示例20: readWord

std::string WordWrapper::readWord(std::istringstream &stream) {
  auto word = std::string{};

  // Gobble leading spaces
  while (stream.peek() == ' ' || stream.peek() == '\n') stream.ignore(1);

  while (true) {
    auto c = static_cast<char>(stream.peek());
    if (!stream) return word;
    if (c == -1) return word;

    if (c == ' ') {
      stream.ignore(1);
      return word;
    }

    if (c == '\n') {
      stream.ignore(1);
      return word + "\n";
    }

    word += c;
    stream.ignore(1);
  }
}
开发者ID:timgurto,项目名称:mmo,代码行数:25,代码来源:WordWrapper.cpp



注:本文中的std::istringstream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ std::list类代码示例发布时间:2022-05-31
下一篇:
C++ std::istream类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap