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


C++ StringBuffer::Append方法代码示例

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


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

示例1:

StringBuffer *StringBufferASCII::Append(const char szString[], uint32 nCount)
{
	// Calculate the new total length of the string (excluding the terminating zero)
	const uint32 nNewLength = m_nLength + nCount;

	// Is it possible to just modify the current internal string in place? (FAST!)
	if (nNewLength <= m_nMaxLength && GetRefCount() < 2) {
		// Just modify the current internal string in place
		memcpy(&m_pszString[m_nLength], szString, nCount);	// Append the new string
		m_pszString[nNewLength] = '\0';						// Set the terminating zero
		SetNewStringLength(nNewLength);						// Set the new string length

		// Return this string buffer
		return this;
	} else {
		// Request an ASCII string buffer from the string buffer manager
		StringBuffer *pStringBuffer = Manager.GetStringBufferASCII(nNewLength);
		if (pStringBuffer) {
			// Add old string
			if (m_nLength)
				pStringBuffer->Append(m_pszString, m_nLength);

			// Add string to append
			pStringBuffer->Append(szString, nCount);
		}

		// Done
		return pStringBuffer;
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:30,代码来源:StringBufferASCII.cpp

示例2: AddFilesFromDirectoryToTPAList

    void AddFilesFromDirectoryToTPAList(wchar_t* targetPath, wchar_t** rgTPAExtensions, int countExtensions)
    {
        *m_log << W("Adding assemblies from ") << targetPath << W(" to the TPA list") << Logger::endl;
        wchar_t assemblyPath[MAX_PATH];

        for (int iExtension = 0; iExtension < countExtensions; iExtension++)
        {
            wcscpy_s(assemblyPath, MAX_PATH, targetPath);

            const size_t dirLength = wcslen(targetPath);
            wchar_t* const fileNameBuffer = assemblyPath + dirLength;
            const size_t fileNameBufferSize = MAX_PATH - dirLength;

            wcscat_s(assemblyPath, rgTPAExtensions[iExtension]);
            WIN32_FIND_DATA data;
            HANDLE findHandle = FindFirstFile(assemblyPath, &data);

            if (findHandle != INVALID_HANDLE_VALUE) {
                do {
                    if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
                        // It seems that CoreCLR doesn't always use the first instance of an assembly on the TPA list (ni's may be preferred
                        // over il, even if they appear later). So, only include the first instance of a simple assembly name to allow
                        // users the opportunity to override Framework assemblies by placing dlls in %CORE_LIBRARIES%

                        // ToLower for case-insensitive comparisons
                        wchar_t* fileNameChar = data.cFileName;
                        while (*fileNameChar)
                        {
                            *fileNameChar = towlower(*fileNameChar);
                            fileNameChar++;
                        }

                        // Remove extension
                        wchar_t fileNameWithoutExtension[MAX_PATH];
                        wcscpy_s(fileNameWithoutExtension, MAX_PATH, data.cFileName);

                        RemoveExtensionAndNi(fileNameWithoutExtension);

                        // Add to the list if not already on it
                        if (!TPAListContainsFile(fileNameWithoutExtension, rgTPAExtensions, countExtensions))
                        {
                            const size_t fileLength = wcslen(data.cFileName);
                            const size_t assemblyPathLength = dirLength + fileLength;
                            wcsncpy_s(fileNameBuffer, fileNameBufferSize, data.cFileName, fileLength);
                            m_tpaList.Append(assemblyPath, assemblyPathLength);
                            m_tpaList.Append(W(";"), 1);
                        }
                        else
                        {
                            *m_log << W("Not adding ") << targetPath << data.cFileName << W(" to the TPA list because another file with the same name is already present on the list") << Logger::endl;
                        }
                    }
                } while (0 != FindNextFile(findHandle, &data));

                FindClose(findHandle);
            }
        }
    }
开发者ID:0xMF,项目名称:coreclr,代码行数:58,代码来源:coreconsole.cpp

示例3: AppendArgumentType

void StackTraceFormatter::AppendArgumentType(Thread *const thread, StringBuffer &buf, const Value *arg)
{
	Value argValue; // Copy, because arg is const

	if (IS_REFERENCE(*arg))
	{
		// If the argument is a reference, it must be dereferenced before
		// we can make use of the type information.
		buf.Append(4, "ref ");
		ReadReference(const_cast<Value*>(arg), &argValue);
	}
	else
	{
		argValue = *arg;
	}

	Type *type = argValue.type;
	if (type == nullptr)
	{
		buf.Append(4, "null");
		return;
	}

	// To make the stack trace more readable, we only append the last component
	// of the type name, so 'osprey.compiler.parser.Token' becomes just 'Token'.
	AppendShortMemberName(thread, buf, type->fullName);

	// When the argument is an aves.Method, we append some information about
	// the instance and method group, too, in the format
	//   Method(this: <instance type>, <method name>)
	//
	// Note that this is applied recursively to the instance type, which means
	// you can end up with situations like
	//   Method(this: Method(this: Method(...), ...), ...)
	//
	// It should at least be impossible for an aves.Method to be bound to iself.
	// Otherwise, well, we'll get infinite recursion!
	if (type == thread->GetVM()->types.Method)
	{
		// Append some information about the instance and method group, too.
		MethodInst *method = argValue.v.method;

		buf.Append(7, "(this: ");

		// It should be impossible for an aves.Method to be bound to iself.
		OVUM_ASSERT(method->instance.v.instance != argValue.v.instance);
		AppendArgumentType(thread, buf, &method->instance);

		buf.Append(2, ", ");

		AppendShortMethodName(thread, buf, method->method);

		buf.Append(')');
	}
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:55,代码来源:stacktraceformatter.cpp

示例4: AppendMethodName

void StackTraceFormatter::AppendMethodName(Thread *const thread, StringBuffer &buf, Method *method)
{
	// The method name is the fully qualified name of the method.

	// If method->declType is null, we're dealing with a global function, where
	// method->name already contains the fully qualified name.
	if (method->declType != nullptr)
	{
		buf.Append(method->declType->fullName);
		buf.Append('.');
	}
	buf.Append(method->name);
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:13,代码来源:stacktraceformatter.cpp

示例5: AppendSourceLocation

void StackTraceFormatter::AppendSourceLocation(Thread *const thread, StringBuffer &buf, MethodOverload *method, const void *ip)
{
	uint32_t offset = (uint32_t)((uint8_t*)ip - method->entry);

	debug::DebugSymbol *sym = method->debugSymbols->FindSymbol(offset);
	if (sym == nullptr)
		return;

	buf.Append(13, "\n    at line ");
	AppendLineNumber(thread, buf, sym->startLocation.lineNumber);

	buf.Append(5, " in \"");
	buf.Append(sym->file->fileName);
	buf.Append('"');
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:15,代码来源:stacktraceformatter.cpp

示例6: NATIVE_FUNCTION

AVES_API NATIVE_FUNCTION(aves_StringBuffer_appendLine)
{
	StringBuffer *buf = THISV.Get<StringBuffer>();
	if (!buf->Append(strings::newline))
		return VM_ThrowMemoryError(thread);

	VM_Push(thread, THISP);
	RETURN_SUCCESS;
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:9,代码来源:stringbuffer.cpp

示例7: AppendShortMethodName

void StackTraceFormatter::AppendShortMethodName(Thread *const thread, StringBuffer &buf, Method *method)
{
	// The short method name is the semi-qualified name of the method. That means
	// the last component of the name if it's a global function, or the last part
	// of the type name followed by the method name if it's a class method.

	// If method->declType is null, we're dealing with a global function, where
	// method->name already contains the fully qualified name.
	if (method->declType != nullptr)
	{
		AppendShortMemberName(thread, buf, method->declType->fullName);
		buf.Append('.');
		buf.Append(method->name);
	}
	else
	{
		AppendShortMemberName(thread, buf, method->name);
	}
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:19,代码来源:stacktraceformatter.cpp

示例8: AppendShortMemberName

void StackTraceFormatter::AppendShortMemberName(Thread *const thread, StringBuffer &buf, String *fullName)
{
	const ovchar_t *fullNameChars = &fullName->firstChar;
	int32_t lastDotIndex = fullName->length - 1;
	while (lastDotIndex >= 0)
	{
		if (fullNameChars[lastDotIndex] == '.')
			break;
		lastDotIndex--;
	}

	if (lastDotIndex >= 0)
		// The name contains one or more dots! Append everything
		// after the last dot.
		buf.Append(fullName->length - lastDotIndex - 1, fullNameChars + lastDotIndex + 1);
	else
		// No dot found, so just append the whole name
		buf.Append(fullName);
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:19,代码来源:stacktraceformatter.cpp

示例9: AppendParameters

void StackTraceFormatter::AppendParameters(Thread *const thread, StringBuffer &buf, const StackFrame *frame, MethodOverload *method)
{
	ovlocals_t paramCount = method->GetEffectiveParamCount();
	const Value *args = reinterpret_cast<const Value*>(frame) - paramCount;

	for (ovlocals_t i = 0; i < paramCount; i++)
	{
		if (i > 0)
			buf.Append(2, ", ");

		if (i == 0 && method->IsInstanceMethod())
			buf.Append(4, "this");
		else
			buf.Append(method->paramNames[i - method->InstanceOffset()]);

		buf.Append(2, ": ");

		AppendArgumentType(thread, buf, args + i);
	}
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:20,代码来源:stacktraceformatter.cpp

示例10:

static void
apply_safe_mode_path_blacklist()
{
	if (sPathBlacklist->IsEmpty())
		return;

	bool success = sSafeModeOptionsBuffer.Append("EntryBlacklist {\n");

	for (PathBlacklist::Iterator it = sPathBlacklist->GetIterator();
		BlacklistedPath* path = it.Next();) {
		success &= sSafeModeOptionsBuffer.Append(path->Path());
		success &= sSafeModeOptionsBuffer.Append("\n", 1);
	}

	success &= sSafeModeOptionsBuffer.Append("}\n");

	if (!success) {
		dprintf("apply_safe_mode_options(): failed to append path "
			"blacklist to buffer\n");
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:21,代码来源:menu.cpp

示例11: AppendStackFrame

void StackTraceFormatter::AppendStackFrame(Thread *const thread, StringBuffer &buf, const StackFrame *frame, const void *ip)
{
	MethodOverload *method = frame->method;
	Method *group = method->group;

	// Each line in the stack trace is indented with two spaces.
	buf.Append(2, ' ');

	AppendMethodName(thread, buf, group);

	buf.Append('(');

	AppendParameters(thread, buf, frame, method);

	buf.Append(')');

	if (method->debugSymbols)
		AppendSourceLocation(thread, buf, method, ip);

	buf.Append('\n');
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:21,代码来源:stacktraceformatter.cpp

示例12: FmtString

//
// String
//
static void FmtString(StringBuffer   & oBuffer,
                      const CDT      & oCurrentArgument,
                      const UINT_32    iFmtFlags,
                      const INT_32     iWidth,
                      const INT_32     iMaxChars,
                      CHAR_8           chPadSymbol)
{
	const STLW::string sTMP    = oCurrentArgument.GetString();

	INT_32 iFormatSize = sTMP.size();
	if (iFormatSize > iMaxChars && iMaxChars > 0) { iFormatSize = iMaxChars; }

	if (iFmtFlags & F_LEFT_ALIGN)
	{
		oBuffer.Append(sTMP.data(), iFormatSize);
		if (iWidth > iFormatSize) { oBuffer.Append(iWidth - iFormatSize, chPadSymbol); }
	}
	else
	{
		if (iWidth > iFormatSize) { oBuffer.Append(iWidth - iFormatSize, chPadSymbol); }
		oBuffer.Append(sTMP.data(), iFormatSize);
	}
}
开发者ID:androidsoft,项目名称:kiwix_mirror,代码行数:26,代码来源:CTPP2Sprintf.cpp

示例13: AppendLineNumber

void StackTraceFormatter::AppendLineNumber(Thread *const thread, StringBuffer &buf, int32_t line)
{
	// 32 digits ought to be enough for anybody
	const size_t BUFFER_SIZE = 32;

	ovchar_t lineNumberStr[BUFFER_SIZE];
	ovchar_t *chp = lineNumberStr + BUFFER_SIZE;
	int32_t length = 0;

	do
	{
		*--chp = (ovchar_t)'0' + line % 10;
		length++;
	} while (line /= 10);

	buf.Append(length, chp);
}
开发者ID:osprey-lang,项目名称:ovum,代码行数:17,代码来源:stacktraceformatter.cpp

示例14: FmtChar

//
// Character
//
static void FmtChar(StringBuffer   & oBuffer,
                    const CDT      & oCurrentArgument,
                    const UINT_32    iFmtFlags,
                    const INT_32     iWidth,
                    CHAR_8           chPadSymbol)
{
	const CDT::eValType oValType = oCurrentArgument.GetType();
	if (oValType == CDT::UNDEF && iWidth > 0)
	{
		oBuffer.Append(iWidth, chPadSymbol);
		return;
	}

	UCHAR_8 ucTMP = ' ';
	if (oValType == CDT::INT_VAL || oValType == CDT::REAL_VAL)
	{
		ucTMP = oCurrentArgument.GetInt();
	}
	else if (oValType == CDT::STRING_VAL)
	{
		const STLW::string sTMP = oCurrentArgument.GetString();
		if (sTMP.empty() && iWidth > 0)
		{
			oBuffer.Append(iWidth, chPadSymbol);
			return;
		}
		ucTMP = sTMP[0];
	}
	else if (oValType == CDT::POINTER_VAL) { ucTMP = 'P'; }
	else if (oValType == CDT::ARRAY_VAL)   { ucTMP = 'A'; }
	else if (oValType == CDT::HASH_VAL)    { ucTMP = 'H'; }

	if (iFmtFlags & F_LEFT_ALIGN)
	{
		oBuffer.Append(1, ucTMP);
		if (iWidth > 1) { oBuffer.Append(iWidth - 1, chPadSymbol); }
	}
	else
	{
		if (iWidth > 1) { oBuffer.Append(iWidth - 1, chPadSymbol); }
		oBuffer.Append(1, ucTMP);
	}
}
开发者ID:androidsoft,项目名称:kiwix_mirror,代码行数:46,代码来源:CTPP2Sprintf.cpp

示例15: FormatImpl

ECode MessageFormat::FormatImpl(
    /* [in] */ ArrayOf< IInterface* >* objects,
    /* [in] */ IStringBuffer* inbuffer,
    /* [in] */ IFieldPosition* position,
    /* [in] */ List<AutoPtr<FieldContainer> >* fields)
{
    VALIDATE_NOT_NULL(inbuffer);

    StringBuffer * buffer = (StringBuffer *)inbuffer;
    AutoPtr<IFieldPosition> passedField;
    CFieldPosition::New(0, (IFieldPosition**)&passedField);

    Int32 begin;
    String result;
    for (Int32 i = 0; i <= mMaxOffset; i++) {
        *buffer += (*mStrings)[i];
        begin = buffer->GetLength();
        AutoPtr<IInterface> arg;
        if (objects != NULL && (*mArgumentNumbers)[i] < objects->GetLength()) {
            arg = (*objects)[(*mArgumentNumbers)[i]];
        }
        else {
            buffer->AppendChar('{');
            *buffer += (*mArgumentNumbers)[i];
            buffer->AppendChar('}');
            HandleArgumentField(begin, buffer->GetLength(), (*mArgumentNumbers)[i],
                    position, fields);
            continue;
        }

        AutoPtr<IFormat> format = (*mFormats)[i];
        if (format == NULL || arg == NULL) {
            if (INumber::Probe(arg) != NULL) {
                AutoPtr<INumberFormat> nf;
                NumberFormat::GetInstance((INumberFormat**)&nf);
                format = IFormat::Probe(nf);
            }
            else if (IDate::Probe(arg) != NULL) {
                AutoPtr<IDateFormat> df;
                DateFormat::GetInstance((IDateFormat**)&df);
                format = IFormat::Probe(df);
            }
            else {
                buffer->Append(Object::ToString(arg));
                HandleArgumentField(begin, buffer->GetLength(),
                        (*mArgumentNumbers)[i], position, fields);
                continue;
            }
        }

        if (IChoiceFormat::Probe(format) != NULL) {
            format->Format(arg, &result);
            AutoPtr<IMessageFormat> mf;
            CMessageFormat::New(result, (IMessageFormat**)&mf);
            mf->SetLocale(mLocale);
            mf->Format(objects, buffer , passedField);
            HandleArgumentField(begin, buffer->GetLength(), (*mArgumentNumbers)[i], position, fields);
            HandleFormat(format, arg, begin, fields);
        }
        else {
            format->Format(arg, buffer, passedField);
            HandleArgumentField(begin, buffer->GetLength(), (*mArgumentNumbers)[i], position, fields);
            HandleFormat(format, arg, begin, fields);
        }
    }
    if (mMaxOffset + 1 < mStrings->GetLength()) {
        (*buffer) += (*mStrings)[mMaxOffset + 1];
    }

    return NOERROR;
}
开发者ID:maerson,项目名称:CPP_Framework_Elastos5,代码行数:71,代码来源:MessageFormat.cpp


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