当前位置: 首页>>代码示例>>C++>>正文


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

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


在下文中一共展示了streambuf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: unpackState

void StarsNode::unpackState(std::streambuf & in) {
    uint32_t size;
    in.sgetn((char *)&size, 4);
    msgpack::unpacker upk;
    upk.reserve_buffer(size);
    in.sgetn(upk.buffer(), size);
    upk.buffer_consumed(size);
    MsgpackInArchive ar(upk);
    ar & power & mem & disk & static_cast<SimOverlayBranch &>(getBranch()) & static_cast<SimOverlayLeaf &>(getLeaf());
    switch (Configuration::getInstance().getPolicy()) {
        case Configuration::IBPolicy:
            static_cast<IBPDispatcher &>(getDisp()).serializeState(ar);
            break;
        case Configuration::MMPolicy:
            static_cast<MMPDispatcher &>(getDisp()).serializeState(ar);
            break;
        case Configuration::DPolicy:
            static_cast<DPDispatcher &>(getDisp()).serializeState(ar);
            break;
        case Configuration::FSPolicy:
            static_cast<FSPDispatcher &>(getDisp()).serializeState(ar);
            break;
        default:
            break;
    }
}
开发者ID:jcelaya,项目名称:stars,代码行数:26,代码来源:StarsNode.cpp

示例2: if

	std::streambuf::int_type SolidusEscaper::operator()(std::streambuf &destination,
	                                                    std::streambuf::int_type character) {
		bool notEscaped = true;
		std::streambuf::char_type tmpChar = std::streambuf::traits_type::to_char_type(character);

		// If we encounter a quotation mark.
		if (tmpChar == Strings::Json::Escape::QUOTATION_MARK) {
			// If we're not in a string, we change that. If we're in a string,
			// we change that only if we're not after an escape back slash.
			inString = !inString || (afterBackSlash);

		} else if (inString && !afterBackSlash) {
			// If we are in a string definition and we're not after a backslash
			// escape.
			if (tmpChar == Strings::Std::SOLIDUS) {
				destination.sputn(Strings::Json::SOLIDUS.c_str(), Strings::Json::SOLIDUS.size());
				notEscaped = false;

			}

		}

		// We determine if we start a backslash escape or not.
		afterBackSlash = inString && !afterBackSlash && (tmpChar == Strings::Json::Escape::BEGIN_ESCAPE);
		return (notEscaped) ? (destination.sputc(tmpChar)) : (0);
	}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:26,代码来源:SolidusEscaper.cpp

示例3: packState

void StarsNode::packState(std::streambuf & out) {
    msgpack::sbuffer buffer;
    msgpack::packer<msgpack::sbuffer> pk(&buffer);
    MsgpackOutArchive ar(pk);
    ar & power & mem & disk & static_cast<SimOverlayBranch &>(getBranch()) & static_cast<SimOverlayLeaf &>(getLeaf());
    switch (Configuration::getInstance().getPolicy()) {
        case Configuration::IBPolicy:
            static_cast<IBPDispatcher &>(getDisp()).serializeState(ar);
            break;
        case Configuration::MMPolicy:
            static_cast<MMPDispatcher &>(getDisp()).serializeState(ar);
            break;
        case Configuration::DPolicy:
            static_cast<DPDispatcher &>(getDisp()).serializeState(ar);
            break;
        case Configuration::FSPolicy:
            static_cast<FSPDispatcher &>(getDisp()).serializeState(ar);
            break;
        default:
            break;
    }
    uint32_t size = buffer.size();
    out.sputn((const char *)&size, 4);
    out.sputn(buffer.data(), size);
}
开发者ID:jcelaya,项目名称:stars,代码行数:25,代码来源:StarsNode.cpp

示例4: parseXMLIdentifier

    static std::string parseXMLIdentifier(std::streambuf& buffer)
    {
        std::stringstream identifier;
        {
            char c=buffer.sgetc();
            if((c<'A' || c>'Z') && (c<'a' || c>'z'))
            {
                throw XMLParseException();
            }
            buffer.snextc();
            identifier<<c;
        }
        for(;;)
        {
            char c=buffer.sgetc();
            if((c<'0' || c>'9') && (c<'A' || c>'Z') && (c<'a' || c>'z'))
            {
                break;
            }
            buffer.snextc();
            identifier<<c;
        }
        return identifier.str();

    }
