本文整理汇总了C++中String16类的典型用法代码示例。如果您正苦于以下问题:C++ String16类的具体用法?C++ String16怎么用?C++ String16使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String16类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(OpenCVEngineTest, GetPathForUnExistVersion)
{
sp<IOpenCVEngine> Engine = InitConnect();
EXPECT_FALSE(NULL == Engine.get());
String16 result = Engine->GetLibPathByVersion(String16("2.5"));
EXPECT_EQ(0, result.size());
}
示例2: GetCallerPID
void ChatSession::Advise(const sp<IChatSessionEvents>& eventSink)
{
int callerPid = GetCallerPID();
_TRACE("ChatSession::Advise >>(%s,pid:%d)",DISPLAY_STRING16(m_wszSessionName),callerPid);
if (eventSink == NULL){
_TRACE("ChatSession::Advise << E_INVALIDARG");
return;
}
String16 userName = eventSink->GetUserName();
if(userName.size()&& !m_bAllowAnonymousAccess){
_TRACE("ChatSession::Advise << E_ACCESSDENIED");
return;
}
sp<IBinder> binder = eventSink->asBinder();
binder->linkToDeath(this);
_TRACE("**ADD(cse:%p binder:%p) ",eventSink.get(),binder.get());
_TRACE("add user %s",DISPLAY_STRING16(userName));
Fire_OnNewUser(userName);
//ChatWorker::getInstance().Defer_OnNewUser(this,userName);
Mutex::Autolock _lock(m_csAdviseLock);
m_Listeners.add(callerPid,binder);
_TRACE("ChatSession::Advise << S_OK");
return;
}
示例3: TEST
TEST(Pseudolocales, RedefineMethod) {
Pseudolocalizer pseudo(PSEUDO_ACCENTED);
String16 result = pseudo.text(String16(String8("Hello, ")));
pseudo.setMethod(NO_PSEUDOLOCALIZATION);
result.append(pseudo.text(String16(String8("world!"))));
ASSERT_EQ(String8("Ĥéļļö, world!"), String8(result));
}
示例4: stopProfiling
void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
{
if (!m_enabled)
return;
String16 id;
String16 resolvedTitle;
// Take last started profile if no title was passed.
if (title.isEmpty()) {
if (m_startedProfiles.empty())
return;
id = m_startedProfiles.back().m_id;
resolvedTitle = m_startedProfiles.back().m_title;
m_startedProfiles.pop_back();
} else {
for (size_t i = 0; i < m_startedProfiles.size(); i++) {
if (m_startedProfiles[i].m_title == title) {
resolvedTitle = title;
id = m_startedProfiles[i].m_id;
m_startedProfiles.erase(m_startedProfiles.begin() + i);
break;
}
}
if (id.isEmpty())
return;
}
std::unique_ptr<protocol::Profiler::CPUProfile> profile = stopProfiling(id, true);
if (!profile)
return;
std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocation(m_session->debugger());
m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile), resolvedTitle);
}
示例5: TEST
TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
{
sp<IOpenCVEngine> Engine = InitConnect();
Starter.PackageManager->InstalledPackages.clear();
Starter.PackageManager->InstallVersion(2040100, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
EXPECT_FALSE(NULL == Engine.get());
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
EXPECT_EQ(0, result.size());
}
示例6: add
ssize_t StringPool::add(const String16& ident, const String16& value,
bool mergeDuplicates)
{
if (ident.size() > 0) {
ssize_t idx = mIdents.valueFor(ident);
if (idx >= 0) {
fprintf(stderr, "ERROR: Duplicate string identifier %s\n",
String8(mEntries[idx].value).string());
return UNKNOWN_ERROR;
}
}
ssize_t vidx = mValues.indexOfKey(value);
ssize_t pos = vidx >= 0 ? mValues.valueAt(vidx) : -1;
ssize_t eidx = pos >= 0 ? mEntryArray.itemAt(pos) : -1;
if (eidx < 0) {
eidx = mEntries.add(entry(value));
if (eidx < 0) {
fprintf(stderr, "Failure adding string %s\n", String8(value).string());
return eidx;
}
}
const bool first = vidx < 0;
if (first || !mergeDuplicates) {
pos = mEntryArray.add(eidx);
if (first) {
vidx = mValues.add(value, pos);
const size_t N = mEntryArrayToValues.size();
for (size_t i=0; i<N; i++) {
size_t& e = mEntryArrayToValues.editItemAt(i);
if ((ssize_t)e >= vidx) {
e++;
}
}
}
mEntryArrayToValues.add(vidx);
if (!mSorted) {
entry& ent = mEntries.editItemAt(eidx);
ent.indices.add(pos);
}
}
if (ident.size() > 0) {
mIdents.add(ident, vidx);
}
NOISY(printf("Adding string %s to pool: pos=%d eidx=%d vidx=%d\n",
String8(value).string(), pos, eidx, vidx));
return pos;
}
示例7:
size_t Buffer::writeString16(String16 _src, size_t _offset)
{
if(_offset != npos)
_pf_writeOffset = _offset;
else
_pf_writeOffset = _pf_buffer.size();
writeInt16(_src.size(), _pf_writeOffset);
for(int i = 0; i < _src.size(); ++i)
writeInt16(_src[i], _offset);
return _pf_writeOffset;
}
示例8: handleScope
int V8Regex::match(const String16& string, int startFrom, int* matchLength) const
{
if (matchLength)
*matchLength = 0;
if (m_regex.IsEmpty() || string.isEmpty())
return -1;
// v8 strings are limited to int.
if (string.length() > INT_MAX)
return -1;
v8::Isolate* isolate = m_debugger->isolate();
v8::HandleScope handleScope(isolate);
v8::Local<v8::Context> context = m_debugger->regexContext();
v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::TryCatch tryCatch(isolate);
v8::Local<v8::RegExp> regex = m_regex.Get(isolate);
v8::Local<v8::Value> exec;
if (!regex->Get(context, toV8StringInternalized(isolate, "exec")).ToLocal(&exec))
return -1;
v8::Local<v8::Value> argv[] = { toV8String(isolate, string.substring(startFrom)) };
v8::Local<v8::Value> returnValue;
if (!exec.As<v8::Function>()->Call(context, regex, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&returnValue))
return -1;
// RegExp#exec returns null if there's no match, otherwise it returns an
// Array of strings with the first being the whole match string and others
// being subgroups. The Array also has some random properties tacked on like
// "index" which is the offset of the match.
//
// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec
ASSERT(!returnValue.IsEmpty());
if (!returnValue->IsArray())
return -1;
v8::Local<v8::Array> result = returnValue.As<v8::Array>();
v8::Local<v8::Value> matchOffset;
if (!result->Get(context, toV8StringInternalized(isolate, "index")).ToLocal(&matchOffset))
return -1;
if (matchLength) {
v8::Local<v8::Value> match;
if (!result->Get(context, 0).ToLocal(&match))
return -1;
*matchLength = match.As<v8::String>()->Length();
}
return matchOffset.As<v8::Int32>()->Value() + startFrom;
}
示例9: 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);
}
示例10: _l
SensorManager& SensorManager::getInstanceForPackage(const String16& packageName) {
Mutex::Autolock _l(sLock);
SensorManager* sensorManager;
std::map<String16, SensorManager*>::iterator iterator =
sPackageInstances.find(packageName);
if (iterator != sPackageInstances.end()) {
sensorManager = iterator->second;
} else {
String16 opPackageName = packageName;
// It is possible that the calling code has no access to the package name.
// In this case we will get the packages for the calling UID and pick the
// first one for attributing the app op. This will work correctly for
// runtime permissions as for legacy apps we will toggle the app op for
// all packages in the UID. The caveat is that the operation may be attributed
// to the wrong package and stats based on app ops may be slightly off.
if (opPackageName.size() <= 0) {
sp<IBinder> binder = defaultServiceManager()->getService(String16("permission"));
if (binder != 0) {
const uid_t uid = IPCThreadState::self()->getCallingUid();
Vector<String16> packages;
interface_cast<IPermissionController>(binder)->getPackagesForUid(uid, packages);
if (!packages.isEmpty()) {
opPackageName = packages[0];
} else {
ALOGE("No packages for calling UID");
}
} else {
ALOGE("Cannot get permission service");
}
}
sensorManager = new SensorManager(opPackageName);
// If we had no package name, we looked it up from the UID and the sensor
// manager instance we created should also be mapped to the empty package
// name, to avoid looking up the packages for a UID and get the same result.
if (packageName.size() <= 0) {
sPackageInstances.insert(std::make_pair(String16(), sensorManager));
}
// Stash the per package sensor manager.
sPackageInstances.insert(std::make_pair(opPackageName, sensorManager));
}
return *sensorManager;
}
示例11: handles
void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const String16& heapSnapshotObjectId, const protocol::Maybe<String16>& objectGroup, std::unique_ptr<protocol::Runtime::RemoteObject>* result)
{
bool ok;
int id = heapSnapshotObjectId.toInt(&ok);
if (!ok) {
*error = "Invalid heap snapshot object id";
return;
}
v8::HandleScope handles(m_isolate);
v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id);
if (heapObject.IsEmpty()) {
*error = "Object is not available";
return;
}
if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject)) {
*error = "Object is not available";
return;
}
*result = m_session->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.fromMaybe(""), false);
if (!result)
*error = "Object is not available";
}
示例12: Exception_NotEnoughDataToRead
size_t Buffer::readString16(String16& _dst, size_t _offset)
{
if(_offset != npos)
_pf_readOffset = _offset;
int16_t strLen;
_pm_checkIfEnoughBytesToRead(sizeof(strLen), _pf_readOffset);
readInt16(strLen, _offset); // <-- readOffset += 2;
// Штука спорной нужности, так как откатывать всё это придётся ловцу исключения.
// Но на всякий случай сделаем так.
if(!_pm_checkIfEnoughBytesToRead_noEx(strLen, _pf_readOffset))
{
_pf_readOffset -= sizeof(strLen);
throw Exception_NotEnoughDataToRead();
}
int16_t ch;
for(int i = 0; i < strLen; ++i)
{
readInt16(ch);
_dst.push_back(ch);
}
return _pf_readOffset;
}
示例13: LOGE
/* BnHelloWorld */
status_t BnHelloWorld::onTransact(uint32_t code,
const Parcel &data,
Parcel *reply,
uint32_t flags)
{
LOGE("OnTransact(%u,%u)", code, flags);
CHECK_INTERFACE(IHelloWorld, data, reply);
switch(code) {
case HW_HELLOTHERE: {
/**
* Checking permissions is always a good idea.
*
* Note that the native client will also be granted these permissions in two cases
* 1) you run the client code as root or system user.
* 2) you run the client code as user who was granted this permission.
* @see http://github.com/keesj/gomo/wiki/AndroidSecurity for more information
**/
if (checkCallingPermission(String16("org.credil.helloworldservice.permissions.CALL_HELLOTHERE")) == false){
return PERMISSION_DENIED;
}
String16 str = data.readString16();
hellothere(String8(str).string());
///reply->writeString16(str);
return NO_ERROR;
} break;
case RETURN_INT_SHANQUAN:{
if (checkCallingPermission(String16("org.credil.helloworldservice.permissions.CALL_HELLOTHERE")) == false){
return PERMISSION_DENIED;
}
String16 str = data.readString16();
helloint(String8(str).string());
int tmp= str.size();
printf("servie str.size():%i\n",tmp);
status_t status = reply->writeInt32(tmp);
if( status == NO_ERROR)
printf("file:%s,line:%i,no error\n",__FILE__,__LINE__);
else
printf("file:%s,line:%i, error\n",__FILE__,__LINE__);
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
return NO_ERROR;
}
示例14: doStringCommand
// Send a command to the supplicant, and return the reply as a String.
static jstring doStringCommand(JNIEnv* env, jstring javaCommand) {
char reply[REPLY_BUF_SIZE];
ScopedUtfChars command(env, javaCommand);
if (!doCommand(env, javaCommand, reply, sizeof(reply))) {
return NULL;
}
if (DBG) ALOGD("cmd = %s, reply: %s", command.c_str(), reply);
String16 str;
if (strstr(command.c_str(),"BSS RANGE=")) {
parseScanResults(str,reply);
} else if (strstr(command.c_str(),"GET_NETWORK") &&
strstr(command.c_str(),"ssid") && !strstr(command.c_str(),"bssid")
&& !strstr(command.c_str(),"scan_ssid")){
constructSsid(str, reply);
} else {
str += String16((char *)reply);
}
return env->NewString((const jchar *)str.string(), str.size());
}
示例15: releaseObjectGroup
void InjectedScriptNative::releaseObjectGroup(const String16& groupName)
{
if (groupName.isEmpty())
return;
NameToObjectGroup::iterator groupIt = m_nameToObjectGroup.find(groupName);
if (groupIt == m_nameToObjectGroup.end())
return;
for (int id : *groupIt->second)
unbind(id);
m_nameToObjectGroup.remove(groupName);
}