本文整理汇总了C++中String16::setTo方法的典型用法代码示例。如果您正苦于以下问题:C++ String16::setTo方法的具体用法?C++ String16::setTo怎么用?C++ String16::setTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String16
的用法示例。
在下文中一共展示了String16::setTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NativeString
NativeString*
AssetManagerGlue::getResourceName(int resid)
{
ResTable::resource_name name;
if (!getResources().getResourceName(resid, &name)) {
return NULL;
}
String16 str;
if (name.package != NULL) {
str.setTo(name.package, name.packageLen);
}
if (name.type != NULL) {
if (str.size() > 0) {
char16_t div = ':';
str.append(&div, 1);
}
str.append(name.type, name.typeLen);
}
if (name.name != NULL) {
if (str.size() > 0) {
char16_t div = '/';
str.append(&div, 1);
}
str.append(name.name, name.nameLen);
}
return new NativeString(str);
}
示例2: parseStyledString
//.........这里部分代码省略.........
span.span.firstChar = span.span.lastChar = outString->size();
spanStack.push(span);
} else if (code == ResXMLTree::END_TAG) {
size_t nslen;
const uint16_t* ns = inXml->getElementNamespace(&nslen);
if (ns == NULL) {
ns = (const uint16_t*)"\0\0";
nslen = 0;
}
const String8 nspace(String16(ns, nslen));
if (nspace == XLIFF_XMLNS) {
xliffDepth--;
continue;
}
if (!ResTable::collectString(outString, curString.string(),
curString.size(), false, &errorMsg, true)) {
SourcePos(String8(fileName), inXml->getLineNumber()).error("%s (in %s)\n",
errorMsg, String8(curString).string());
return UNKNOWN_ERROR;
}
rawString.append(curString);
curString = String16();
if (spanStack.size() == 0) {
if (strcmp16(inXml->getElementName(&len), endTag.string()) != 0) {
SourcePos(String8(fileName), inXml->getLineNumber()).error(
"Found tag %s where <%s> close is expected\n",
String8(inXml->getElementName(&len)).string(),
String8(endTag).string());
return UNKNOWN_ERROR;
}
break;
}
StringPool::entry_style_span span = spanStack.top();
String16 spanTag;
ssize_t semi = span.name.findFirst(';');
if (semi >= 0) {
spanTag.setTo(span.name.string(), semi);
} else {
spanTag.setTo(span.name);
}
if (strcmp16(inXml->getElementName(&len), spanTag.string()) != 0) {
SourcePos(String8(fileName), inXml->getLineNumber()).error(
"Found close tag %s where close tag %s is expected\n",
String8(inXml->getElementName(&len)).string(),
String8(spanTag).string());
return UNKNOWN_ERROR;
}
bool empty = true;
if (outString->size() > 0) {
span.span.lastChar = outString->size()-1;
if (span.span.lastChar >= span.span.firstChar) {
empty = false;
outSpans->add(span);
}
}
spanStack.pop();
/*
* This warning seems to be just an irritation to most people,
* since it is typically introduced by translators who then never
* see the warning.
*/
if (0 && empty) {
fprintf(stderr, "%s:%d: warning: empty '%s' span found in text '%s'\n",
fileName, inXml->getLineNumber(),
String8(spanTag).string(), String8(*outString).string());
}
} else if (code == ResXMLTree::START_NAMESPACE) {
// nothing
}
}
if (code == ResXMLTree::BAD_DOCUMENT) {
SourcePos(String8(fileName), inXml->getLineNumber()).error(
"Error parsing XML\n");
}
if (outSpans != NULL && outSpans->size() > 0) {
if (curString.size() > 0) {
if (!ResTable::collectString(outString, curString.string(),
curString.size(), false, &errorMsg, true)) {
SourcePos(String8(fileName), inXml->getLineNumber()).error(
"%s (in %s)\n",
errorMsg, String8(curString).string());
return UNKNOWN_ERROR;
}
}
} else {
// There is no style information, so string processing will happen
// later as part of the overall type conversion. Return to the
// client the raw unprocessed text.
rawString.append(curString);
outString->setTo(rawString);
}
return NO_ERROR;
}