本文整理汇总了C++中std::ostream::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::flush方法的具体用法?C++ ostream::flush怎么用?C++ ostream::flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ostream
的用法示例。
在下文中一共展示了ostream::flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeConfig
static void writeConfig (po::variables_map & vm, std::ostream & out) {
// Also: http://stackoverflow.com/questions/4703134/is-there-a-way-to-print-config-file-for-boost-program-options
using boost::property_tree::ptree;
ptree root;
for(auto i:vm) {
// Do not write the config option in the new config
if(i.first == "config")
continue;
if(i.second.value().type() == typeid(int))
root.put(i.first, i.second.as<int>());
else if(i.second.value().type() == typeid(std::string))
root.put(i.first, i.second.as<std::string>());
else if(i.second.value().type() == typeid(float))
root.put(i.first, i.second.as<float>());
else if(i.second.value().type() == typeid(bool))
root.put(i.first, i.second.as<bool>());
else if(i.second.value().type() == typeid(unsigned long))
root.put(i.first, i.second.as<unsigned long>());
else if(i.second.value().type() == typeid(unsigned int))
root.put(i.first, i.second.as<unsigned int>());
else if(i.second.value().type() == typeid(double))
root.put(i.first, i.second.as<double>());
else
std::cerr << "Unknown options type: " << i.second.value().type().name() << " " << i.first << std::endl;
}
write_ini( out, root );
out.flush();
}
示例2:
/**
* @brief This method outputs parameters of the URI.
* @param out Output stream
*/
void
URI::debug(std::ostream& out) const {
out << "Kind : " ;
out << (scheme!="" ? "ABSOLUTE " : "RELATIVE ") ;
if (opaque!="") out << "OPAQUE " ;
out << std::endl ;
if (scheme!="")
out << "Scheme : " << scheme << std::endl ;
if (opaque!="")
out << "OPAQUE : " << opaque << std::endl ;
else {
out << "User : " << user << std::endl ;
out << "Password : " << password << std::endl ;
out << "Host : " << host << std::endl ;
out << "Port : " << port << std::endl ;
out << "Path : " << path << std::endl ;
}
out << "Query : " << query << std::endl ;
out << "Fragment : " << fragment << std::endl ;
out.flush() ;
}
示例3: SaveAsText
void SupportVectorShape::SaveAsText(std::ostream & ostr) {
for (int i = 0; i < FeaturePoints_->size(); ++i) {
PointType const& p = FeaturePoints_->at(i);
ostr << p.x << ' ' << p.y << ' ' << p.z << '\n';
}
ostr.flush();
}
示例4: stream_state
inline
void
arma_ostream::print(std::ostream& o, const subview_field<oT>& x)
{
arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o);
const std::streamsize cell_width = o.width();
const uword x_n_rows = x.n_rows;
const uword x_n_cols = x.n_cols;
for(uword col=0; col<x_n_cols; ++col)
{
o << "[field column " << col << ']' << '\n';
for(uword row=0; row<x_n_rows; ++row)
{
o.width(cell_width);
o << x.at(row,col) << '\n';
}
o << '\n';
}
o.flush();
stream_state.restore(o);
}
示例5: dump_node
static void dump_node(std::ostream&out, const Node*node){
for (unsigned line = 1, height = get_height(node); line <= height; ++line){
dump_line(out, node, line);
out.put('\n');
}
out.flush();
}
示例6: OutputNodePositionsInXY
void NetworkSimulator::OutputNodePositionsInXY(
const TimeType lastOutputTime,
std::ostream& nodePositionOutStream) const
{
typedef map<NodeIdType, shared_ptr<NetworkNode> >::const_iterator IterType;
for(IterType iter = nodes.begin(); (iter != nodes.end()); ++iter) {
const NodeIdType& nodeId = iter->first;
const NetworkNode& node = *iter->second;
const ObjectMobilityPosition nodePosition = node.GetCurrentLocation();
// Don't output stationary nodes.
if ((lastOutputTime == ZERO_TIME) || (nodePosition.LastMoveTime() > lastOutputTime)) {
nodePositionOutStream.precision(10);
nodePositionOutStream << ' ' << nodeId << ' '
<< setw(11) << nodePosition.X_PositionMeters() << ' '
<< setw(11) << nodePosition.Y_PositionMeters() << ' '
<< nodePosition.HeightFromGroundMeters() << ' '
<< nodePosition.AttitudeAzimuthFromNorthClockwiseDegrees() << ' '
<< nodePosition.AttitudeElevationFromHorizonDegrees();
}//if//
}//for//
nodePositionOutStream.flush();
}//OutputNodePositionsInXY//
示例7: SaveSVG
void flowwidget::SaveSVG(std::ostream &data) {
std::cerr << "[FlowWidget] Request to export recieved, enumerating nodes for size" << std::endl;
int GenMinimum = INT_MAX;
int GenExtreme = INT_MIN;
std::for_each(XMLHandlr->OrphanNodes.begin(), XMLHandlr->OrphanNodes.end(),
[&](std::pair<std::string, FlowNode> nodepair) {
NodeSize ns = getNodeSize(QFont("sans-serif", BaseFontSize*nodepair.second.FontSizeMult), QFont("sans-serif", BaseFontSize*nodepair.second.FontSizeMult*1.5), nodepair.second);
if (nodepair.second.CenterPosX - (ns.Width/2) < GenMinimum)
GenMinimum = nodepair.second.CenterPosX - (ns.Width/2);
if (nodepair.second.CenterPosY - (ns.Height/2) < GenMinimum)
GenMinimum = nodepair.second.CenterPosY - (ns.Height/2);
if (nodepair.second.CenterPosX + (ns.Width/2) > GenExtreme)
GenExtreme = nodepair.second.CenterPosX + (ns.Width/2);
if (nodepair.second.CenterPosY + (ns.Height/2) > GenExtreme)
GenExtreme = nodepair.second.CenterPosY + (ns.Height/2);
});
int SVGSize = GenExtreme-GenMinimum;
std::cerr << "[FlowWidget] Calculated sheet size of " << SVGSize << std::endl;
QSvgGenerator svgen;
QIODevice* iodev = new IOStreamBridge(data);
svgen.setOutputDevice(iodev);
svgen.setSize(QSize(SVGSize, SVGSize));
renderFullTree(&svgen, XMLHandlr,
LineColor, BaseFontSize, "",
SVGSize, SVGSize, PermaScale, 1, 0, 0);
data.flush();
std::cerr << "[FlowWidget] Finished export!" << std::endl;
}
示例8: Debug
void VistaNewClusterSlave::Debug( std::ostream& oStream ) const
{
oStream << "[VistaNewClusterSlave]\n"
<< " Name : " << m_sSlaveName << "\n"
<< " Config Section : " << m_sSlaveSectionName << "\n"
<< " SlaveId : " << m_nOwnSlaveID << "\n"
<< " Byteswap : " << (m_bDoByteSwap ? "YES" : "NO") << "\n"
<< " DoGLFinish : " << (m_bDoOglFinish ? "YES" : "NO") << "\n"
<< " DataSync Mode : " << VistaMasterSlave::GetDataSyncModeName( m_nDataSyncMethod ) << "\n"
<< " Barrier Mode : " << VistaMasterSlave::GetBarrierModeName( m_nBarrierWaitMethod ) << "\n"
<< " SwapSync Mode : " << VistaMasterSlave::GetSwapSyncModeName( m_nSwapSyncMethod ) << "\n"
<< " SwapSync timeout : " << vstr::formattime( m_nSwapSyncTimeout, 3 ) << "\n"
<< " Connected : " << (m_pConnection ? "YES" : "NO") << "\n";
if( m_pConnection )
{
VistaSocketAddress oOwnAddress = m_pConnection->GetLocalAddress();
std::string sOwnHostname;
oOwnAddress.GetIPAddress().GetHostName( sOwnHostname );
oStream << " Slave Address : " << sOwnHostname
<< ":" << oOwnAddress.GetPortNumber() << "\n"
<< " Master Address : " << m_pConnection->GetPeerName()
<< ":" << m_pConnection->GetPeerPort() << "\n";
}
oStream.flush();
}
示例9: serialize
void WalletLegacySerializer::serialize(std::ostream& stream, const std::string& password, bool saveDetailed, const std::string& cache) {
std::stringstream plainArchive;
StdOutputStream plainStream(plainArchive);
CryptoNote::BinaryOutputStreamSerializer serializer(plainStream);
saveKeys(serializer);
serializer(saveDetailed, "has_details");
if (saveDetailed) {
serializer(transactionsCache, "details");
}
serializer.binary(const_cast<std::string&>(cache), "cache");
std::string plain = plainArchive.str();
std::string cipher;
Crypto::chacha_iv iv = encrypt(plain, password, cipher);
uint32_t version = walletSerializationVersion;
StdOutputStream output(stream);
CryptoNote::BinaryOutputStreamSerializer s(output);
s.beginObject("wallet");
s(version, "version");
s(iv, "iv");
s(cipher, "data");
s.endObject();
stream.flush();
}
示例10: make_unexpected
expected<void> InjectSpanContext(
const PropagationOptions& /*propagation_options*/, std::ostream& carrier,
const SpanContextData& span_context_data) {
auto trace_id = SwapEndianIfBig(span_context_data.trace_id);
carrier.write(reinterpret_cast<const char*>(&trace_id), sizeof(trace_id));
auto span_id = SwapEndianIfBig(span_context_data.span_id);
carrier.write(reinterpret_cast<const char*>(&span_id), sizeof(span_id));
const uint32_t num_baggage =
SwapEndianIfBig(static_cast<uint32_t>(span_context_data.baggage.size()));
carrier.write(reinterpret_cast<const char*>(&num_baggage),
sizeof(num_baggage));
for (auto& baggage_item : span_context_data.baggage) {
WriteString(carrier, baggage_item.first);
WriteString(carrier, baggage_item.second);
}
// Flush so that when we call carrier.good(), we'll get an accurate view of
// the error state.
carrier.flush();
if (!carrier.good()) {
return opentracing::make_unexpected(
std::make_error_code(std::errc::io_error));
}
return {};
}
示例11: printMidQuotesAndTrades
void Reporter::printMidQuotesAndTrades(std::ostream& os, Errors& errors)
{
StrStream strstream;
if (unlikely(bids_.begin() == bids_.end() || asks_.begin() == asks_.end()))
{
strstream << "NAN" << '\n';
}
else if (receivedNewTrade_)
{
strstream << getQty(currentTrade_) << '@' << getPrice(currentTrade_) << '\n';
receivedNewTrade_ = false;
detectCross_ = false;
}
else if (unlikely(getPrice(*bids_.begin()) >= getPrice(*asks_.begin())))
{
if (likely(!detectCross_)) detectCross_ = true;
else
{
strstream << "Cross BID (" << getPrice(*bids_.begin()) << ")/ASK(" << getPrice(*asks_.begin()) << ')' << '\n';
++errors.bestBidEqualOrUpperThanBestAsk;
}
}
else
{
Price midQuote = (getPrice(*bids_.begin())+getPrice(*asks_.begin()))/2;
strstream << midQuote << '\n';
}
os.rdbuf()->sputn(strstream.c_str(), strstream.length());
os.flush();
}
示例12: reset
void Display::reset(std::ostream& os) {
pthread_mutex_lock(&Display::mutex);
os.flush();
os.clear();
os.seekp(0);
pthread_mutex_unlock(&Display::mutex);
}
示例13: dumpQDimacs
void Root::dumpQDimacs(std::ostream &out) const {
auto const compact = varCompactor();
// Ouput Header
out <<
"c Generated by QBM [https://github.com/preusser/qbm]\n"
"c by Thomas B. Preusser <[email protected]>\n"
"p cnf " << compact(m_signalnxt-1) << ' ' << std::count(m_clauses.begin(), m_clauses.end(), 0) << std::endl;
// Existential: Configuration
out << "e ";
for(int i = FIRST_CONFIG; i < m_confignxt; i++) out << compact(i) << ' ';
out << '0' << std::endl;
// Universal: Inputs
out << "a ";
for(int i = FIRST_INPUT; i < m_inputnxt; i++) out << compact(i) << ' ';
out << '0' << std::endl;
// Existential: Internal and Output Signals
out << "e ";
for(int i = FIRST_SIGNAL; i < m_signalnxt; i++) out << compact(i) << ' ';
out << '0' << std::endl;
// Clauses
for(int lit : m_clauses) {
if(lit) out << compact(lit) << ' ';
else out << '0' << std::endl;
}
out.flush();
}
示例14: while
inline int64_t JSONStreamHelper<T>::write(std::ostream& out, bool json_out,
int64_t buf_size) {
std::function<bool(T&)> reader = get_read_fn();
std::vector<T> buf;
int64_t total = 0;
bool good = true;
std::function<T(size_t)> lambda = [&](size_t i) -> T {return buf[i];};
while (good) {
T obj;
good = reader(obj);
if (good) {
buf.push_back(obj);
}
if (!good || buf.size() >= buf_size) {
if (!json_out) {
stream::write(out, buf.size(), lambda);
} else {
for (int i = 0; i < buf.size(); ++i) {
out << pb2json(buf[i]);
}
}
total += buf.size();
buf.clear();
}
}
if (!json_out) {
stream::finish(out);
}
out.flush();
return total;
}
示例15: print_expression
void print_expression (std::ostream & out, const std::vector < double >&coeff2,
float min2, float max2,bool noclamp=false)
{
int order = coeff2.size ();
if(!noclamp)
out << "clamp(";
switch(order)
{
case 1:
out << coeff2[0]<<"*A[0]";break;
case 2:
out << coeff2[0]<<"*A[0]+"<<coeff2[1];break;
default:
for (int i = 0; i < order; i++)
{
out << coeff2[i];
for (int j = 0; j < i; j++)
out << "*A[0]";
if (i != (order - 1))
out << "+";
}
}
if(!noclamp)
out << "," << min2 << "," << (noclamp?max2*1000:max2) << ")";
out << std::endl;
out.flush();
}