本文整理汇总了C++中std::streambuf::sputn方法的典型用法代码示例。如果您正苦于以下问题:C++ streambuf::sputn方法的具体用法?C++ streambuf::sputn怎么用?C++ streambuf::sputn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::streambuf
的用法示例。
在下文中一共展示了streambuf::sputn方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例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);
}
示例3: 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;
}
示例4: 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);
}
示例5: write
/**
* Write implementation delegated to the underlying streambuf
*
* @param buffer source buffer
* @param length number of bytes to process
* @return number of bytes processed
*/
std::streamsize write(const char* buffer, std::streamsize length) {
return streambuf->sputn(buffer, length);
}