std::ostream& toStream( std::ostream& os, const YesNoNumber& value ) { if ( value.getIsNumber() ) { toStream( os, value.getValueNumber() ); } else { toStream( os, value.getValueYesNo() ); } return os; }
// ============================================================================ // print XYZ-point // ============================================================================ std::ostream& Gaudi::Utils::toStream ( const Gaudi::XYZPoint& obj, std::ostream& s ) { s << "( " ; toStream ( obj.X () , s ) ; s << " , " ; toStream ( obj.Y () , s ) ; s << " , " ; toStream ( obj.Z () , s ) ; s << " )" ; return s ; }
std::ostream& toStream( std::ostream& os, const FontSize& value ) { if ( value.getIsNumber() ) { toStream( os, value.getValueNumber() ); } else { toStream( os, value.getValueCssFontSize() ); } return os; }
void HttpResponse::writeResponse() { // TODO: Optimize std::ostringstream response(std::ios_base::binary); response << "HTTP/1.1 " << _statusCode << " " << _status << "\r\n"; for (std::vector<std::pair<std::string, std::string> >::iterator it = _headers.begin(); it != _headers.end(); it++) { response << it->first << ": " << it->second << "\r\n"; } if (_pBody) response << "Content-Length: " << _pBody->size() << "\r\n"; response << "\r\n"; std::string responseStr = response.str(); _responseHeader.assign(responseStr.begin(), responseStr.end()); uv_buf_t headerBuf = uv_buf_init(&_responseHeader[0], _responseHeader.size()); uv_write_t* pWriteReq = (uv_write_t*)malloc(sizeof(uv_write_t)); memset(pWriteReq, 0, sizeof(uv_write_t)); pWriteReq->data = this; int r = uv_write(pWriteReq, toStream(_pRequest->handle()), &headerBuf, 1, &on_response_written); if (r) { _pRequest->fatal_error("uv_write", uv_strerror(uv_last_error(_pRequest->handle()->loop))); delete this; free(pWriteReq); } }
string NodeValue::toString() const { stringstream ss; OutputLanguage outlang = (this == &s_null) ? language::output::LANG_AUTO : options::outputLanguage(); toStream(ss, -1, false, false, outlang); return ss.str(); }
void KWidgetStreamer::propertyToStream( const QObject* from, QDataStream& stream ) { // Only handle widgets. Alternatives to widgets are layouts, validators, timers, etc. if ( ! from->inherits("QWidget") ) return; // Serializing all the children (if any). const QObjectList* children = from->children(); if ( children ) { stream << children->count(); for ( QObjectListIt it = QObjectListIt(*children); *it; ++it ) { toStream( *it, stream ); } } else { stream << (unsigned int) 0; } // Now stream out properties for ( PropertyMapIt mapIt = _map.begin(); mapIt != _map.end(); mapIt++ ) { QString tp = mapIt.key(); PropertyList list = mapIt.data(); if ( from->inherits( tp.latin1() ) ) { for ( PropertyListIt it = list.begin(); it != list.end(); ++it ) { QVariant prop = from->property( (*it).latin1() ); if ( ! prop.isValid() ) qWarning("Invalid property: %s:%s", tp.latin1(), (*it).latin1() ); stream << prop ; } } } }
std::string LFP::toString() const { std::ostringstream oss; toStream(oss); return oss.str(); }
// ============================================================================ // print LorentzVector // ============================================================================ std::ostream& Gaudi::Utils::toStream ( const Gaudi::LorentzVector& obj, std::ostream& s ) { s << "( " ; toStream ( obj.Px () , s , 12 ) ; s << " , " ; toStream ( obj.Py () , s , 12 ) ; s << " , " ; toStream ( obj.Pz () , s , 13 ) ; s << " , " ; toStream ( obj.E () , s , 14 ) ; s << " )" ; return s ; }
/* Write binary representation of the kd-tree to file. */ bool VertexBufferRoot::writeToFile( const std::string& filename ) { bool result = false; std::ofstream output( getArchitectureFilename( filename ).c_str(), std::ios::out | std::ios::binary ); if( output ) { // enable exceptions on stream errors output.exceptions( std::ofstream::failbit | std::ofstream::badbit ); try { toStream( output ); result = true; } catch( const std::exception& e ) { MESHERROR << "Unable to write binary file, an exception " << "occured: " << e.what() << std::endl; } output.close(); } else { MESHERROR << "Unable to create binary file." << std::endl; } return result; }
void Map::toString(char* output_str) const { std::ostringstream stream; toStream(stream); std::string str = stream.str(); const char* stream_string = str.c_str(); strncpy(output_str, stream_string, strlen(stream_string)); }
std::ostream& toStream( std::ostream& os, const CommaSeparatedText& value ) { bool isfirst = true; for ( auto x : value.getValues() ) { if( isfirst ) { toStream( os, x ); isfirst = false; } else { os << ","; toStream( os, x ); } } return os; }
template<class T> Debug Debug::print(const T& value) { if(!output) return *this; /* Separate values with spaces, if enabled */ if(flags & 0x01) flags &= ~0x01; else if(flags & Debug::SpaceAfterEachValue) *output << " "; toStream(*output, value); return *this; }
bool TiXmlDocument::PHYSFS_SaveFile( const char * filename ) const { std::stringstream s; toStream(s, 0); PHYSFS_file* f = PHYSFS_openWrite(filename); PHYSFS_sint64 length_write = PHYSFS_write(f, s.str().c_str(), 1, (PHYSFS_uint32) s.str().length()); PHYSFS_close(f); if (length_write != s.str().length()) return false; return true; }
std::ostream& toStream( std::ostream& os, const NumberOrNormal& value ) { if ( value.getIsNumber() ) { toStream( os, value.getValueNumber() ); } else { os << "normal"; } return os; }
template<class T> Debug& Debug::print(const T& value) { if(!_output) return *this; /* Separate values with spaces, if enabled */ if(_flags & Flag::NoSpaceBeforeNextValue) _flags &= ~Flag::NoSpaceBeforeNextValue; else *_output << ' '; toStream(*_output, value); _flags |= Flag::ValueWritten; return *this; }
void HttpResponse::onResponseWritten(int status) { if (status != 0) { REprintf("Error writing response: %d\n", status); _pRequest->close(); delete this; return; } if (_pBody == NULL) { delete this; } else { HttpResponseExtendedWrite* pResponseWrite = new HttpResponseExtendedWrite( this, toStream(_pRequest->handle()), _pBody); pResponseWrite->begin(); } }
//------------------------------------------------------------------------------ void Logical::saveToFile(QString fileName) { QFile toFile(fileName); if (!toFile.open(QIODevice::WriteOnly)) { QMessageBox::critical(0, tr("Error"), tr("Can't open file to write")); } else { QTextStream toStream(&toFile); toStream.setCodec("UTF-8"); toStream << "#Life 1.05" << endl << "#P -" << (useWidth / 2) << " -" << (useHeight / 2) << endl; for (int i = 0; i < useHeight; ++i) { for (int j = 0; j < useWidth; ++j) { toStream << ((lPole[i][j] == 1) ? "*" : "."); } toStream << endl; } toFile.close(); } }
bool AddTool::_addOneFile(QString templateName, QString targetName, const QList<QPair<QRegExp, QString> > &mapping) { qDebug() << "Adding file:" << targetName << "from" << templateName; { //block to make sure file processing is done when we get out of it QFile templateFile(templateName); QFile targetFile(targetName); if(!targetFile.open(QIODevice::WriteOnly | QIODevice::Text)) { toolError(QString("Could not open file: ") + targetName + " for write."); return false; } if(!templateFile.open(QIODevice::ReadOnly | QIODevice::Text)) { toolError(QString("Could not open file: ") + templateName + " for read."); return false; } QTextStream fromStream(&templateFile); QTextStream toStream(&targetFile); transformStream(fromStream, toStream, mapping); } //Now add it to mercurial QProcess process; process.setWorkingDirectory(QFileInfo(targetName).absolutePath()); process.start(QString("hg add ") + QFileInfo(targetName).fileName()); if(!process.waitForFinished(3000)) //3 seconds delay { toolError(QString("Couldn't hg add the file: ") + targetName); return false; } FormatTool::formatFile(targetName); return true; }
StringType toString( const CommaSeparatedText& value ) { std::stringstream ss; toStream( ss, value ); return ss.str(); }
std::ostream& operator<<( std::ostream& os, const CommaSeparatedText& value ) { return toStream( os, value ); }
std::ostream& operator<<( std::ostream& os, const YesNoNumber& value ) { return toStream( os, value ); }
std::string toString( const YesNoNumber& value ) { std::stringstream ss; toStream( ss, value ); return ss.str(); }
std::ostream& operator<<( std::ostream& os, const FontSize& value ) { return toStream( os, value ); }
std::string FragmentCatalogEntry::Serialize() const { std::stringstream ss(std::ios_base::binary | std::ios_base::out | std::ios_base::in); toStream(ss); return ss.str(); }
// //////////////////////////////////////////////////////////////////// void HistoricalBookingHolder::display() const { toStream (std::cout); }
void SExpr::toStream(std::ostream& out, const SExpr& sexpr, OutputLanguage language) throw() { toStream(out, sexpr, language, PrettySExprs::getPrettySExprs(out) ? 2 : 0); }
void SExpr::toStream(std::ostream& out, const SExpr& sexpr) throw() { toStream(out, sexpr, language::SetLanguage::getLanguage(out)); }
std::string PreciseDecimal::toString() const { std::stringstream ss; toStream( ss ); return ss.str(); }
std::string LLDate::asString() const { std::ostringstream stream; toStream(stream); return stream.str(); }
std::string FragCatParams::Serialize() const { std::stringstream ss; toStream(ss); return ss.str(); }