예제 #1
0
		std::ostream& toStream( std::ostream& os, const YesNoNumber& value )
        {
            if ( value.getIsNumber() )
            {
                toStream( os, value.getValueNumber() );
            }
            else
            {
                toStream( os, value.getValueYesNo() );
            }
            return os;
        }
예제 #2
0
// ============================================================================
// 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 ;
}
예제 #3
0
		std::ostream& toStream( std::ostream& os, const FontSize& value )
        {
            if ( value.getIsNumber() )
            {
                toStream( os, value.getValueNumber() );
            }
            else
            {
                toStream( os, value.getValueCssFontSize() );
            }
            return os;
        }
예제 #4
0
파일: http.cpp 프로젝트: jcheng5/httpuv
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);
  }
}
예제 #5
0
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();
}
예제 #6
0
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 ;
      }
    }
  }
}
예제 #7
0
파일: lfpfunc.cpp 프로젝트: benjit89/ntp
std::string
LFP::toString() const
{
	std::ostringstream oss;
	toStream(oss);
	return oss.str();
}
예제 #8
0
// ============================================================================
// 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 ;
}
예제 #9
0
/*  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;
}
예제 #10
0
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));
}
예제 #11
0
파일: Strings.cpp 프로젝트: Webern/MxProg
 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;
 }
예제 #12
0
파일: Debug.cpp 프로젝트: DYSEQTA/corrade
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;
}
예제 #13
0
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;
}
예제 #14
0
		std::ostream& toStream( std::ostream& os, const NumberOrNormal& value )
        {
            if ( value.getIsNumber() )
            {
                toStream( os, value.getValueNumber() );
            }
            else
            {
                os << "normal";
            }
            return os;
        }
예제 #15
0
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;
}
예제 #16
0
파일: http.cpp 프로젝트: jcheng5/httpuv
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();
  }
}
예제 #17
0
파일: logical.cpp 프로젝트: maindefine/life
//------------------------------------------------------------------------------
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();
    }
}
예제 #18
0
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;
}
예제 #19
0
파일: Strings.cpp 프로젝트: Webern/MxProg
 StringType toString( const CommaSeparatedText& value )
 {
     std::stringstream ss;
     toStream( ss, value );
     return ss.str();
 }
예제 #20
0
파일: Strings.cpp 프로젝트: Webern/MxProg
 std::ostream& operator<<( std::ostream& os, const CommaSeparatedText& value )
 {
     return toStream( os, value );
 }
예제 #21
0
		std::ostream& operator<<( std::ostream& os, const YesNoNumber& value )
        {
            return toStream( os, value );
        }
예제 #22
0
 std::string toString( const YesNoNumber& value )
 {
     std::stringstream ss;
     toStream( ss, value );
     return ss.str();
 }
예제 #23
0
		std::ostream& operator<<( std::ostream& os, const FontSize& value )
        {
            return toStream( os, value );
        }
예제 #24
0
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);
 }
예제 #26
0
파일: sexpr.cpp 프로젝트: g2graman/CVC4
void SExpr::toStream(std::ostream& out, const SExpr& sexpr, OutputLanguage language) throw() {
  toStream(out, sexpr, language, PrettySExprs::getPrettySExprs(out) ? 2 : 0);
}
예제 #27
0
파일: sexpr.cpp 프로젝트: g2graman/CVC4
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();
 }
예제 #29
0
파일: lldate.cpp 프로젝트: Boy/netbook
std::string LLDate::asString() const
{
	std::ostringstream stream;
	toStream(stream);
	return stream.str();
}
예제 #30
0
std::string FragCatParams::Serialize() const {
  std::stringstream ss;
  toStream(ss);
  return ss.str();
}