本文整理汇总了C++中StringBuilder::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuilder::Append方法的具体用法?C++ StringBuilder::Append怎么用?C++ StringBuilder::Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder::Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_dns_packet
void DNSServer::create_dns_packet(const dnsreq& req, StringBuilder& sb)
{
dnshdr hdr;
hdr.transaction_id = req.transaction_id;
hdr.flags = htons(req.flags);
hdr.additional_rr = hdr.authority_rr = htons(0);
hdr.queries = htons(req.queries.size());
hdr.answers = htons(req.answers.size());
sb.Append((char*) &hdr, sizeof(hdr));
int i, offset = sizeof(hdr);
UShort queries[req.queries.size()];
for (i = 0; i < (int) req.queries.size(); i++)
{
queries[i] = offset;
offset += write_dns_name(req.queries[i].q, sb);
dnshdr_q hdr1
{ htons(req.queries[i].type), htons(req.queries[i].cls) };
sb.Append((char*) &hdr1, sizeof(hdr1));
offset += sizeof(hdr1);
}
for (i = 0; i < (int) req.answers.size(); i++)
{
if (req.answers[i].query_index >= (int) req.queries.size())
continue;
dnshdr_a hdr1
{ (UShort) (htons(queries[req.answers[i].query_index] | dns_offset_mask)), htons(
req.answers[i].type), htons(req.answers[i].cls), htonl(req.answers[i].ttl), htons(
req.answers[i].addr.Length) };
sb.Append((char*) &hdr1, sizeof(hdr1));
sb.Append(req.answers[i].addr);
}
}
示例2: write_dns_name
int DNSServer::write_dns_name(const string& name, StringBuilder& sb)
{
const char* ch = name.data();
int len = name.length();
int i = 0;
int last_i = 0;
int ret = 0;
while (i < len)
{
if (ch[i] == '.')
{
sb.Append((char) (i - last_i));
sb.Append(ch + last_i, i - last_i);
ret += 1 + (i - last_i);
last_i = i + 1;
}
i++;
}
if (last_i < len)
{
sb.Append((char) (len - last_i));
sb.Append(ch + last_i, len - last_i);
ret += 1 + (len - last_i);
}
sb.Append((char) 0);
return ret;
}
示例3: RejectQuery
ECode ContentProvider::RejectQuery(
/* [in] */ IUri* uri,
/* [in] */ ArrayOf<String>* projection,
/* [in] */ const String& selection,
/* [in] */ ArrayOf<String>* selectionArgs,
/* [in] */ const String& sortOrder,
/* [in] */ ICancellationSignal* cancellationSignal,
/* [out] */ ICursor** cursor)
{
StringBuilder sb;
// The read is not allowed... to fake it out, we replace the given
// selection statement with a dummy one that will always be FALSE.
// This way we will get a cursor back that has the correct structure
// but contains no rows.
if (selection.IsNullOrEmpty()) {
sb.Append("'A' = 'B'");
}
else {
sb.Append("'A' = 'B' AND (");
sb.Append(selection);
sb.Append(")");
}
return Query(uri, projection, selection, selectionArgs,
sortOrder, cancellationSignal, cursor);
}
示例4: 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;
}
示例5: test
bool test()
{
StringBuilder sb;
sb.Append("asdfg");
bool t1 = sb.Length() == 5;
sb.Append("qwert");
bool t2 = sb.Length() == 10;
return (t1 && t2);
}
示例6: MakeCanonicalPath
CString FileSystem::MakeCanonicalPath(const char* path)
{
int len = strlen(path);
if (!strncmp("\\\\?\\", path, 4) || len == 0)
{
return path;
}
std::vector<CString> components = Util::SplitStr(path, "\\/");
for (uint32 i = 1; i < components.size(); i++)
{
if (!strcmp(components[i], ".."))
{
components.erase(components.begin() + i - 1, components.begin() + i + 1);
i -= 2;
}
else if (!strcmp(components[i], "."))
{
components.erase(components.begin() + i);
i--;
}
}
StringBuilder result;
result.Reserve(strlen(path));
if (!strncmp("\\\\", path, 2))
{
result.Append("\\\\");
}
bool first = true;
for (CString& comp : components)
{
if (comp.Length() > 0)
{
if (!first)
{
result.Append("\\");
}
result.Append(comp);
first = false;
}
}
if ((path[len - 1] == '\\' || path[len - 1] == '/' ||
(len > 3 && !strcmp(path + len - 3, "\\..")) ||
(len > 2 && !strcmp(path + len - 2, "\\.")))
&&
result[result.Length() - 1] != '\\')
{
result.Append("\\");
}
return *result;
}
示例7: ToString
ECode PhoneAccountHandle::ToString(
/* [out] */ String* result)
{
VALIDATE_NOT_NULL(result)
StringBuilder sb;
sb.Append(mComponentName);
sb.Append(", ");
sb.Append(mId);
return sb.ToString(result);
}
示例8: ToString
ECode CSizeF::ToString(
/* [out] */ String* str)
{
VALIDATE_NOT_NULL(str)
StringBuilder sb;
sb.Append(mWidth);
sb.Append("x");
sb.Append(mHeight);
*str = sb.ToString();
return NOERROR;
}
示例9: ToString
ECode CCellSignalStrengthGsm::ToString(
/* [out] */ String* str)
{
VALIDATE_NOT_NULL(str);
StringBuilder sb;
sb.Append("CellSignalStrengthGsm:");
sb.Append(" ss="); sb.Append(mSignalStrength);
sb.Append(" ber="); sb.Append(mBitErrorRate);
*str = sb.ToString();
return NOERROR;
}
示例10: ToString
ECode CAuthState::ToString(
/* [out] */ String* str)
{
VALIDATE_NOT_NULL(str)
StringBuilder buffer;
buffer.Append("auth scope [");
buffer.Append(mAuthScope);
buffer.Append("]; credentials set [");
buffer.Append(mCredentials != NULL ? "true" : "false");
buffer.Append("]");
*str = buffer.ToString();
return NOERROR;
}
示例11: WriteDateTime
String DateUtils::WriteDateTime(
/* [in] */ ICalendar* cal,
/* [in] */ Boolean zulu)
{
StringBuilder sb;
sb.EnsureCapacity(16);
if (zulu) {
sb.Append(" Z"); //Java: sb.setLength(16); sb.setCharAt(15, 'Z');
}
else {
sb.Append(" ");//Java: sb.setLength(15);
}
String strTemp = sb.ToString();
return WriteDateTime(cal, &strTemp);
}
示例12: 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();
}
示例13: Concat
String EncodedStringValue::Concat(
/* [in] */ ArrayOf<IEncodedStringValue*>* addr)
{
StringBuilder sb;
Int32 maxIndex = addr->GetLength() - 1;
for (Int32 i = 0; i <= maxIndex; i++) {
String str;
(*addr)[i]->GetString(&str);
sb.Append(str);
if (i < maxIndex) {
sb.Append(String(";"));
}
}
return sb.ToString();
}
示例14: GenerateShaderStruct
// ------------------------------------------------------------------------------------------
//! Generates a structure inside GLSL shader.
//! @param Struct Structure object definition.
//! @param Builder Output for the shader code.
void GLSLGenerator::GenerateShaderStruct(HLSLStruct const* const Struct, StringBuilder& Builder)
{
Builder.AppendFormat("\n\nstruct %s\n{", Struct->Name.CStr());
for (auto const& Definition : Struct->InnerDefinitions)
{
HLSLVariable const* const StructField = static_cast<HLSLVariable const*>(Definition);
Builder.AppendFormat("\n\t%s %s", StructField->Type->Name.CStr(), StructField->Name.CStr());
if (StructField->ArrayRank != 0)
{
// Adding array information for our field..
Builder.AppendFormat("[%d]", static_cast<int>(StructField->ArrayRank));
}
Builder.Append(';');
}
Builder.Append("\n};");
}
示例15: ToString
RF_Type::Bool ToString()
{
StringBuilder builder;
builder.Append("hi");
auto result = builder.ToString();
return result->Size() == 3 && result->Length() == 2;
}