Пример #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
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
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
 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
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
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
//------------------------------------------------------------------------------
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
 StringType toString( const CommaSeparatedText& value )
 {
     std::stringstream ss;
     toStream( ss, value );
     return ss.str();
 }
Пример #20
0
 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
void SExpr::toStream(std::ostream& out, const SExpr& sexpr, OutputLanguage language) throw() {
  toStream(out, sexpr, language, PrettySExprs::getPrettySExprs(out) ? 2 : 0);
}
Пример #27
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();
 }
Пример #29
0
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();
}