开发者ID:JulianSchutsch,项目名称:dt,代码行数:25,代码来源:xml.cpp

示例5: parseXMLSkipSpace

 static void parseXMLSkipSpace(std::streambuf& buffer)
 {
     while(buffer.sgetc()==' ' || buffer.sgetc()=='\n' || buffer.sgetc()=='\r')
     {
         buffer.snextc();
     }
 }
开发者ID:JulianSchutsch,项目名称:dt,代码行数:7,代码来源:xml.cpp

示例6: size

/**
   read whole contents of streambuf 'buf'

   \return size of data malloced and copied into \param[out] buffer unless size
   is 0 (in which case buffer is set to NULL for convenience, so you can blindly free)

   requires put pointer is at end for determining size (e.g. just-written iostream)
*/
inline std::size_t read_streambuf_malloc(std::streambuf& buf, void*& buffer) {
  typedef std::streambuf::pos_type Pos;
  typedef std::streambuf::off_type Off;
  Pos sz = buf.pubseekoff(0, std::ios::end, std::ios_base::out);
  if (sz > 0 && seek_ok(sz) && seek_ok(buf.pubseekpos(0, std::ios_base::in)))
    return buf.sgetn((char*)(buffer = std::malloc(sz)), sz);
  else {
    buffer = 0;
    return 0;
  }
}
开发者ID:irrawaddy28,项目名称:carmel,代码行数:19,代码来源:read_stream.hpp

示例7:

	std::streambuf::int_type Indenter::operator()(std::streambuf &destination,
	                                              std::streambuf::int_type character) {
		std::streambuf::char_type tmpChar = std::streambuf::traits_type::to_char_type(character);

		if (atStartOfLine && tmpChar != Whitespace::NEW_LINE) {
			destination.sputc(Whitespace::HORIZONTAL_TAB);
		}

		atStartOfLine = (tmpChar == Whitespace::NEW_LINE);
		return destination.sputc(tmpChar);
	}
开发者ID:57-Wolve,项目名称:NodeManager,代码行数:11,代码来源:Indenter.cpp

示例8: advance

    std::size_t HeaderParser::advance(std::streambuf& sb)
    {
        std::size_t ret = 0;

        while (sb.in_avail() > 0)
        {
            ++ret;
            if (parse(sb.sbumpc()))
                return ret;
        }

        return ret;
    }
开发者ID:gema-arta,项目名称:zim-vendor,代码行数:13,代码来源:parser.cpp

示例9: if

    virtual std::streampos seekoff (std::streamoff off, std::ios_base::seekdir way,
                   std::ios_base::openmode which = std::ios_base::in)
    {
        std::streamoff newpos;
        if ( way == std::ios_base::beg )
        {
            newpos = off;
        }
        else if ( way == std::ios_base::cur )
        {
            newpos = _curPos + off;
        }
        else if ( way == std::ios_base::end )
        {
            newpos = _numChars + off;
        }
        else
        {
            return -1;
        }

        if ( newpos<0 || newpos>_numChars ) return -1;
        if ( ARCHIVE_POS(_streambuf->pubseekpos( STREAM_POS(_startPos+newpos), which)) < 0 ) return -1;
        _curPos = newpos;
        return _curPos;
    }
开发者ID:MORTAL2000,项目名称:OpenSceneGraph,代码行数:26,代码来源:OSGA_Archive.cpp

示例10: parseXML

 XMLNode_SPtr parseXML(std::streambuf& buffer)
 {
     std::cout<<"Parse Start"<<std::endl;
     parseXMLSkipSpace(buffer);
     char c=buffer.sgetc();
     if(c=='<')
     {
         buffer.snextc();
         std::cout<<"Parse Node"<<std::endl;
         XMLNode_SPtr current=parseXMLNode(buffer);
         std::cout<<"Something"<<std::endl;
         return current;
     }
     std::cout<<"Nothing"<<std::endl;
     return XMLNode_SPtr();
 }
开发者ID:JulianSchutsch,项目名称:dt,代码行数:16,代码来源:xml.cpp

示例11: serializar

Ttamanio Bloque::serializar(std::streambuf&salida)const{
	unsigned char nrocomponetes=componentes.size();
	Ttamanio offset=sizeof(unsigned char);
	salida.sputn((char*)&nrocomponetes,offset);
	for(Ttamanio i=0;i<nrocomponetes;i++){
		offset+=componentes.at(i)->serializar(salida);
	}
	return offset;
}
开发者ID:FiubaDaniel,项目名称:7506pontiac,代码行数:9,代码来源:Bloque.cpp

