本文整理汇总了C++中OStringStream::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ OStringStream::toString方法的具体用法?C++ OStringStream::toString怎么用?C++ OStringStream::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OStringStream
的用法示例。
在下文中一共展示了OStringStream::toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSomething
void OW_StringStreamTestCases::testSomething()
{
OStringStream ss;
ss << "O";
unitAssert(ss.length() == 1);
unitAssert(ss.toString().equals("O"));
ss.reset();
unitAssert(ss.length() == 0);
unitAssert(ss.toString().equals(""));
ss << String("Hello World");
unitAssert(ss.length() == 11);
unitAssert(ss.toString().equals("Hello World"));
}
示例2: 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());
}
}
示例3: CIMtoXML
//.........这里部分代码省略.........
break;
}
case CIMDataType::STRING:
{
StringArray a;
cv.get(a);
raToXmlSA(out, a);
break;
}
case CIMDataType::DATETIME:
{
CIMDateTimeArray a;
cv.get(a);
raToXml(out, a);
break;
}
case CIMDataType::REFERENCE:
{
CIMObjectPathArray a;
cv.get(a);
raToXmlCOP(out, a);
break;
}
case CIMDataType::EMBEDDEDCLASS:
{
CIMClassArray ca;
cv.get(ca);
StringArray sa;
for (size_t i = 0; i < ca.size(); ++i)
{
OStringStream ss;
CIMtoXML(ca[i], ss);
sa.push_back(ss.toString());
}
raToXmlSA(out, sa);
break;
}
case CIMDataType::EMBEDDEDINSTANCE:
{
CIMInstanceArray ia;
cv.get(ia);
StringArray sa;
for (size_t i = 0; i < ia.size(); ++i)
{
OStringStream ss;
CIMInstancetoXML(ia[i],ss);
sa.push_back(ss.toString());
}
raToXmlSA(out, sa);
break;
}
default:
OW_ASSERT(0);
}
}
else if (cv.getType() == CIMDataType::REFERENCE)
{
out << "<VALUE.REFERENCE>";
CIMObjectPath a(CIMNULL);
cv.get(a);
if (a.getFullNameSpace().isLocal())
{
if (a.getNameSpace().empty())
{