当前位置: 首页>>代码示例>>C++>>正文


C++ OStringStream类代码示例

本文整理汇总了C++中OStringStream的典型用法代码示例。如果您正苦于以下问题:C++ OStringStream类的具体用法?C++ OStringStream怎么用?C++ OStringStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OStringStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: update

	void Framework::update(){

		OStringStream o;
		o << "aho" << endl; //const char*
		char ts[ 3 ];
		ts[ 0 ] = 'O';
		ts[ 1 ] = 'K';
		ts[ 2 ] = '\0';
		o << ts << endl; //char*
		o << string( "baka" ) << endl; //string
		o << RefString( "tonma" ) << endl; //RefString
		o << 'a' << endl; //char
		o << '\n'; //char ( new-line )
		o << static_cast< char >( -74 ) << endl; //char (out of range )
		o << static_cast< char >( 14 ) << endl; //char (out of range )
		o << static_cast< unsigned char >( 99 ) << endl; //unsigned char
		o << static_cast< short >( -9999 ) << endl; //short
		o << static_cast< unsigned short >( 65534 ) << endl; //unsigned short
		o << static_cast< int >( -2012345678 ) << endl; //int
		o << static_cast< unsigned >( 4012345678 ) << endl; //unsigned

		o.precision( 7 );
		o << 50.00000000000 << endl;
		o << 0.09999999999f << endl;
		o << 0.0399999999f << endl;
		o << 1.f << endl; //float ( 1 )
		o << 1.5f << endl; //float ( 1 )
		o << 1.75f << endl; //float ( 1 )
		o << 152423.f << endl; //float ( 1 )
		o << -123456789.f * 1000000.f << endl; //float (big)
		o << -1.23456789f * 0.000000001f << endl; //float (small)
//		o.precision( 15 );
		o << -1.23456789f * 0.000000001f << endl; //float (small)
o << -134.56712839f << endl;
o << -0.056712839f << endl;
		o << 0.0 << endl; //float +0
		o << -0.0 << endl; //float -0
		o << sqrtf( -1.f ) << endl; //float NaN
		o << -1e30f * 1e30f << endl; //float +Inf
		o << 1e-30f * 1e-30f << endl; //float -Denorm
		o << -numeric_limits< float >::max() << endl; //float max
		o << numeric_limits< float >::min() << endl; //float min

		o << -123456789.0 * 1000000.0 << endl; //double (big)
		o << -1.234567890 * 0.000000001 << endl; //double (small)
		o << 0.0 << endl; //double +0
		o << -0.0 << endl; //double -0
		o << sqrt( -1.0 ) << endl; //double NaN
		o << -1e300 * 1e300 << endl; //double +Inf
		o << 1e-300 * 1e-300 << endl; //double -Denorm
		o << -numeric_limits< double >::max() << endl; //double max

		Array< char > out;
		o.get( &out );
		cout << &out[ 0 ] << endl;

		cout << o << endl;

		requestEnd();
	}
开发者ID:rainbow23,项目名称:GameLib2008,代码行数:60,代码来源:main.cpp

示例2: toString

 static std::string toString(const std::vector<DATA> &values)
 {
   OStringStream ost;
   for (auto v : values)
     ost << "'" << v << "' "; // adds quote around the string to see whitespace
   return ost.str();
 }
开发者ID:Cdebus,项目名称:MITK,代码行数:7,代码来源:mitkVectorPropertyTest.cpp

示例3: writeData

Ostream& writeData(
    Ostream &o,
    Type value,
    const string annotation,
    const word header,
    bool newLine=false
) {
    const label annotationLen=25;
    if(annotation!="") {
        o << annotation.c_str();
        for(label i=0;i<(annotationLen-label(annotation.size()));i++) {
            o << " ";
        }
    }
    writeValue(o,value);
    for(direction i=0;i<pTraits<Type>::nComponents;i++) {
        scalar v=component(value,i);
        csvHeader+=","+header;
        if(pTraits<Type>::nComponents>1) {
            csvHeader+=string(" ")+pTraits<Type>::componentNames[i];
        }
        OStringStream s;
        s << v;
        csvLine+=","+s.str();
    }
    if(newLine) {
        o << endl;
    }
    return o;
}
开发者ID:martinep,项目名称:foam-extend-svn,代码行数:30,代码来源:fieldReport.C

示例4: is

