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


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

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


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

示例1: 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

示例2: AppendHex

ECode UriCodec::AppendHex(
    /* [in] */ StringBuilder& builder,
    /* [in] */ Byte b)
{
    builder.AppendChar('%');
    builder.Append(IntegralToString::ToHexString(b, TRUE));
    return NOERROR;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:8,代码来源:UriCodec.cpp

示例3: AppendEncoded

ECode UriCodec::AppendEncoded(
    /* [in] */ StringBuilder & builder,
    /* [in] */ const String& s,
    /* [in] */ ICharset* charset,
    /* [in] */ Boolean isPartiallyEncoded)
{
    if (s.IsNull())
        return E_NULL_POINTER_EXCEPTION;

    Int32 escapeStart = -1;
    AutoPtr<ArrayOf<Char32> > char32Array = s.GetChars();
    for(Int32 i = 0; i < s.GetLength(); i++) {
        Char32 c = (*char32Array)[i];
        if ((c >= 'a' && c <= 'z')
                || (c >= 'A' && c <= 'Z')
                || (c >= '0' && c <= '9')
                || IsRetained(c)
                || (c == '%' && isPartiallyEncoded)) {
            if (escapeStart != -1) {
                AppendHex(builder, s.Substring(escapeStart, i), charset);
                escapeStart = -1;
            }

            if (c == '%' && isPartiallyEncoded){
                builder.Append(s.Substring(i, Elastos::Core::Math::Min(i + 3, s.GetLength())));
                i += 2;
            }
            else if (c == ' '){
                builder.AppendChar('+');
            }
            else{
                builder.AppendChar(c);
            }
        }
        else if(escapeStart == -1) {
            escapeStart = i;
        }
    }

    if (escapeStart != -1) {
        AppendHex(builder, s.Substring(escapeStart, s.GetLength()), charset);
    }
    return NOERROR;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:44,代码来源:UriCodec.cpp

示例4:

ECode Rfc822Token::QuoteComment(
    /* [in] */ const String& comment,
    /* [out] */ String* str)
{
    VALIDATE_NOT_NULL(str)
    StringBuilder sb;

    AutoPtr<ArrayOf<Char32> > chars = comment.GetChars();
    Int32 len = chars->GetLength();
    Char32 c;
    for (Int32 i = 0; i < len; i++) {
        c = (*chars)[i];
        if (c == '(' || c == ')' || c == '\\') {
            sb.AppendChar('\\');
        }

        sb.AppendChar(c);
    }

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

示例5: DeriveFingerprint

/**
 * Some devices split the fingerprint components between multiple
 * partitions, so we might derive the fingerprint at runtime.
 */
static String DeriveFingerprint() {
    String finger = GetStringProperty(String("ro.build.fingerprint"));
    if (finger.IsNullOrEmpty()) {
        StringBuilder sb;
        sb += GetStringProperty(String("ro.product.brand"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.product.name"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.product.device"));
        sb.AppendChar(':');
        sb += GetStringProperty(String("ro.build.version.release"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.id"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.version.incremental"));
        sb.AppendChar(':');
        sb += GetStringProperty(String("ro.build.type"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.tags"));
        finger = sb.ToString();
    }
    return finger;
}
开发者ID:XilongPei,项目名称:Elastos5,代码行数:27,代码来源:Build.cpp

示例6: ProcessKey

Boolean EnglishInputProcessor::ProcessKey(
    /* [in] */ IInputConnection* inputContext,
    /* [in] */ IKeyEvent* event,
    /* [in] */ Boolean upperCase,
    /* [in] */ Boolean realAction)
{
    if (NULL == inputContext || NULL == event) return FALSE;

    Int32 keyCode = 0;
    event->GetKeyCode(&keyCode);

    AutoPtr<ICharSequence> prefix;
    inputContext->GetTextBeforeCursor(2, 0, (ICharSequence**)&prefix);

    Int32 keyChar = 0;
    if (keyCode >= IKeyEvent::KEYCODE_A && keyCode <= IKeyEvent::KEYCODE_Z) {
        keyChar = keyCode - IKeyEvent::KEYCODE_A + 'a';
        if (upperCase) {
            keyChar = keyChar + 'A' - 'a';
        }
    } else if (keyCode >= IKeyEvent::KEYCODE_0
            && keyCode <= IKeyEvent::KEYCODE_9)
        keyChar = keyCode - IKeyEvent::KEYCODE_0 + '0';
    else if (keyCode == IKeyEvent::KEYCODE_COMMA)
        keyChar = ',';
    else if (keyCode == IKeyEvent::KEYCODE_PERIOD)
        keyChar = '.';
    else if (keyCode == IKeyEvent::KEYCODE_APOSTROPHE)
        keyChar = '\'';
    else if (keyCode == IKeyEvent::KEYCODE_AT)
        keyChar = '@';
    else if (keyCode == IKeyEvent::KEYCODE_SLASH) keyChar = '/';

    if (0 == keyChar) {
        mLastKeyCode = keyCode;

        String insert;
        if (IKeyEvent::KEYCODE_DEL == keyCode) {
            if (realAction)  {
                Boolean flag = FALSE;
                inputContext->DeleteSurroundingText(1, 0, &flag);
            }
        } else if (IKeyEvent::KEYCODE_ENTER == keyCode) {
            insert = String("\n");
        } else if (IKeyEvent::KEYCODE_SPACE == keyCode) {
            insert = String(" ");
        } else {
            return FALSE;
        }

        if (NULL != insert && realAction) {
            Boolean flag = FALSE;
            AutoPtr<ICharSequence> text;
            CStringWrapper::New(insert, (ICharSequence**)&text);
            inputContext->CommitText(text, insert.GetLength(), &flag);
        }

        return TRUE;
    }

    if (!realAction)
        return TRUE;

    if (IKeyEvent::KEYCODE_SHIFT_LEFT == mLastKeyCode
            || IKeyEvent::KEYCODE_SHIFT_LEFT == mLastKeyCode) {
        if (keyChar >= 'a' && keyChar <= 'z')
            keyChar = keyChar - 'a' + 'A';
    } else if (IKeyEvent::KEYCODE_ALT_LEFT == mLastKeyCode) {
    }

    StringBuilder builder;
    builder.AppendChar(keyChar);
    String result = builder.ToString();

    Boolean flag = FALSE;
    AutoPtr<ICharSequence> text;
    CStringWrapper::New(result, (ICharSequence**)&text);
    inputContext->CommitText(text, result.GetLength(), &flag);
    mLastKeyCode = keyCode;
    return TRUE;
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:81,代码来源:EnglishInputProcessor.cpp


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