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


C++ StringBuilder::ToString方法代码示例

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


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

示例1: if

ECode CWifiP2pDnsSdServiceResponse::ReadDnsName(
    /* [in] */ IDataInput* idi,
    /* [out] */ String* dnsName)
{
    VALIDATE_NOT_NULL(dnsName);
    *dnsName = String(NULL);

    StringBuilder sb;

    // copy virtual memory packet.
    HashMap<Int32, String> vmpack;
    HashMap<Int32, String>::Iterator it;

    if (!mDnsQueryName.IsNull()) {
        vmpack[0x27] = mDnsQueryName;
    }

    // try {
    Int32 i, temp;
    while (TRUE) {
        FAIL_RETURN(idi->ReadUnsignedByte(&i));
        if (i == 0x00) {
            *dnsName = sb.ToString();
            return NOERROR;
        }
        else if (i == 0xc0) {
            // refer to pointer.
            FAIL_RETURN(idi->ReadUnsignedByte(&temp));
            it = vmpack.Find(temp);
            if (it == vmpack.End()) {
                //invalid.
                return NOERROR;
            }

            sb += it->mSecond;
            *dnsName = sb.ToString();
            return NOERROR;
        }
        else {
            AutoPtr<ArrayOf<Byte> > data = ArrayOf<Byte>::Alloc(i);
            if (data == NULL) return E_OUT_OF_MEMORY;

            FAIL_RETURN(idi->ReadFully((ArrayOf<Byte>*)data));
            sb += String((const char *)data->GetPayload());
            sb += ".";
        }
    }
    // catch (IOException e) {
    //     e.printStackTrace();
    // }

    return NOERROR;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:53,代码来源:CWifiP2pDnsSdServiceResponse.cpp

示例2: TryGetMyContactsGroupId

ECode CContactsPeople::TryGetMyContactsGroupId(
    /* [in] */ IContentResolver* resolver,
    /* [out] */ Int64* id)
{
    VALIDATE_NOT_NULL(id);

    AutoPtr<IContactsGroups> helper;
    CContactsGroups::AcquireSingleton((IContactsGroups**)&helper);
    AutoPtr<IUri> uri;
    helper->GetCONTENT_URI((IUri**)&uri);
    StringBuilder builder;
    builder += IContactsGroupsColumns::SYSTEM_ID;
    builder += "='";
    builder += IContactsGroups::GROUP_MY_CONTACTS;
    builder += "'";
    String selection = builder.ToString();
    AutoPtr<ICursor> groupsCursor;
    resolver->Query(uri, GROUPS_PROJECTION, selection, NULL, String(NULL), (ICursor**)&groupsCursor);
    if (groupsCursor != NULL) {
        //try {
        Boolean result;
        ECode ec = groupsCursor->MoveToFirst(&result);
        if (SUCCEEDED(ec) && result) {
            groupsCursor->GetInt64(0, id);
            ICloseable::Probe(groupsCursor)->Close();
            return NOERROR;
        }
        //} finally {
        ICloseable::Probe(groupsCursor)->Close();
        //}
    }
    *id = 0;
    return NOERROR;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:34,代码来源:CContactsPeople.cpp

示例3: GetUserAgent

static String GetUserAgent()
{
    StringBuilder builder;

    Boolean validRelease = !TextUtils::IsEmpty(Build::VERSION::RELEASE);
    Boolean validId = !TextUtils::IsEmpty(Build::ID);
    Boolean includeModel = Build::VERSION::CODENAME.Equals("REL")
            && !TextUtils::IsEmpty(Build::MODEL);

    builder.Append("AndroidDownloadManager");
    if (validRelease) {
        builder.Append("/");
        builder.Append(Build::VERSION::RELEASE);
    }
    builder.Append(" (Linux; U; Android");
    if (validRelease) {
        builder.Append(" ");
        builder.Append(Build::VERSION::RELEASE);
    }
    if (includeModel || validId) {
        builder.Append(";");
        if (includeModel) {
            builder.Append(" ");
            builder.Append(Build::MODEL);
        }
        if (validId) {
            builder.Append(" Build/");
            builder.Append(Build::ID);
        }
    }
    builder.Append(")");

    String str = builder.ToString();
    return str;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:35,代码来源:Constants.cpp

示例4: ComposeSearchUrl

String URLUtil::ComposeSearchUrl(
    /* [in] */ const String& inQuery,
    /* [in] */ const String& templateStr,
    /* [in] */ const String& queryPlaceHolder)
{
    Int32 placeHolderIndex = templateStr.IndexOf(queryPlaceHolder);
    if (placeHolderIndex < 0) {
        return String(NULL);
    }

    String query;
    StringBuilder buffer;
    buffer.AppendString(templateStr.Substring(0, placeHolderIndex));

    //try {
    //    query = java.net.URLEncoder.encode(inQuery, "utf-8");
    AutoPtr<IURLEncoder> URLEncoder;
    assert(0);
//    	CURLEncoder::New((IURLEncoder**)&URLEncoder);
    if (FAILED(URLEncoder->Encode(inQuery, String("utf-8"), &query))){
        return String(NULL);
    }
    buffer.AppendString(query);
    //} catch (UnsupportedEncodingException ex) {
    //    return null;
    //}

    buffer.AppendString(templateStr.Substring(
            placeHolderIndex + queryPlaceHolder.GetLength()));

    return buffer.ToString();
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:32,代码来源:URLUtil.cpp

示例5: ToString

ECode ItemInfo::ToString(
    /* [out] */ String* str)
{
    VALIDATE_NOT_NULL(str);

    StringBuilder sb;
    sb += "Item(id=";
    sb += mId;
    sb += " type=";
    sb += mItemType;
    sb += " container=";
    sb += mContainer;
    sb += " screen=";
    sb += mScreen;
    sb += " cellX=";
    sb += mCellX;
    sb += " cellY=";
    sb += mCellY;
    sb += " spanX=";
    sb += mSpanX;
    sb += " spanY=";
    sb += mSpanY;

    sb += " dropPos=";
    sb += "(";
    for (Int32 i = 0; i < mDropPos->GetLength(); i++) {
        sb += (*mDropPos)[i];
    }
    sb += ")";

    sb += " user=";
    sb += TO_STR(mUser);
    sb += ")";
    return sb.ToString(str);
}
开发者ID:maerson,项目名称:CPP_Framework_Elastos5,代码行数:35,代码来源:ItemInfo.cpp

示例6: ToString

//@Override
ECode CNetworkStatsEntry::ToString(
    /* [out] */ String* result)
{
    StringBuilder builder;
    builder += String("iface=");
    builder += mIface;
    builder += String(" uid=");
    builder += StringUtils::ToString(mUid);
    builder += String(" set=");
    builder += StringUtils::ToString(mSet);
    builder += String(" tag=");
    builder += StringUtils::ToString(mTag);
    builder += String(" rxBytes=");
    builder += StringUtils::ToString(mRxBytes);
    builder += String(" rxPackets=");
    builder += StringUtils::ToString(mRxPackets);
    builder += String(" txBytes=");
    builder += StringUtils::ToString(mTxBytes);
    builder += String(" txPackets=");
    builder += StringUtils::ToString(mTxPackets);
    builder += String(" operations=");
    builder += StringUtils::ToString(mOperations);
    *result = builder.ToString();
    return NOERROR;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:26,代码来源:CNetworkStatsEntry.cpp

示例7: test

 bool test()
 {
   StringBuilder sb;
   sb.Append("asdfgqwert");
   sb.Remove(5, 10);
   return (*sb.ToString() == "asdfg");
 }
开发者ID:praveenster,项目名称:leplib,代码行数:7,代码来源:TestStringBuilder.cpp

示例8: ToString

ECode BasicClientCookie::ToString(
    /* [out] */ String* str)
{
    VALIDATE_NOT_NULL(str)
    StringBuilder buffer;
    buffer.Append("[version: ");
    buffer.Append(StringUtils::ToString(mCookieVersion));
    buffer.Append("]");
    buffer.Append("[name: ");
    buffer.Append(mName);
    buffer.Append("]");
    buffer.Append("[value: ");
    buffer.Append(mValue);
    buffer.Append("]");
    buffer.Append("[domain: ");
    buffer.Append(mCookieDomain);
    buffer.Append("]");
    buffer.Append("[path: ");
    buffer.Append(mCookiePath);
    buffer.Append("]");
    buffer.Append("[expiry: ");
    buffer.Append(mCookieExpiryDate);
    buffer.Append("]");
    *str = buffer.ToString();
    return NOERROR;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:26,代码来源:BasicClientCookie.cpp

示例9: testAppend

void testAppend()
{
    printf("\n===============testAppend===============\n");
    String className("SoftKeyboard.CSoftKeyboard");
    Int32 length = className.GetLength();
    String tmp(".CSoftKeyboard");
    String str1("SoftKeyboard");

    String str3 = String(className.string() + 12, length - 12);

    printf("[.CSoftKeyboard] is %d\n", strlen(".CSoftKeyboard"));
    printf("tmp: [%s], tmp length: %d\n", tmp.string(), tmp.GetLength());
    printf("str3: [%s], length - 12: %d, str3 length: %d\n", str3.string(), length - 12, str3.GetLength());

    printf("\n");
    String str2 = className.Substring(12, length);
    printf("str2: [%s], str2 length: %d\n", str2.string(), str2.GetLength());

    StringBuilder sb;
    sb += str1;
    sb += "/";

    // printf(" result is %s\n", sb.ToString().string());

    sb += str2;

    printf(" result is %s\n", sb.ToString().string());
}
开发者ID:imace,项目名称:ElastosRDK5_0,代码行数:28,代码来源:test.cpp

示例10: ShowUsage

/**
 * Print how to use this command.
 */
void Monkey::ShowUsage()
{
    StringBuilder usage;
    usage.AppendCStr("usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]\n");
    usage.AppendCStr("              [-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]\n");
    usage.AppendCStr("              [--ignore-crashes] [--ignore-timeouts]\n");
    usage.AppendCStr("              [--ignore-security-exceptions]\n");
    usage.AppendCStr("              [--monitor-native-crashes] [--ignore-native-crashes]\n");
    usage.AppendCStr("              [--kill-process-after-error] [--hprof]\n");
    usage.AppendCStr("              [--pct-touch PERCENT] [--pct-motion PERCENT]\n");
    usage.AppendCStr("              [--pct-trackball PERCENT] [--pct-syskeys PERCENT]\n");
    usage.AppendCStr("              [--pct-nav PERCENT] [--pct-majornav PERCENT]\n");
    usage.AppendCStr("              [--pct-appswitch PERCENT] [--pct-flip PERCENT]\n");
    usage.AppendCStr("              [--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]\n");
    usage.AppendCStr("              [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]\n");
    usage.AppendCStr("              [--pkg-whitelist-file PACKAGE_WHITELIST_FILE]\n");
    usage.AppendCStr("              [--wait-dbg] [--dbg-no-events]\n");
    usage.AppendCStr("              [--setup scriptfile] [-f scriptfile [-f scriptfile] ...]\n");
    usage.AppendCStr("              [--port port]\n");
    usage.AppendCStr("              [-s SEED] [-v [-v] ...]\n");
    usage.AppendCStr("              [--throttle MILLISEC] [--randomize-throttle]\n");
    usage.AppendCStr("              [--profile-wait MILLISEC]\n");
    usage.AppendCStr("              [--device-sleep-time MILLISEC]\n");
    usage.AppendCStr("              [--randomize-script]\n");
    usage.AppendCStr("              [--script-log]\n");
    usage.AppendCStr("              [--bugreport]\n");
    usage.AppendCStr("              [--periodic-bugreport]\n");
    usage.AppendCStr("              COUNT\n");
    PFL_EX(usage.ToString().string());
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:33,代码来源:Monkey.cpp

示例11: ToString

			String ToString(TArgs&& ... args)
			{
				StringBuilder builder;
				int callerArr[] = { 0, ((void)builder.Append(Forward<TArgs>(args)), 0) ... }; // Only the expressions using param pack in initializer list can be executed(compiled). As an optimization, this array will be omitted by compiler generally. The second 0 provides values of type [long] that satisfies the type of $callerArr. For more detail about the second 0, check out comma operator.

				return builder.ToString();
			}
开发者ID:PENGUINLIONG,项目名称:LiongPlus,代码行数:7,代码来源:StringFormatter.hpp

示例12: ToString

ECode DateFormatSymbols::ToString(
    /* [out] */ String* str)
{
    VALIDATE_NOT_NULL(str)

    // 'locale' isn't part of the externally-visible state.
    // 'zoneStrings' is so large, we just print a representative value.

    StringBuilder sb;
    sb.Append("DateFormatSymbols");
    sb.Append("[amPmStrings=");
    sb.Append(Arrays::ToString(mAmpms));
    sb.Append(",eras=");
    sb.Append(Arrays::ToString(mEras));
    sb.Append(",localPatternChars=");
    sb.Append(mLocalPatternChars);
    sb.Append(",months=");
    sb.Append(Arrays::ToString(mMonths));
    sb.Append(",shortMonths=");
    sb.Append(Arrays::ToString(mShortMonths));
    sb.Append(",shortWeekdays=");
    sb.Append(Arrays::ToString(mShortWeekdays));
    sb.Append(",weekdays=");
    sb.Append(Arrays::ToString(mWeekdays));
    sb.Append(",zoneStrings=[");
    AutoPtr<ArrayOf<IArrayOf*> > lzs = InternalZoneStrings();
    sb.Append(Object::ToString((*lzs)[0]));
    sb.Append("...]]");

    *str = sb.ToString();
    return NOERROR;
}
开发者ID:maerson,项目名称:CPP_Framework_Elastos5,代码行数:32,代码来源:DateFormatSymbols.cpp

示例13: QuoteNameIfNecessary

ECode Rfc822Token::ToString(
    /* [out] */ String* str)
{
    VALIDATE_NOT_NULL(str)
    StringBuilder sb;

    if (!mName.IsNullOrEmpty()) {
        String qn;
        QuoteNameIfNecessary(mName, &qn);
        sb.Append(qn);
        sb.AppendChar(' ');
    }

    if (!mComment.IsNullOrEmpty()) {
            sb.AppendChar('(');
            String qn;
            QuoteComment(mComment, &qn);
            sb.Append(qn);
            sb.Append(") ");
    }

    if (!mAddress.IsNullOrEmpty()) {
        sb.AppendChar('<');
        sb.Append(mAddress);
        sb.AppendChar('>');
    }

    *str = sb.ToString();
    return NOERROR;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:30,代码来源:Rfc822Token.cpp

示例14: ToString

 RF_Type::Bool ToString()
 {
     StringBuilder builder;
     builder.Append("hi");
     auto result = builder.ToString();
     return result->Size() == 3 && result->Length() == 2;
 }
开发者ID:wangscript,项目名称:RadonFramework,代码行数:7,代码来源:StringBuilder.cpp

示例15: FormatTime

String DateTime::FormatTime(DateFormat format) const
{
	StringBuilder sbFinal;
	wchar szBuffer[12];

	FormatInt32(m_hour, szBuffer, 2, '0');
	sbFinal += szBuffer;

	if( format != DateFormat::Compact )
	{
		sbFinal += ":";
	}
	FormatInt32(m_minute, szBuffer, 2, '0');
	sbFinal += szBuffer;


	if( format != DateFormat::Compact )
	{
		sbFinal += ":";
	}
	FormatInt32(m_second, szBuffer, 2, '0');
	sbFinal += szBuffer;

	return sbFinal.ToString();
}
开发者ID:cloudflare,项目名称:pngoptimizer,代码行数:25,代码来源:DateTime.cpp


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