本文整理汇总了C++中String16::size方法的典型用法代码示例。如果您正苦于以下问题:C++ String16::size方法的具体用法?C++ String16::size怎么用?C++ String16::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String16
的用法示例。
在下文中一共展示了String16::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3:
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;
}
示例4: InitConnect
TEST(OpenCVEngineTest, GetPathForUnExistVersion)
{
sp<IOpenCVEngine> Engine = InitConnect();
EXPECT_FALSE(NULL == Engine.get());
String16 result = Engine->GetLibPathByVersion(String16("2.5"));
EXPECT_EQ(0, result.size());
}
示例5: Say
status_t ChatSession::Say(const String16& statement)
{
HRESULT hr = S_OK;
String16 userName;
int callerPid = GetCallerPID();
_TRACE("ChatSession::Say(%s) >>",DISPLAY_STRING16(statement));
{
Mutex::Autolock _lock(m_csAdviseLock);
sp<IBinder> binder = m_Listeners.valueFor(callerPid);
sp<IChatSessionEvents> eventSink = interface_cast<IChatSessionEvents>(binder);
if(eventSink != NULL){
_TRACE("**source(cse:%p binder:%p) ",eventSink.get(),binder.get());
userName = eventSink->GetUserName();
}
}
if (userName.size() && CheckAccess(userName))
{
{
Mutex::Autolock _lock(m_csStatementLock);
m_statements.add(userName + String16("\t:\t") +statement);
}
//Fire_OnNewStatement(userName, statement);
ChatWorker::getInstance().Defer_OnNewStatement(this,userName, statement);
}
else
hr = E_ACCESSDENIED;
_TRACE("ChatSession::Say() <<hr:%x",hr);
return hr;
}
示例6: _lock
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;
}
示例7: InitConnect
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());
}
示例8:
String16
pseudo_generate_expansion(const unsigned int length) {
String16 result = k_expansion_string;
const char16_t* s = result.string();
if (result.size() < length) {
result += String16(" ");
result += pseudo_generate_expansion(length - result.size());
} else {
int ext = 0;
// Should contain only whole words, so looking for a space
for (unsigned int i = length + 1; i < result.size(); ++i) {
++ext;
if (s[i] == ' ') {
break;
}
}
result.remove(length + ext, 0);
}
return result;
}
示例9:
static String8 good_old_string(const String16& src)
{
String8 name8;
char ch8[2];
ch8[1] = 0;
for (unsigned j = 0; j < src.size(); j++) {
char16_t ch = src[j];
if (ch < 128) ch8[0] = (char)ch;
name8.append(ch8);
}
return name8;
}
示例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: onTransact
/* 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;
}
示例12: 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());
}
示例13: setTo
status_t String16::setTo(const String16& other, size_t len, size_t begin)
{
const size_t N = other.size();
if (begin >= N) {
SharedBuffer::bufferFromData(mString)->release();
mString = getEmptyString();
return NO_ERROR;
}
if ((begin+len) > N) len = N-begin;
if (begin == 0 && len == N) {
setTo(other);
return NO_ERROR;
}
if (&other == this) {
LOG_ALWAYS_FATAL("Not implemented");
}
return setTo(other.string()+begin, len);
}
示例14: size
status_t String16::append(const String16& other)
{
const size_t myLen = size();
const size_t otherLen = other.size();
if (myLen == 0) {
setTo(other);
return NO_ERROR;
} else if (otherLen == 0) {
return NO_ERROR;
}
SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
->editResize((myLen+otherLen+1)*sizeof(char16_t));
if (buf) {
char16_t* str = (char16_t*)buf->data();
memcpy(str+myLen, other, (otherLen+1)*sizeof(char16_t));
mString = str;
return NO_ERROR;
}
return NO_MEMORY;
}
示例15: getNamespaceResourcePackage
String16 getNamespaceResourcePackage(String16 namespaceUri, bool* outIsPublic)
{
//printf("%s starts with %s?\n", String8(namespaceUri).string(),
// String8(RESOURCES_PREFIX).string());
size_t prefixSize;
bool isPublic = true;
if (namespaceUri.startsWith(RESOURCES_PREFIX)) {
prefixSize = RESOURCES_PREFIX.size();
} else if (namespaceUri.startsWith(RESOURCES_PRV_PREFIX)) {
isPublic = false;
prefixSize = RESOURCES_PRV_PREFIX.size();
} else {
if (outIsPublic) *outIsPublic = isPublic; // = true
return String16();
}
//printf("YES!\n");
//printf("namespace: %s\n", String8(String16(namespaceUri, namespaceUri.size()-prefixSize, prefixSize)).string());
if (outIsPublic) *outIsPublic = isPublic;
return String16(namespaceUri, namespaceUri.size()-prefixSize, prefixSize);
}