const Foam::fvPatchField<Type>&
Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
{
    if (!redirectPatchFieldPtr_.valid())
    {
        // Construct a patch
        // Make sure to construct the patchfield with up-to-date value

        OStringStream os;
        os.writeKeyword("type") << redirectType_ << token::END_STATEMENT
            << nl;
        static_cast<const Field<Type>&>(*this).writeEntry("value", os);
        IStringStream is(os.str());
        dictionary dict(is);

        redirectPatchFieldPtr_.set
        (
            fvPatchField<Type>::New
            (
                this->patch(),
                this->dimensionedInternalField(),
                dict
            ).ptr()
        );
    }
    return redirectPatchFieldPtr_();
}
开发者ID:ADGlassby,项目名称:OpenFOAM-2.2.x,代码行数:27,代码来源:codedFixedValueFvPatchField.C

示例5:

std::string 
StringTools::toString( double value )
{
  OStringStream stream;
  stream << value;
  return stream.str();
}
开发者ID:LTears,项目名称:rktotal,代码行数:7,代码来源:StringTools.cpp

示例6: is

const Foam::mixedFvPatchField<Type>&
Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
{
    if (!redirectPatchFieldPtr_.valid())
    {
        // Construct a patch
        // Make sure to construct the patchfield with up-to-date value

        // Write the data from the mixed b.c.
        OStringStream os;
        mixedFvPatchField<Type>::write(os);
        IStringStream is(os.str());
        // Construct dictionary from it.
        dictionary dict(is);

        // Override the type to enforce the fvPatchField::New constructor
        // to choose our type
        dict.set("type", name_);

        redirectPatchFieldPtr_.set
        (
            dynamic_cast<mixedFvPatchField<Type>*>
            (
                fvPatchField<Type>::New
                (
                    this->patch(),
                    this->internalField(),
                    dict
                ).ptr()
            )
        );
    }
    return redirectPatchFieldPtr_();
}
开发者ID:OpenFOAM,项目名称:OpenFOAM-dev,代码行数:34,代码来源:codedMixedFvPatchField.C

示例7:

String
XMLNodeImpl::toString() const
{
	OStringStream ss;
	printNode( ss );
	return ss.releaseString();
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:7,代码来源:OW_XMLNode.cpp

示例8: forAll

void Foam::vtkPVblockMesh::updateInfoEdges
(
    vtkDataArraySelection* arraySelection
)
{
    if (debug)
    {
        Info<< "<beg> Foam::vtkPVblockMesh::updateInfoEdges"
            << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
    }

    arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );

    const blockMesh& blkMesh = *meshPtr_;
    const curvedEdgeList& edges = blkMesh.edges();

    const int nEdges = edges.size();
    forAll(edges, edgeI)
    {
        OStringStream ostr;

        ostr<< edges[edgeI].start() << ":" << edges[edgeI].end() << " - "
            << edges[edgeI].type();

        // Add "beg:end - type" to GUI list
        arraySelection->AddArray(ostr.str().c_str());
    }
开发者ID:BarisCumhur,项目名称:OpenFOAM-dev,代码行数:27,代码来源:vtkPVblockMesh.C

示例9: entry

Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const T& t)
:
    entry(keyword),
    ITstream(keyword, tokenList(10))
{
    OStringStream os;
    os << t << token::END_STATEMENT;
    readEntry(dictionary::null, IStringStream(os.str())());
}
开发者ID:Cescfangs,项目名称:OpenFOAM-1.7.x,代码行数:9,代码来源:primitiveEntryTemplates.C

示例10: ASSERT_ANY_COMPARE

void Assertion::ASSERT_ANY_COMPARE(const ROAnything &inputAny, const ROAnything &masterAny, String location, char delimSlot, char idxdelim) {
	OStringStream s;
	String failingPath(location);
	if(!AnyUtils::AnyCompareEqual(inputAny, masterAny, failingPath,&s, delimSlot, idxdelim)) {
		String strfail(failingPath);
		strfail << "\n" << s.str();
		ASSERTM((const char*)strfail, false);
	}
}
开发者ID:chenbk85,项目名称:CuteTestForCoastTest,代码行数:9,代码来源:AssertionAnything.cpp

示例11: toString

		static std::string toString(const EERIEMATRIX &matrix) {
			OStringStream ost;
			ost << std::endl << std::fixed;
			ost << matrix._11 << "\t" << matrix._12 << "\t" << matrix._13 << "\t" << matrix._14 << std::endl;
			ost << matrix._21 << "\t" << matrix._22 << "\t" << matrix._23 << "\t" << matrix._24 << std::endl;
			ost << matrix._31 << "\t" << matrix._32 << "\t" << matrix._33 << "\t" << matrix._34 << std::endl;
			ost << matrix._41 << "\t" << matrix._42 << "\t" << matrix._43 << "\t" << matrix._44 << std::endl;
			return ost.str();
		}
开发者ID:AlexMarlo,项目名称:ArxLibertatis,代码行数:9,代码来源:GraphicsUtilityTest.cpp

