本文整理汇总了C++中sp::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::c_str方法的具体用法?C++ sp::c_str怎么用?C++ sp::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::c_str方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NumberFormatException
sp<Short> Short::valueOf(const sp<String>& string, int32_t radix) {
if (string == nullptr || string->isEmpty()) {
throw NumberFormatException("String is null or empty");
}
if (::isspace(string->charAt(0))) {
throw NumberFormatException(String::format("Invalid integral value: %s", string->c_str()));
}
// See http://man7.org/linux/man-pages/man3/strtol.3.html.
char* endptr;
int16_t value = ::strtol(string->c_str(), &endptr, radix);
if (*endptr != '\0') {
throw NumberFormatException(String::format("Invalid integral value: %s", string->c_str()));
}
return new Short(value);
}
示例2: mName
Process::Process(const sp<String>& name) :
mName(name),
mLock(new ReentrantLock()),
mCondition(mLock->newCondition()) {
mMainThread = new HandlerThread(String::format("Process {%s}", name->c_str()));
mServices = new HashMap<sp<ComponentName>, sp<Service>>();
}
示例3:
void FileHandler::Writer::write(const sp<String>& s, uint32_t offset,
size_t length)
{
const ssize_t size = ::write(mFd, s->c_str() + offset, length);
if (size > 0) {
mSize += size;
}
}
示例4: processConfigurationRule
void Eliza::processConfigurationRule(sp<String> s) {
sp<StringArray> lines = new StringArray(4);
if (Strings::match(s, "*reasmb: *", lines)) {
if (reassemblyList == nullptr) {
printf("Error: no reassembly list\n");
return;
}
reassemblyList->add(lines->get(1));
} else if (Strings::match(s, "*decomp: *", lines)) {
if (decompositionList == nullptr) {
printf("Error: no decomposition list\n");
return;
}
reassemblyList = new ReassemblyList();
sp<String> tmp = lines->get(1);
if (Strings::match(tmp, "$ *", lines)) {
decompositionList->add(lines->get(0), true, reassemblyList);
} else {
decompositionList->add(tmp, false, reassemblyList);
}
} else if (Strings::match(s, "*key: * #*", lines)) {
decompositionList = new DecompositionList();
reassemblyList = nullptr;
int n = 0;
if (lines->get(2)->length() != 0) {
try {
n = Integer::valueOf(lines->get(2))->intValue();
} catch (const NumberFormatException& e) {
printf("Number is wrong in key: %s\n", lines->get(2)->c_str());
}
}
keys->add(lines->get(1), n, decompositionList);
} else if (Strings::match(s, "*key: *", lines)) {
decompositionList = new DecompositionList();
reassemblyList = nullptr;
keys->add(lines->get(1), 0, decompositionList);
} else if (Strings::match(s, "*synon: * *", lines)) {
sp<WordList> words = new WordList();
words->add(lines->get(1));
s = lines->get(2);
while (Strings::match(s, "* *", lines)) {
words->add(lines->get(0));
s = lines->get(1);
}
words->add(s);
synonyms->add(words);
} else if (Strings::match(s, "*pre: * *", lines)) {
preList->add(lines->get(1), lines->get(2));
} else if (Strings::match(s, "*post: * *", lines)) {
postList->add(lines->get(1), lines->get(2));
} else if (Strings::match(s, "*initial: *", lines)) {
welcome = lines->get(1);
} else if (Strings::match(s, "*final: *", lines)) {
goodbye = lines->get(1);
} else if (Strings::match(s, "*quit: *", lines)) {
quit->add(String::format(" %s ", lines->get(1)->c_str()));
} else {
printf("Unrecognized input: %s\n", s->c_str());
}
}
示例5: valueOf
sp<Double> Double::valueOf(const sp<String>& s) {
return valueOf(s->c_str());
}
示例6: putString
void Bundle::putString(const char* key, const sp<String>& string) {
putString(key, (string != NULL) ? string->c_str() : NULL);
}
示例7: split
sp<ArrayList<sp<String>>> String::split(const sp<String>& separator) const {
return split(separator->c_str());
}
示例8: indexOf
ssize_t String::indexOf(const sp<String>& string, size_t fromIndex) const {
return indexOf(string->c_str() + fromIndex);
}
示例9: endsWith
bool String::endsWith(const sp<String>& suffix) const {
return endsWith(suffix->c_str());
}
示例10: startsWith
bool String::startsWith(const sp<String>& prefix) const {
return startsWith(prefix->c_str());
}
示例11: contains
bool String::contains(const sp<String>& subString) const {
return contains(subString->c_str());
}
示例12: File
sp<File> ContextImpl::makeFilename(const sp<File>& baseDir, const sp<String>& name) {
if (name->indexOf(File::separatorChar) < 0) {
return new File(baseDir, name);
}
throw IllegalArgumentException(String::format("File %s contains a path separator", name->c_str()));
}