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


C++ OStringStream::toString方法代码示例

本文整理汇总了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"));
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:15,代码来源:OW_StringStreamTestCases.cpp

示例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());
    }
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:56,代码来源:OW_HTTPClient.cpp

示例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())
			{
开发者ID:kkaempf,项目名称:openwbem,代码行数:67,代码来源:OW_CIMtoXML.cpp


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