本文整理汇总了C++中String::Equals方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Equals方法的具体用法?C++ String::Equals怎么用?C++ String::Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: constructor
/**
* Settings class constructor from a key=value; pairs formatted string. The string is
* typically returned by Settings.toString() method.
* @throws IllegalArgumentException if the string is not correctly formatted.
*/
ECode CPresetReverbSettings::constructor(
/* [in] */ const String& settings)
{
AutoPtr<ArrayOf<String> > values;
StringUtils::Split(settings, String("=;"), (ArrayOf<String>**)&values);
Int32 tokens = values ? values->GetLength() : 0;
if (tokens != 3) {
// throw new IllegalArgumentException("settings: " + settings);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
Int32 index = 0;
String key = (*values)[index++];
if (!key.Equals("PresetReverb")) {
// throw new IllegalArgumentException("invalid settings for PresetReverb: " + key);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
// try {
key = (*values)[index++];
if (!key.Equals("preset")) {
// throw new IllegalArgumentException("invalid key name: " + key);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
mPreset = StringUtils::ParseInt16((*values)[index++]);
// } catch (NumberFormatException nfe) {
// throw new IllegalArgumentException("invalid value for key: " + key);
// }
return NOERROR;
}
示例2: HttpMultipartEntity
void
ProjectGiraffeTab4::OnAppControlCompleteResponseReceived(const AppId &appId, const String &operationId, AppCtrlResult appControlResult, const IMap *extraData)
{
AppLogTag("camera1", "appid %ls opid %ls", appId.GetPointer(), operationId.GetPointer());
if (appId.Equals(L"tizen.filemanager", true) &&
operationId.Equals(L"http://tizen.org/appcontrol/operation/pick", true))
{
if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) {
AppLogTag("camera1", "Media list success.");
String pathKey = L"path";
String *filePath = (String *)extraData->GetValue(pathKey);
AppLogTag("camera1", "filepath: %ls", filePath->GetPointer());
HttpMultipartEntity* userParameters = new HttpMultipartEntity();
userParameters->Construct();
userParameters->AddFilePart(L"avatar", *filePath);
HttpConnection *connection = HttpConnection::userUpdatePutConnection(this, userParameters);
connection->begin();
// TODO: figure out when to free
// delete userParameters;
} else if (appControlResult == APP_CTRL_RESULT_CANCELED) {
AppLogTag("camera1", "Media list canceled.");
} else if (appControlResult == APP_CTRL_RESULT_FAILED) {
AppLogTag("camera1", "Media list failed.");
}
} else if (appId.Equals(L"tizen.camera", true) &&
operationId.Equals(L"http://tizen.org/appcontrol/operation/createcontent", true))
{
AppLogTag("camera1", "camcam");
if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) {
AppLogTag("camera1", "Camera capture success.");
String pathKey = L"path";
String *filePath = (String *)extraData->GetValue(pathKey);
AppLogTag("camera1", "filepath: %ls", filePath->GetPointer());
HttpMultipartEntity* userParameters = new HttpMultipartEntity();
userParameters->Construct();
userParameters->AddFilePart(L"avatar", *filePath);
HttpConnection *connection = HttpConnection::userUpdatePutConnection(this, userParameters);
connection->begin();
// TODO: figure out when to free
// delete userParameters;
} else if (appControlResult == APP_CTRL_RESULT_CANCELED) {
AppLogTag("camera1", "Camera capture canceled.");
} else if (appControlResult == APP_CTRL_RESULT_FAILED) {
AppLogTag("camera1", "Camera capture failed.");
} else if (appControlResult == APP_CTRL_RESULT_TERMINATED) {
AppLogTag("camera1", "Camera capture terminated.");
} else if (appControlResult == APP_CTRL_RESULT_ABORTED) {
AppLogTag("camera1", "Camera capture aborted.");
}
}
}
示例3: CopyTables
ECode CNamespaceSupport::Context::DeclarePrefix(
/* [in] */ const String& prefix,
/* [in] */ const String& uri)
{
// Lazy processing...
if (!mDeclsOK) {
// throw new IllegalStateException ("can't declare any more prefixes in this context");
return E_ILLEGAL_STATE_EXCEPTION;
}
if (!mDeclSeen) {
CopyTables();
}
if (mDeclarations == NULL) {
CArrayList::New((IArrayList**)&mDeclarations);
}
if (prefix.Equals("")) {
if (uri.Equals("")) {
mDefaultNS = String(NULL);
}
else {
mDefaultNS = uri;
}
}
else {
mPrefixTable[prefix] = uri;
mUriTable[uri] = prefix; // may wipe out another prefix
}
AutoPtr<ICharSequence> seq;
CString::New(prefix, (ICharSequence**)&seq);
return mDeclarations->Add(seq);
}
示例4:
void
MapForm::OnAppControlCompleted(const String& appControlId, const String& operationId, const IList* pResultList)
{
String* pResult = null;
if (appControlId.Equals(APPCONTROL_PROVIDER_SETTINGS))
{
pResult = (Osp::Base::String*)pResultList->GetAt(0);
if (pResult->Equals(APPCONTROL_RESULT_SUCCEEDED))
{
pResult = (Osp::Base::String*)pResultList->GetAt(1);
if (pResult->Equals(String(L"category:Location")))
{
pResult = (Osp::Base::String*)pResultList->GetAt(2);
if (pResult->Equals(String(L"GPSEnabled")))
{
AppLog("LocationServices are enabled.");
}
else
{
AppLog("LocationServices are disabled.");
}
}
}
}
}
示例5: RilStateToState
/**
* See state strings defined in ril.h RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
*/
ECode COperatorInfo::RilStateToState(
/* [in] */ const String& s,
/* [out] */ IOperatorInfoState* result)
{
VALIDATE_NOT_NULL(result);
if (s.Equals("unknown")) {
*result = OperatorInfoState_UNKNOWN;
return NOERROR;
}
else if (s.Equals("available")) {
*result = OperatorInfoState_AVAILABLE;
return NOERROR;
}
else if (s.Equals("current")) {
*result = OperatorInfoState_CURRENT;
return NOERROR;
}
else if (s.Equals("forbidden")) {
*result = OperatorInfoState_FORBIDDEN;
return NOERROR;
}
// throw new RuntimeException(
// "RIL impl error: Invalid network state '" + s + "'");
return E_RUNTIME_EXCEPTION;
}
示例6: GetService
ECode Provider::GetService(
/* [in] */ const String& type,
/* [out] */ IProviderService** retService)
{
VALIDATE_NOT_NULL(retService)
AutoLock lock(this);
UpdatePropertyServiceTable();
if (mLastServicesByType != NULL && type.Equals(mLastType)) {
*retService = mLastServicesByType;
REFCOUNT_ADD(*retService);
return NOERROR;
}
AutoPtr<ISet> services;
GetServices((ISet**)&services);
AutoPtr<IIterator> it;
services->GetIterator((IIterator**)&it);
Boolean hasNext;
while (it->HasNext(&hasNext), hasNext) {
AutoPtr<IProviderService> service;
it->GetNext((IInterface**)&service);
String srvType;
service->GetType(&srvType);
if (type.Equals(srvType)) {
mLastType = type;
mLastServicesByType = service;
*retService = service;
REFCOUNT_ADD(*retService);
return NOERROR;
}
}
*retService = NULL;
return NOERROR;
}
示例7: ChannelSetIsValid
Boolean CBatchedScanSettings::ChannelSetIsValid()
{
Boolean bIsEmpty;
if (mChannelSet == NULL || (mChannelSet->IsEmpty(&bIsEmpty), bIsEmpty)) {
return TRUE;
}
AutoPtr<IIterator> iter;
mChannelSet->GetIterator((IIterator**)&iter);
Boolean bNext;
iter->HasNext(&bNext);
for (; bNext; iter->HasNext(&bNext)) {
AutoPtr<ICharSequence> iChannel;
iter->GetNext((IInterface**)&iChannel);
String channel;
iChannel->ToString(&channel);
// try {
Int32 i = StringUtils::ParseInt32(channel);
if (i > 0 && i <= MAX_WIFI_CHANNEL) continue;
// } catch (NumberFormatException e) {}
if (channel.Equals("A") || channel.Equals("B")) continue;
return FALSE;
}
return TRUE;
}
示例8: ValueOf
static ProfileGroupMode ValueOf(const String& modeStr)
{
if (modeStr.Equals("SUPPRESS")) return ProfileGroupMode_SUPPRESS;
else if (modeStr.Equals("DEFAULT")) return ProfileGroupMode_DEFAULT;
else if (modeStr.Equals("OVERRIDE")) return ProfileGroupMode_OVERRIDE;
else return ProfileGroupMode_DEFAULT;
}
示例9: FromMap
ECode VersionInfo::FromMap(
/* [in] */ const String& pckg,
/* [in] */ IMap* info,
/* [in] */ IClassLoader* clsldr,
/* [out] */ IVersionInfo** versionInfo)
{
VALIDATE_NOT_NULL(versionInfo)
*versionInfo = NULL;
if (pckgs == NULL) {
Logger::E("VersionInfo", "Package identifier list must not be null.");
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
String module = String(NULL);
String release = String(NULL);
String timestamp = String(NULL);
if (info != NULL) {
AutoPtr<ICharSequence> cs;
CStringWrapper::New(PROPERTY_MODULE, (ICharSequence**)&cs);
AutoPtr<IInterface> value;
info->Get(cs, (IInterface**)&value);
AutoPtr<ICharSequence> v = ICharSequence::Probe(value);
v->ToString(&module);
if ((!module.IsNull()) && (module.GetLength() < 1)) {
module = String(NULL);
}
cs = NULL;
CStringWrapper::New(PROPERTY_RELEASE, (ICharSequence**)&cs);
value = NULL;
info->Get(cs, (IInterface**)&value);
v = ICharSequence::Probe(value);
v->ToString(&release);
if ((!release.IsNull()) && ((release.GetLength() < 1) ||
(release.Equals("${pom.version}")))) {
release = String(NULL);
}
cs = NULL;
CStringWrapper::New(PROPERTY_TIMESTAMP, (ICharSequence**)&cs);
value = NULL;
info->Get(cs, (IInterface**)&value);
v = ICharSequence::Probe(value);
v->ToString(×tamp);
if ((!timestamp.IsNull()) && ((timestamp.GetLength() < 1) ||
(timestamp.Equals("${mvn.timestamp}")))) {
timestamp = String(NULL);
}
} // if info
String clsldrstr = String(NULL);
if (clsldr != NULL) {
IObject::Probe(clsldr)->ToString(&clsldrstr);
}
*info = (IVersionInfo*)new VersionInfo(pckg, module, release, timestamp, clsldrstr);
REFCOUNT_ADD(*info)
return NOERROR;
}
示例10: constructor
/**
* Settings class constructor from a key=value; pairs formatted string. The string is
* typically returned by Settings.toString() method.
* @throws IllegalArgumentException if the string is not correctly formatted.
*/
ECode CEqualizerSettings::constructor(
/* [in] */ const String& settings)
{
AutoPtr<ArrayOf<String> > values;
StringUtils::Split(settings, String("=;"), (ArrayOf<String>**)&values);
Int32 tokens = values ? values->GetLength() : 0;
if (tokens < 5) {
// throw new IllegalArgumentException("settings: " + settings);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
Int32 index = 0;
String key = (*values)[index++];
if (!key.Equals("Equalizer")) {
// throw new IllegalArgumentException("invalid settings for Equalizer: " + key);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
// try {
key = (*values)[index++];
if (!key.Equals("curPreset")) {
// throw new IllegalArgumentException("invalid key name: " + key);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
mCurPreset = StringUtils::ParseInt32((*values)[index++]);
key = (*values)[index++];
if (!key.Equals("numBands")) {
// throw new IllegalArgumentException("invalid key name: " + key);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
mNumBands = StringUtils::ParseInt32((*values)[index++]);
if (StringUtils::ParseInt32((*values)[index++]) != mNumBands*2) {
// throw new IllegalArgumentException("settings: " + settings);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
// try {
mBandLevels = ArrayOf<Int16>::Alloc(mNumBands);
for (int i = 0; i < mNumBands; i++) {
key = (*values)[index++];
if (!key.Equals(String("band") + StringUtils::Int32ToString(i+1) + String("Level"))) {
// throw new IllegalArgumentException("invalid key name: " + key);
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
(*mBandLevels)[i] = StringUtils::ParseInt32((*values)[index++]);
}
// } catch (NumberFormatException nfe) {
// throw new IllegalArgumentException("invalid value for key: " + key);
// }
return NOERROR;
}
示例11: OpenInputStream
/**
* Open a stream on to the content associated with a content URI. If there
* is no data associated with the URI, FileNotFoundException is thrown.
*
* <h5>Accepts the following URI schemes:</h5>
* <ul>
* <li>content ({@link #SCHEME_CONTENT})</li>
* <li>android.resource ({@link #SCHEME_ANDROID_RESOURCE})</li>
* <li>file ({@link #SCHEME_FILE})</li>
* </ul>
*
* <p>See {@link #openAssetFileDescriptor(Uri, String)} for more information
* on these schemes.
*
* @param uri The desired URI.
* @return InputStream
* @throws FileNotFoundException if the provided URI could not be opened.
* @see #openAssetFileDescriptor(Uri, String)
*/
ECode ContentResolver::OpenInputStream(
/* [in] */ IUri* uri,
/* [out] */ IInputStream** istream)
{
VALIDATE_NOT_NULL(istream);
String scheme;
FAIL_RETURN(uri->GetScheme(&scheme));
if (scheme.Equals(SCHEME_ELASTOS_RESOURCE)) {
// Note: left here to avoid breaking compatibility. May be removed
// with sufficient testing.
AutoPtr<IOpenResourceIdResult> r;
FAIL_RETURN(GetResourceId(uri, (IOpenResourceIdResult**)&r));
// try {
AutoPtr<IResources> resources;
FAIL_RETURN(r->GetResources((IResources**)&resources));
Int32 id;
FAIL_RETURN(r->GetResourceId(&id));
return resources->OpenRawResource(id, istream);
// } catch (Resources.NotFoundException ex) {
// throw new FileNotFoundException("Resource does not exist: " + uri);
// }
} else if (scheme.Equals(SCHEME_FILE)) {
// Note: left here to avoid breaking compatibility. May be removed
// with sufficient testing.
String path;
FAIL_RETURN(uri->GetPath(&path));
return CFileInputStream::New(path, (IFileInputStream**)&istream);
} else {
AutoPtr<IAssetFileDescriptor> fd;
FAIL_RETURN(OpenAssetFileDescriptor(
uri, String("r"), (IAssetFileDescriptor**)&fd));
// try {
if (fd == NULL) {
*istream = NULL;
return NOERROR;
}
else {
// TODO: ALEX
// return fd->CreateInputStream(istream);
return E_NOT_IMPLEMENTED;
}
// } catch (IOException e) {
// throw new FileNotFoundException("Unable to create stream");
// }
}
}
示例12: OnCreateCustomFromTag
ECode PreferenceInflater::OnCreateCustomFromTag(
/* [in] */ IXmlPullParser* parser,
/* [in] */ IInterface* _parentPreference,
/* [in] */ IAttributeSet* attrs,
/* [out] */ Boolean* res)
{
VALIDATE_NOT_NULL(res)
*res = FALSE;
AutoPtr<IPreference> parentPreference = IPreference::Probe(_parentPreference);
assert(parentPreference != NULL);
String tag;
parser->GetName(&tag);
if (tag.Equals(INTENT_TAG_NAME)) {
AutoPtr<IIntent> intent;
AutoPtr<IContext> ctx;
GetContext((IContext**)&ctx);
AutoPtr<IResources> resource;
ctx->GetResources((IResources**)&resource);
if (Intent::ParseIntent(resource, parser, attrs, (IIntent**)&intent) == (ECode)E_IO_EXCEPTION) {
Slogger::D("PreferenceInflater", "Error parsing preference");
return E_XML_PULL_PARSER_EXCEPTION;
}
if (intent != NULL) {
parentPreference->SetIntent(intent);
}
*res = TRUE;
return NOERROR;
}
else if (tag.Equals(EXTRA_TAG_NAME)) {
AutoPtr<IContext> ctx;
GetContext((IContext**)&ctx);
AutoPtr<IResources> resource;
ctx->GetResources((IResources**)&resource);
AutoPtr<IBundle> data;
parentPreference->GetExtras((IBundle**)&data);
resource->ParseBundleExtra(EXTRA_TAG_NAME, attrs, data);
if (XmlUtils::SkipCurrentTag(parser) == (ECode)E_IO_EXCEPTION) {
Slogger::D("PreferenceInflater", "Error parsing preference");
return E_XML_PULL_PARSER_EXCEPTION;
}
*res = TRUE;
return NOERROR;
}
return NOERROR;
}
示例13: GetBoolean
ECode CLockSettingsService::GetBoolean(
/* [in] */ const String& key,
/* [in] */ Boolean defaultValue,
/* [in] */ Int32 userId,
/* [out] */ Boolean* res)
{
//checkReadPermission(userId);
VALIDATE_NOT_NULL(res);
String value;
FAIL_RETURN(ReadFromDb(key, String(NULL), userId, &value))
*res = TextUtils::IsEmpty(value) ?
defaultValue : (value.Equals("1") || value.Equals("TRUE"));
return NOERROR;
}
示例14: test_caseInsensitiveButCasePreserving
int CTest::test_caseInsensitiveButCasePreserving(int argc, char* argv[])
{
AutoPtr<IRawHeaders> h;
CRawHeaders::New((IRawHeaders**)&h);
String str0("Content-Type");
String str1("text/plain");
h->Add(str0, str1);
// Case-insensitive:
String strOut;
h->Get(str0, &strOut);
Boolean flag = strOut.Equals(str1);
assert(flag == TRUE);
String str2("Content-type");
h->Get(str2, &strOut);
flag = strOut.Equals(str1);
assert(flag == TRUE);
String str3("content-type");
h->Get(str3, &strOut);
flag = strOut.Equals(str1);
assert(flag == TRUE);
String str4("CONTENT-TYPE");
h->Get(str4, &strOut);
flag = strOut.Equals(str1);
assert(flag == TRUE);
// ...but case-preserving:
AutoPtr<IMap> innerMap;
h->ToMultimap((IMap**)&innerMap);
AutoPtr<ISet> keyset;
innerMap->KeySet((ISet**)&keyset);
AutoPtr<ArrayOf<IInterface*> > array;
keyset->ToArray((ArrayOf<IInterface*>**)&array);
AutoPtr<ICharSequence> cs = (ICharSequence*)ICharSequence::Probe((*array)[0]);
String str5(String("Content-Type"));
cs->ToString(&strOut);
flag = strOut.Equals(str5);
assert(flag == TRUE);
// We differ from the RI in that the Map we return is also case-insensitive.
// Our behavior seems more consistent. (And code that works on the RI will work on Android.)
// AutoPtr<ICharSequence> cs1;
// CString::New(String("Content-Type"), (ICharSequence**)&cs1);
// AutoPtr<IInterface> value;
// innerMap->Get(cs1, (IInterface**)&value);
// assertEquals(Arrays.asList("text/plain"), h.toMultimap().get("Content-Type"));
// assertEquals(Arrays.asList("text/plain"), h.toMultimap().get("Content-type")); // RI fails this.
}
示例15: if
void
Kamera::OnAppControlCompleted (const String &appControlId, const String &operationId, const IList *pResultList) {
//This method is invoked when an application control callback event occurs.
String* pCaptureResult = null;
if (appControlId.Equals(APPCONTROL_CAMERA) && operationId.Equals(OPERATION_CAPTURE))
{
pCaptureResult = (Osp::Base::String*)pResultList->GetAt(0);
if (pCaptureResult->Equals(String(APPCONTROL_RESULT_SUCCEEDED)))
{
String eval;
AppLog("Camera capture success.");
String* pCapturePath = (String*)pResultList->GetAt(1);
// copying to app Home Folder
String homeFilename;
homeFilename.Format(128, L"/Home/%S", File::GetFileName(*pCapturePath).GetPointer());
result r = File::Copy(*pCapturePath, homeFilename, true);
if(IsFailed(r)) {
AppLogException("Could not copy picture");
eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Could not copy picture')", callbackId.GetPointer());
AppLogDebug("%S", eval.GetPointer());
pWeb->EvaluateJavascriptN(eval);
}
// Uri imageUri;
// imageUri.setUri(homeFilename);
eval.Clear();
eval.Format(512, L"PhoneGap.callbacks['%S'].success('file://%S')", callbackId.GetPointer(), homeFilename.GetPointer());
AppLogDebug("%S", eval.GetPointer());
pWeb->EvaluateJavascriptN(eval);
}
else if (pCaptureResult->Equals(String(APPCONTROL_RESULT_CANCELED)))
{
AppLog("Camera capture canceled.");
String eval;
eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Camera capture canceled')", callbackId.GetPointer());
pWeb->EvaluateJavascriptN(eval);
}
else if (pCaptureResult->Equals(String(APPCONTROL_RESULT_FAILED)))
{
AppLog("Camera capture failed.");
String eval;
eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Camera capture failed')", callbackId.GetPointer());
pWeb->EvaluateJavascriptN(eval);
}
}
}