本文整理汇总了C++中std::streambuf::sgetn方法的典型用法代码示例。如果您正苦于以下问题:C++ streambuf::sgetn方法的具体用法?C++ streambuf::sgetn怎么用?C++ streambuf::sgetn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::streambuf
的用法示例。
在下文中一共展示了streambuf::sgetn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: 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;
}
}
示例3: warning
//////////////////////////////////////////////////////////////////////////////
// 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");
}
}
示例4: deserializar
Ttamanio Bloque::deserializar(std::streambuf&entrada){
unsigned char nrocomponetes;
Ttamanio offset=sizeof(unsigned char);
entrada.sgetn((char*)&nrocomponetes,offset);
Ttamanio i=0;
while(i<nrocomponetes and i<componentes.size()){
offset+=componentes.at(i)->deserializar(entrada);
i++;
}
/*le sobran componentes*/
while(i<componentes.size()){
delete componentes.at(i);
componentes.erase(componentes.begin()+i);
}
/*le faltan componentes*/
Componente* auxiliar;
while(i<nrocomponetes){
auxiliar=componentes.at(0)->clonar();
offset+=auxiliar->deserializar(entrada);
componentes.push_back(auxiliar);
i++;
}
return offset;
}