本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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_();
}
示例5:
std::string
StringTools::toString( double value )
{
OStringStream stream;
stream << value;
return stream.str();
}
示例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_();
}
示例7:
String
XMLNodeImpl::toString() const
{
OStringStream ss;
printNode( ss );
return ss.releaseString();
}
示例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());
}
示例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())());
}
示例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);
}
}
示例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();
}
示例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;
}
示例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());
}
}
示例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;
}
示例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));
}