示例12: if

Foam::string Foam::stringOps::getVariable
(
    const word& name,
    const dictionary& dict,
    const bool allowEnvVars,
    const bool allowEmpty
)
{
    string value;

    const entry* ePtr = dict.lookupScopedEntryPtr
    (
        name,
        true,
        false
    );
    if (ePtr)
    {
        OStringStream buf;
        // Force floating point numbers to be printed with at least
        // some decimal digits.
        buf << fixed;
        buf.precision(IOstream::defaultPrecision());

        // fail for non-primitiveEntry
        dynamicCast<const primitiveEntry>
        (
            *ePtr
        ).write(buf, true);

        value = buf.str();
    }
    else if (allowEnvVars)
    {
        value = getEnv(name);

        if (value.empty())
        {
            FatalIOErrorInFunction
            (
                dict
            )   << "Cannot find dictionary or environment variable "
                << name << exit(FatalIOError);
        }
    }
    else
    {
        FatalIOErrorInFunction
        (
            dict
        )   << "Cannot find dictionary variable "
            << name << exit(FatalIOError);
    }

    return value;
}
开发者ID:mattijsjanssens,项目名称:mattijs-extensions,代码行数:56,代码来源:stringOps.C

示例13: sendAuthorization

void HTTPClient::sendAuthorization()
{
    if ( !m_sAuthorization.empty())
    {
        OStringStream ostr;
        ostr << m_sAuthorization << " ";
        if ( m_sAuthorization == "Basic" )
        {
            getCredentialsIfNecessary();
            ostr << HTTPUtils::base64Encode( m_url.principal + ":" +
                                             m_url.credential );
        }
#ifndef OW_DISABLE_DIGEST
        else if ( m_sAuthorization == "Digest" )
        {
            String sNonceCount;
            sNonceCount.format( "%08x", m_iDigestNonceCount );
            HTTPUtils::DigestCalcResponse( m_sDigestSessionKey, m_sDigestNonce, sNonceCount,
                                           m_sDigestCNonce, "auth", m_requestMethod, m_httpPath, "", m_sDigestResponse );
            ostr << "username=\"" << m_url.principal << "\", ";
            ostr << "realm=\"" << m_sRealm << "\", ";
            ostr << "nonce=\"" << m_sDigestNonce << "\", ";
            ostr << "uri=\"" + m_httpPath + ", ";
            ostr << "qop=\"auth\", ";
            ostr << "nc=" << sNonceCount << ", ";
            ostr << "cnonce=\"" << m_sDigestCNonce << "\", ";
            ostr << "response=\"" << m_sDigestResponse << "\"";
            m_iDigestNonceCount++;
        }
#endif
        else if (m_sAuthorization == "OWLocal")
        {
            if (m_localNonce.empty())
            {
                // first round - we just send our euid

                ostr << "uid=\"" << UserUtils::getEffectiveUserId() << "\"";
            }
            else
            {
                // second round - send the nonce and the cookie

                // first try to read the cookie
                std::ifstream cookieFile(m_localCookieFile.c_str());
                if (!cookieFile)
                {
                    OW_THROW_ERR(HTTPException, Format("Unable to open local authentication file: %1", strerror(errno)).c_str(), m_statusCode);
                }
                String cookie = String::getLine(cookieFile);
                ostr << "nonce=\"" << m_localNonce << "\", ";
                ostr << "cookie=\"" << cookie << "\"";
            }
        }
        addHeaderNew("Authorization", ostr.toString());
    }
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:56,代码来源:OW_HTTPClient.cpp

示例14: set_args_

 explicit set_args_(const Range &args)
 {
     OStringStream os;
     boost::for_each(args, boost::bind(&set_args_::add, this,
         _1, boost::ref(os)));
     String s = os.str();
     cmd_line_.reset(new Char[s.size() + 1]);
     boost::copy(s, cmd_line_.get());
     cmd_line_[s.size()] = 0;
 }
开发者ID:pbondo,项目名称:uniproxy,代码行数:10,代码来源:set_args.hpp

示例15: topology

Foam::PtrList<Foam::dictionary> Foam::blockMesh::patchDicts() const
{
    const polyPatchList& patchTopologies = topology().boundaryMesh();

    PtrList<dictionary> patchDicts(patchTopologies.size());

    forAll(patchTopologies, patchI)
    {
        OStringStream os;
        patchTopologies[patchI].write(os);
        IStringStream is(os.str());
        patchDicts.set(patchI, new dictionary(is));
    }
开发者ID:AmaneShino,项目名称:OpenFOAM-2.0.x,代码行数:13,代码来源:blockMesh.C


注:本文中的OStringStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。