示例12: operator

 int operator()(std::streambuf& sbuf, int c)
 {
     int result = eof();
     if (c != eof() && new_line)
     {
         std::ostream(&sbuf) << ++line_number << ": ";
     }
     new_line = (c == '\n');
     
     return result != eof() ? result : sbuf.sputc(c);
 }
开发者ID:CCJY,项目名称:coliru,代码行数:11,代码来源:main.cpp

示例13: read

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
bool t_single_scenario_campaign_file_header::read(
	std::streambuf &		stream,
	t_progress_handler *	progress_handler_ptr )
{
	m_map_data_start = stream.pubseekoff( 0, std::ios::cur );
	m_map_data_end = stream.pubseekoff( 0, std::ios::end );
	stream.pubseekpos( m_map_data_start );

	try
	{
		t_inflate_filter inflater( stream );
		if ( !::read( inflater, *m_map_header_ptr, progress_handler_ptr ) ) 
			return false;
	}
	catch ( t_inflate_filter::t_data_error const & )
	{
		return false;
	}
	return true;
}
开发者ID:sundoom,项目名称:sunstudio,代码行数:22,代码来源:campaign_file_header.cpp

示例14: read

//////////////////////////////////////////////////////////////////////////////
// STATIC
void
read(std::streambuf & istrm, void * dataIn, size_t dataInLen)
{
	std::streamsize cnt = dataInLen;
#ifdef BLOCXX_WIN32
// VC10 warns that sgetn is unsafe.
#pragma warning(push)
#pragma warning(disable:4996)
#endif
	if (istrm.sgetn(static_cast<char *>(dataIn), cnt) != cnt)
#ifdef BLOCXX_WIN32
#pragma warning(pop)
#endif
	{
		BLOCXX_THROW(IOException, "Failed reading data");
	}
}
开发者ID:camsoupa,项目名称:redneckracer,代码行数:19,代码来源:BinarySerialization.cpp

示例15: tmp

	std::streambuf::int_type Escaper::operator()(std::streambuf &destination,
	                                             std::streambuf::int_type character) {
		bool notEscaped = true;
		std::streambuf::char_type tmpChar = std::streambuf::traits_type::to_char_type(character);

		// If we encounter a quotation mark.
		if (tmpChar == Structural::BEGIN_END_STRING) {
			// If we're not in a string, we change that. If we're in a string,
			// we change that only if we're not after an escape back slash.
			inString = !inString || (afterBackSlash);

		} else if (inString && !afterBackSlash) {
			// If we are in a string definition and we're not after a backslash
			// escape.
			if (tmpChar == Strings::Std::REVERSE_SOLIDUS) {
				destination.sputn(Strings::Json::REVERSE_SOLIDUS.c_str(), Strings::Json::REVERSE_SOLIDUS.size());
				notEscaped = false;

			} else if (tmpChar == Strings::Std::BACKSPACE) {
				destination.sputn(Strings::Json::BACKSPACE.c_str(), Strings::Json::BACKSPACE.size());
				notEscaped = false;

			} else if (tmpChar == Strings::Std::FORM_FEED) {
				destination.sputn(Strings::Json::FORM_FEED.c_str(), Strings::Json::FORM_FEED.size());
				notEscaped = false;

			} else if (tmpChar == Strings::Std::LINE_FEED) {
				destination.sputn(Strings::Json::LINE_FEED.c_str(), Strings::Json::LINE_FEED.size());
				notEscaped = false;

			} else if (tmpChar == Strings::Std::TAB) {
				destination.sputn(Strings::Json::TAB.c_str(), Strings::Json::TAB.size());
				notEscaped = false;

			} else if (tmpChar >= '\0' && tmpChar <= '\x1f') {
				std::string tmp(Value::escapeToUnicode(tmpChar));
				destination.sputn(tmp.c_str(), tmp.size());
				notEscaped = false;
			}

		}

		// We determine if we start a backslash escape or not.
		afterBackSlash = inString && !afterBackSlash && (tmpChar == Strings::Json::Escape::BEGIN_ESCAPE);
		return (notEscaped) ? (destination.sputc(tmpChar)) : (0);
	}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:46,代码来源:Escaper.cpp


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