本文整理汇总了C++中String::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Contains方法的具体用法?C++ String::Contains怎么用?C++ String::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayText
result Enrollment::DisplayText(ByteBuffer& txBuffer, unsigned long buflen) {
String data;
char* pBuffer = null;
result res = E_SUCCESS;
txBuffer.Flip();
pBuffer = (char*) (txBuffer.GetPointer());
data.SetCapacity(buflen + 20);
res = data.Append(pBuffer);
TryReturn(res == E_SUCCESS, res, "Append Failed");
txBuffer.Clear();
if (data == L"__HELLO__") {
EnableControl(true);
__isConnected = true;
return res;
}
if (__isConnected == false) {
AppLog(
"Server hasn't received Initial message so all incoming content is discarded");
// Remove created NetEndPoint
delete __pUdpEndpoint;
__pUdpEndpoint = null;
return res;
}
if (data == L"__CLOSE__") {
SceneManager* pSceneManager = SceneManager::GetInstance();
AppAssert(pSceneManager);
pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CALENDAR));
OnClose();
return res;
}
int i = 0;
if (data.Contains(__pWorkList[i]->GetText())) {
__pWorkList[i++]->SetSelected(true);
}
if (data.Contains(__pWorkList[i]->GetText())) {
__pWorkList[i++]->SetSelected(true);
}
if (data.Contains(__pWorkList[i]->GetText())) {
__pWorkList[i++]->SetSelected(true);
}
if (data.Contains(__pWorkList[i]->GetText())) {
__pWorkList[i++]->SetSelected(true);
}
TryReturn(res == E_SUCCESS, res, "AppendText Failed");
for (int k = 0; k < MAX_WORK_COUNT; k++) {
__pWorkList[k]->RequestRedraw();
}
return res;
}
示例2: JumpToNextConditional
void Script::JumpToNextConditional()
{
// If the statement is not true, find an else or endif block..!
for (int i = currentLine; i < lines.Size(); ++i){
String l = lines[i];
if (l.Contains("elsif"))
{
std::cout<<"\nJumpToNextConditional: "<<l;
currentLine = i;
// Call this function again?
EvaluateLine(lines[i]);
return;
}
else if (l.Contains("else"))
{
/// Jump to this row ^^
currentLine = i;
lineFinished = true;
return;
}
else if (l.Contains("endif")){
currentLine = i;
lineFinished = true;
return;
}
}
}
示例3: LoadFromString
// Let's say you don't know if the input string is raw base64, or if it has
// bookends
// on it like -----BEGIN BLAH BLAH ...
// And if it DOES have Bookends, you don't know if they are escaped: -
// -----BEGIN ...
// Let's say you just want an easy function that will figure that crap out, and
// load the
// contents up properly into an OTASCIIArmor object. (That's what this function
// will do.)
//
// str_bookend is a default.
// So you could make it more specific like, -----BEGIN ENCRYPTED KEY (or
// whatever.)
//
// static
bool OTASCIIArmor::LoadFromString(OTASCIIArmor& ascArmor,
const String& strInput,
std::string str_bookend)
{
if (strInput.Contains(str_bookend)) // YES there are bookends around this.
{
const std::string str_escaped("- " + str_bookend);
const bool bEscaped = strInput.Contains(str_escaped);
String strLoadFrom(strInput);
if (!ascArmor.LoadFromString(strLoadFrom, bEscaped)) // removes the
// bookends so we
// have JUST the
// coded part.
{
// otErr << "%s: Failure loading string into OTASCIIArmor
// object:\n\n%s\n\n",
// __FUNCTION__, strInput.Get());
return false;
}
}
else
ascArmor.Set(strInput.Get());
return true;
}
示例4: ToFormat
String DateTime::ToFormat(const String& format) const
{
String s = format.IsEmpty() ? "M/D/YYYY" : format;
TimeSpan t = *this;
String ampm = "am";
if (s.Contains("am/pm") || s.Contains("AM/PM"))
{
s = s.Replace("am/pm", "{4}");
s = s.Replace("AM/PM", "{5}");
if (t.Hours() >= 12)
{
t = t.AddHours(-12);
ampm = "pm";
}
else if (t.Hours() == 0)
t = t.AddHours(12);
}
String AMPM = ampm.ToUpper();
YearString y(*this);
MonthString m(*this);
DayString d(*this);
s = s
.Replace("YYYY", "{0:~~~~}")
.Replace("YY", "{0:~~}")
.Replace("MMMM", "{1:~~~~}")
.Replace("MMM", "{1:~~~}")
.Replace("MM", "{1:~~}")
.Replace("M", "{1}")
.Replace("DDDD", "{2:~~~~}")
.Replace("DDD", "{2:~~~}")
.Replace("DD", "{2:~~}")
.Replace("D", "{2}")
.Replace("hh", "{3:HH}")
.Replace("h", "{3:H}")
.Replace("mm", "{3:MM}")
.Replace("m", "{3:M}")
.Replace("ss", "{3:SS}")
.Replace("s", "{3:S}")
.Replace("nnn", "{3:NNN}")
.Replace("nn", "{3:NN}")
.Replace("n", "{3:N}")
.Replace("{3:HH}", "{3:hh}")
.Replace("{3:H}", "{3:h}")
.Replace("{3:MM}", "{3:mm}")
.Replace("{3:M}", "{3:m}")
.Replace("{3:SS}", "{3:ss}")
.Replace("{3:S}", "{3:s}")
.Replace("{3:NNN}", "{3:nnn}")
.Replace("{3:NN}", "{3:nn}")
.Replace("{3:N}", "{3:n}");
if (s.Contains("{4}"))
s = s.Replace("{4}", ampm);
if (s.Contains("{5}"))
s = s.Replace("{5}", AMPM);
return Format(s, y, m, d, t);
}
示例5: Import
bool ModelImporter::Import()
{
String modelAssetFilename = asset_->GetPath();
importNode_ = new Node(context_);
// skip external animations, they will be brought in when importing their
// corresponding model
if (!modelAssetFilename.Contains("@"))
{
ImportModel();
if (importAnimations_)
{
ImportAnimations();
}
}
File outFile(context_);
if (!outFile.Open(asset_->GetCachePath(), FILE_WRITE))
ErrorExit("Could not open output file " + asset_->GetCachePath());
importNode_->SaveXML(outFile);
importNode_ = 0;
return true;
}
示例6: TryCreateStorage
AssetStoragePtr HttpAssetProvider::TryCreateStorage(HashMap<String, String> &storageParams, bool fromNetwork)
{
if (!storageParams.Contains("src") || !IsValidRef(storageParams["src"], ""))
return AssetStoragePtr();
if (storageParams.Contains("type") && storageParams["type"].Compare("HttpAssetStorage", false) != 0)
return AssetStoragePtr();
String baseUrl = storageParams["src"];
if (!baseUrl.EndsWith("/") && baseUrl.Contains("/"))
baseUrl = baseUrl.Substring(0, baseUrl.FindLast('/')+1);
if (!baseUrl.EndsWith("/"))
return AssetStoragePtr();
String name = UniqueName(storageParams["name"]);
// @todo liveupdate, liveupload, autodiscoverable etc. when actually needed
AssetStoragePtr storage = StorageForBaseURL(baseUrl);
if (!storage)
{
storage = AssetStoragePtr(new HttpAssetStorage(framework_->GetContext(), name, baseUrl, storageParams["localdir"]));
httpStorages_.Push(storage);
}
storage->SetReplicated(Urho3D::ToBool(storageParams["replicated"]));
return storage;
}
示例7: UserGroup
UserGroup *UserGroup::MatchFilter(const String &filter) {
UserGroup *filteredGroup = null;
String filterLowerCase;
filter.ToLowerCase(filterLowerCase);
for(int i = 0; i < _pUserList->GetCount(); i++) {
JsonObject *user;
String firstName;
String lastName;
String fullName;
JsonParseUtils::GetObject(_pUserList, i, user);
JsonParseUtils::GetString(*user, L"first_name", firstName);
JsonParseUtils::GetString(*user, L"last_name", lastName);
(firstName + L" " + lastName).ToLowerCase(fullName);
if(fullName.Contains(filterLowerCase)) {
if(filteredGroup == null) {
filteredGroup = new UserGroup();
filteredGroup->Construct(*_pGroupName);
}
filteredGroup->_pUserList->Add(user);
}
}
return filteredGroup;
}
示例8: Guard
/** Used to tokenize with some characters used to start and stop the tokenization procedure temporarily.
Sample use-case would be to tokenize the string "Aim(7,3), Guard(2,3)" and returning "Aim(7,3)" and "Guard(2,3)",
using the tokenizer ',' and ignoreparts "()".
Ignore parts should be in pairs, one starting the ignore part, the other stopping it.
*/
List<String> TokenizeIgnore(String string, String tokenizers, String ignoreParts)
{
List<String> tokens;
int inIgnorePart = 0;
const char * cString = string.c_str();
String str;
for (int i = 0; i < string.Length(); ++i)
{
char c = cString[i];
for (int i = 0; i < ignoreParts.Length(); i += 2)
{
if (c == ignoreParts.c_str()[i])
++inIgnorePart;
if (c == ignoreParts.c_str()[i+1])
--inIgnorePart;
}
if (tokenizers.Contains(c) && inIgnorePart == 0)
{
tokens.Add(str);
str = String();
}
else
{
str += c;
}
}
// Add final one.
tokens.Add(str);
return tokens;
}
示例9: lock
void UEventObserver::UEventThread::SendEvent(
/* [in] */ const String& message)
{
{
AutoLock lock(mKeysAndObserversLock);
List< AutoPtr<IInterface> >::Iterator it = mKeysAndObservers.Begin();
while (it != mKeysAndObservers.End()) {
AutoPtr<ICharSequence> csStr = ICharSequence::Probe(*it);
assert(csStr != NULL);
String key;
csStr->ToString(&key);
if (message.Contains(key)) {
List< AutoPtr<IInterface> >::Iterator tmpIt = it;
AutoPtr<IInterface> obj = *(++tmpIt);
AutoPtr<UEventObserver> observer = (UEventObserver*)IObject::Probe(obj);
mTempObserversToSignal.PushBack(observer);
}
++it;
++it;
}
}
if (!mTempObserversToSignal.IsEmpty()) {
AutoPtr<UEvent> event = new UEvent(message);
List< AutoPtr<UEventObserver> >::Iterator it;
for (it = mTempObserversToSignal.Begin(); it != mTempObserversToSignal.End(); ++it) {
AutoPtr<UEventObserver> observer = *it;
observer->OnUEvent(event);
}
mTempObserversToSignal.Clear();
}
}
示例10: Error
FileFormat::FileFormat( const String& nameExtOrMime, bool toRead, bool toWrite ) :
FileFormatBase()
{
if ( nameExtOrMime.IsEmpty() )
throw Error( "FileFormat: Empty format name, file extension or MIME type specified" );
m_data = new FileFormatPrivate;
if ( nameExtOrMime.Contains( '/' ) )
{
IsoString mimeType( nameExtOrMime );
m_data->handle = (*API->FileFormat->GetFileFormatByMimeType)( ModuleHandle(), mimeType.c_str(), toRead, toWrite );
if ( m_data->handle == nullptr )
throw Error( "FileFormat: No installed image file format was found "
"for the specified MIME type \'" + nameExtOrMime + "\' and access conditions" );
}
else if ( nameExtOrMime.StartsWith( '.' ) )
{
m_data->handle = (*API->FileFormat->GetFileFormatByFileExtension)( ModuleHandle(), nameExtOrMime.c_str(), toRead, toWrite );
if ( m_data->handle == nullptr )
throw Error( "FileFormat: No installed image file format was found "
"for the specified file extension \'" + nameExtOrMime + "\'and access conditions" );
}
else
{
IsoString id( nameExtOrMime );
m_data->handle = (*API->FileFormat->GetFileFormatByName)( ModuleHandle(), id.c_str() );
if ( m_data->handle == nullptr )
throw Error( "FileFormat: No installed image file format was found "
"with the specified identifier \'" + nameExtOrMime + '\'' );
}
m_data->GetCapabilities();
}
示例11: EndCutscene
void Script::EndCutscene(bool endingPrematurely /*= false*/)
{
// Make sure we're in a cutscene first..
if (!inCutscene)
return;
if (endingPrematurely)
{
// Jump to the end of the cutscene.
for (int i = currentLine; i < lines.Size(); ++i)
{
// Look for the end.
String line = lines[i];
if (line.Contains("End(Cutscene)"))
{
// Jump to it.
currentLine = i;
// Stop doing whatever we were doing too.
lineFinished = true;
break;
}
}
}
// End all sub-scripts too!
for (int i = 0; i < childScripts.Size(); ++i)
{
Script * script = childScripts[i];
script->QueueEnd();
}
inCutscene = false;
}
示例12: Load
bool Project::Load(const String& fullpath)
{
loading_ = true;
if (fullpath.Contains(".atomic")) {
projectPath_ = AddTrailingSlash(GetPath(fullpath));
projectFilePath_ = fullpath;
}
else
{
projectPath_ = AddTrailingSlash(fullpath);
projectFilePath_ = projectPath_ + GetFileName(RemoveTrailingSlash(projectPath_)) + ".atomic";
}
SharedPtr<ProjectFile> pfile(new ProjectFile(context_));
bool result = pfile->Load(this);
loading_ = false;
LoadBuildSettings();
LoadUserPrefs();
if ( true /*result*/) {
VariantMap data;
data[ProjectLoaded::P_PROJECTPATH] = projectFilePath_;
SendEvent(E_PROJECTLOADED, data);
}
return result;
}
示例13:
void
POP3ClientConnection::ParseStateCAPASent_(const String &sData)
{
if (!CommandIsSuccessfull_(sData) || !sData.Contains(_T("STLS")))
{
// STLS is not supported.
if (GetConnectionSecurity() == CSSTARTTLSRequired)
{
String message =
Formatter::Format("The download of messages from external account {0} failed. The external aAccount is configured to use STARTTLS connection security, but the POP3 server does not support it.", account_->GetName());
LOG_APPLICATION(message)
QuitNow_();
return;
}
else
{
SendUserName_();
return;
}
}
EnqueueWrite_("STLS");
current_state_ = StateSTLSSent;
}
示例14: GetNativeFunctionSignature
String CSTypeHelper::GetNativeFunctionSignature(JSBFunction* function, String& returnType)
{
if (function->Skip())
return String::EMPTY;
if (function->IsDestructor())
return String::EMPTY;
if (OmitFunction(function))
return String::EMPTY;
JSBClass* klass = function->GetClass();
JSBPackage* package = klass->GetPackage();
String fname = function->IsConstructor() ? "Constructor" : function->GetName();
returnType = "void";
if (function->IsConstructor())
{
returnType = "RefCounted*";
}
else if (function->GetReturnType())
{
if (function->IsConstructor())
{
returnType = ToString("%s*", klass->GetNativeName().CString());
}
else if (function->GetReturnClass())
{
if (!function->GetReturnClass()->IsNumberArray())
{
returnType = ToString("const %s*", function->GetReturnClass()->GetNativeName().CString());
}
}
else if (function->GetReturnType()->type_->asStringHashType())
{
returnType = "unsigned";
}
else
{
returnType = ToString("%s", CSTypeHelper::GetNativeTypeString(function->GetReturnType()).CString());
// ScriptVector is handled by a out parameter
if (returnType.Contains("ScriptVector"))
returnType = "void";
}
}
String sig;
GenNativeFunctionParameterSignature(function, sig);
String functionSig = ToString("csb_%s_%s_%s_%u(%s)",
package->GetName().CString(), klass->GetName().CString(),
fname.CString(), function->GetID(), sig.CString());
return functionSig;
}
示例15: strStartwith
ECode CTestBasicType::strStartwith(
/* [in] */ String i,
/* [in] */ String j,
/* [out] */ Boolean * pO)
{
*pO = i.Contains(j);
return NOERROR;
}