本文整理汇总了C++中String8::length方法的典型用法代码示例。如果您正苦于以下问题:C++ String8::length方法的具体用法?C++ String8::length怎么用?C++ String8::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String8
的用法示例。
在下文中一共展示了String8::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StriWrapLineStart
StriWrapLineStart(const String8& s, R_len_t v) :
str(s.c_str()) {
nbytes = s.length()+v;
count = s.countCodePoints()+v;
width = stri__width_string(s.c_str(), s.length());
str.append(std::string(v, ' '));
}
示例2: okayToCompress
/*
* Determine whether or not we want to try to compress this file based
* on the file extension.
*/
bool okayToCompress(Bundle* bundle, const String8& pathName)
{
String8 ext = pathName.getPathExtension();
int i;
if (ext.length() == 0)
return true;
for (i = 0; i < NELEM(kNoCompressExt); i++) {
if (strcasecmp(ext.string(), kNoCompressExt[i]) == 0)
return false;
}
const android::Vector<const char*>& others(bundle->getNoCompressExtensions());
for (i = 0; i < (int)others.size(); i++) {
const char* str = others[i];
int pos = pathName.length() - strlen(str);
if (pos < 0) {
continue;
}
const char* path = pathName.string();
if (strcasecmp(path + pos, str) == 0) {
return false;
}
}
return true;
}
示例3:
void
BaseCamAdapter::
showParameters(String8 const& param) const
{
static char bufParam[4096];
const int count = 768;
char *pbuf = bufParam;
char ch;
uint32_t len;
uint32_t i, loop;
pbuf[0] = 0;
len = param.length();
if ( len > 4096) {
len = 4096;
}
::strcpy(pbuf, param.string());
loop = (len + count - 1) / count;
CAM_LOGD("[showParameters]: %d, %d \n", loop, len);
for (i = 0; i < loop; i++) {
ch = pbuf[count];
pbuf[count] = 0;
CAM_LOGD("(%s) \n", pbuf);
pbuf[count] = ch;
pbuf += count;
}
}
示例4: if
void
IParamsManager::
showParameters(String8 const& rs8Param)
{
String8 s8Log;
ssize_t const max_cpy_len = 767;
size_t loop = 0;
size_t const len = rs8Param.length();
char const* pHead = rs8Param.string();
char const*const pEnd = pHead + len;
for (; pHead < pEnd;)
{
ssize_t cpy_len = pEnd - pHead;
if ( cpy_len > max_cpy_len )
{
cpy_len = max_cpy_len;
}
s8Log.setTo(pHead, cpy_len);
CAM_LOGD("%s", s8Log.string());
pHead += cpy_len;
loop++;
}
MY_LOGD("%zu %zu", loop, len);
}
示例5:
const char *CameraParameters::get(const char *key) const
{
String8 v = mMap.valueFor(String8(key));
if (v.length() == 0)
return 0;
return v.string();
}
示例6: getChannelMasksForAF
void HDMIAudioCaps::getChannelMasksForAF(String8& masks) {
Mutex::Autolock _l(mLock);
masks.clear();
// If the sink does not support basic audio, then it supports no audio.
if (!mBasicAudioSupported)
return;
masks.append("AUDIO_CHANNEL_OUT_STEREO");
// To keep things simple, only report mode information for the mode
// which supports the maximum number of channels.
ssize_t ndx = getMaxChModeNdx_l();
if (ndx < 0)
return;
if (mModes[ndx].max_ch >= 6) {
if (masks.length())
masks.append("|");
masks.append((mModes[ndx].max_ch >= 8)
? "AUDIO_CHANNEL_OUT_5POINT1|AUDIO_CHANNEL_OUT_7POINT1"
: "AUDIO_CHANNEL_OUT_5POINT1");
}
}
示例7: strcpy
AudioParameter::AudioParameter(const String8& keyValuePairs)
{
char *str = new char[keyValuePairs.length()+1];
mKeyValuePairs = keyValuePairs;
char *last;
strcpy(str, keyValuePairs.string());
char *pair = strtok_r(str, ";", &last);
while (pair != NULL) {
if (strlen(pair) != 0) {
size_t eqIdx = strcspn(pair, "=");
String8 key = String8(pair, eqIdx);
String8 value;
if (eqIdx == strlen(pair)) {
value = String8("");
} else {
value = String8(pair + eqIdx + 1);
}
if (mParameters.indexOfKey(key) < 0) {
mParameters.add(key, value);
} else {
mParameters.replaceValueFor(key, value);
}
} else {
ALOGV("AudioParameter() cstor empty key value pair");
}
pair = strtok_r(NULL, ";", &last);
}
delete[] str;
}
示例8: printRefs
void printRefs() const
{
String8 text;
{
Mutex::Autolock _l(mMutex);
char buf[128];
sprintf(buf, "Strong references on RefBase %p (weakref_type %p):\n", mBase, this);
text.append(buf);
printRefsLocked(&text, mStrongRefs);
sprintf(buf, "Weak references on RefBase %p (weakref_type %p):\n", mBase, this);
text.append(buf);
printRefsLocked(&text, mWeakRefs);
}
{
char name[100];
snprintf(name, 100, DEBUG_REFS_CALLSTACK_PATH "/%p.stack", this);
int rc = open(name, O_RDWR | O_CREAT | O_APPEND, 644);
if (rc >= 0) {
write(rc, text.string(), text.length());
close(rc);
ALOGD("STACK TRACE for %p saved in %s", this, name);
}
else ALOGE("FAILED TO PRINT STACK TRACE for %p in %s: %s", this,
name, strerror(errno));
}
}
示例9: ALOGD
status_t
BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
{
if (m_status != NO_ERROR) {
return m_status;
}
ssize_t amt;
amt = write_padding_for(m_pos);
if (amt != 0) {
return amt;
}
String8 k;
if (m_keyPrefix.length() > 0) {
k = m_keyPrefix;
k += ":";
k += key;
} else {
k = key;
}
if (DEBUG) {
ALOGD("Writing header: prefix='%s' key='%s' dataSize=%d", m_keyPrefix.string(),
key.string(), dataSize);
}
entity_header_v1 header;
ssize_t keyLen;
keyLen = k.length();
header.type = tolel(BACKUP_HEADER_ENTITY_V1);
header.keyLen = tolel(keyLen);
header.dataSize = tolel(dataSize);
if (DEBUG) ALOGI("writing entity header, %d bytes", sizeof(entity_header_v1));
amt = write(m_fd, &header, sizeof(entity_header_v1));
if (amt != sizeof(entity_header_v1)) {
m_status = errno;
return m_status;
}
m_pos += amt;
if (DEBUG) ALOGI("writing entity header key, %ld bytes", keyLen+1);
amt = write(m_fd, k.string(), keyLen+1);
if (amt != keyLen+1) {
m_status = errno;
return m_status;
}
m_pos += amt;
amt = write_padding_for(keyLen+1);
m_entityCount++;
return amt;
}
示例10: onGetDrmObjectType
int FwdLockEngine::onGetDrmObjectType(int uniqueId,
const String8& path,
const String8& mimeType) {
String8 mimeStr = String8(mimeType);
LOG_VERBOSE("FwdLockEngine::onGetDrmObjectType");
/* Checks whether
* 1. path and mime type both are not empty strings (meaning unavailable) else content is unknown
* 2. if one of them is empty string and if other is known then its a DRM Content Object.
* 3. if both of them are available, then both may be of known type
* (regardless of the relation between them to make it compatible with other DRM Engines)
*/
if (((0 == path.length()) || onCanHandle(uniqueId, path)) &&
((0 == mimeType.length()) || IsMimeTypeSupported(mimeType)) && (mimeType != path) ) {
return DrmObjectType::CONTENT;
}
return DrmObjectType::UNKNOWN;
}
示例11: appendInputDeviceConfigurationFileRelativePath
static void appendInputDeviceConfigurationFileRelativePath(String8& path,
const String8& name, InputDeviceConfigurationFileType type) {
path.append(CONFIGURATION_FILE_DIR[type]);
for (size_t i = 0; i < name.length(); i++) {
char ch = name[i];
if (!isValidNameChar(ch)) {
ch = '_';
}
path.append(&ch, 1);
}
path.append(CONFIGURATION_FILE_EXTENSION[type]);
}
示例12: LOGE
Element *Element::createFromStream(Context *rsc, IStream *stream) {
// First make sure we are reading the correct object
RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
if (classID != RS_A3D_CLASS_ID_ELEMENT) {
LOGE("element loading skipped due to invalid class id\n");
return NULL;
}
String8 name;
stream->loadString(&name);
Component component;
component.loadFromStream(stream);
uint32_t fieldCount = stream->loadU32();
if (!fieldCount) {
return (Element *)Element::create(rsc,
component.getType(),
component.getKind(),
component.getIsNormalized(),
component.getVectorSize());;
}
const Element **subElems = new const Element *[fieldCount];
const char **subElemNames = new const char *[fieldCount];
size_t *subElemNamesLengths = new size_t[fieldCount];
uint32_t *arraySizes = new uint32_t[fieldCount];
String8 elemName;
for (uint32_t ct = 0; ct < fieldCount; ct ++) {
stream->loadString(&elemName);
subElemNamesLengths[ct] = elemName.length();
char *tmpName = new char[subElemNamesLengths[ct]];
memcpy(tmpName, elemName.string(), subElemNamesLengths[ct]);
subElemNames[ct] = tmpName;
arraySizes[ct] = stream->loadU32();
subElems[ct] = Element::createFromStream(rsc, stream);
}
const Element *elem = Element::create(rsc, fieldCount, subElems, subElemNames,
subElemNamesLengths, arraySizes);
for (uint32_t ct = 0; ct < fieldCount; ct ++) {
delete [] subElemNames[ct];
subElems[ct]->decUserRef();
}
delete[] subElems;
delete[] subElemNames;
delete[] subElemNamesLengths;
delete[] arraySizes;
return (Element *)elem;
}
示例13: sizeof
void EventLog::TagBuffer::writeString8(const String8& value) {
if (mOverflow) return;
const int32_t stringLen = value.length();
const size_t needed = 1 + sizeof(int32_t) + stringLen;
if (mPos + needed > STORAGE_MAX_SIZE) {
mOverflow = true;
return;
}
mStorage[mPos + 0] = EVENT_TYPE_STRING;
memcpy(&mStorage[mPos + 1], &stringLen, sizeof(int32_t));
memcpy(&mStorage[mPos + 5], value.string(), stringLen);
mPos += needed;
}
示例14: canHandle
bool DrmManager::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
const String8 plugInId = getSupportedPlugInId(mimeType);
bool result = (EMPTY_STRING != plugInId) ? true : false;
if (0 < path.length()) {
if (result) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.canHandle(uniqueId, path);
} else {
result = canHandle(uniqueId, path);
}
}
return result;
}
示例15: usbCamGetParameters
/******************************************************************************
* Function: usbCamGetParameters
* Description: This function allocates memory for parameter string,
* composes and returns the parameter string
*
* Input parameters:
* camHal - camera HAL handle
*
* Return values:
* Address to the parameter string
*
* Notes: none
*****************************************************************************/
char* usbCamGetParameters(camera_hardware_t *camHal)
{
ALOGD("%s: E", __func__);
char *parms = NULL;
char* rc = NULL;
String8 str;
QCameraParameters qParam = camHal->qCamParams;
//qParam.dump();
str = qParam.flatten( );
rc = (char *)malloc(sizeof(char)*(str.length()+1));
if(rc != NULL){
memset(rc, 0, sizeof(char)*(str.length()+1));
strncpy(rc, str.string(), str.length());
rc[str.length()] = 0;
parms = rc;
}
PRINT_PARAM_STR(parms);
ALOGD("%s: X", __func__);
return (parms);
} /* usbCamGetParameters */