本文整理汇总了C++中String::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Empty方法的具体用法?C++ String::Empty怎么用?C++ String::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakePair
SharedPtr<Technique> Technique::CloneWithDefines(const String& vsDefines, const String& psDefines)
{
// Return self if no actual defines
if (vsDefines.Empty() && psDefines.Empty())
return SharedPtr<Technique>(this);
Pair<StringHash, StringHash> key = MakePair(StringHash(vsDefines), StringHash(psDefines));
// Return existing if possible
HashMap<Pair<StringHash, StringHash>, SharedPtr<Technique> >::Iterator i = cloneTechniques_.Find(key);
if (i != cloneTechniques_.End())
return i->second_;
// Set same name as the original for the clones to ensure proper serialization of the material. This should not be a problem
// since the clones are never stored to the resource cache
i = cloneTechniques_.Insert(MakePair(key, Clone(GetName())));
for (Vector<SharedPtr<Pass> >::ConstIterator j = i->second_->passes_.Begin(); j != i->second_->passes_.End(); ++j)
{
Pass* pass = (*j);
if (!pass)
continue;
if (!vsDefines.Empty())
pass->SetVertexShaderDefines(pass->GetVertexShaderDefines() + " " + vsDefines);
if (!psDefines.Empty())
pass->SetPixelShaderDefines(pass->GetPixelShaderDefines() + " " + psDefines);
}
return i->second_;
}
示例2: CreateDirectory
bool CreateDirectory ( String dir )
{
if ( dir.Empty() )
return true;
int max = 0;
String *dirs = dir.FindReplace ( "/", "\\" ).FindReplace ( "\\\\", "\\" ).SplitToken ( '\\', &max );
int start = 1;
String curDir = dirs[0];
// if ( !curDir.IsIn(":\\") )
// {
curDir = "";
start = 0;
// }
for ( int i = start; i < max; i++ )
{
if ( !curDir.Empty() )
curDir += "\\";
curDir += dirs[i];
#ifdef _WIN32
CreateDirectory ( curDir.c_str(), 0 );
#else
String newDir = curDir;
newDir = newDir.FindReplace ( "\\", "/" );
mkdir(newDir.c_str(), 0755);
#endif
}
return true;
}
示例3: Object
MessageBox::MessageBox(Context* context, const String& messageString, const String& titleString, XMLFile* layoutFile, XMLFile* styleFile) :
Object(context),
titleText_(0),
messageText_(0),
okButton_(0)
{
// If layout file is not given, use the default message box layout
if (!layoutFile)
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
layoutFile = cache->GetResource<XMLFile>("UI/MessageBox.xml");
if (!layoutFile) // Error is already logged
return; // Note: windowless MessageBox should not be used!
}
UI* ui = GetSubsystem<UI>();
window_ = ui->LoadLayout(layoutFile, styleFile);
ui->GetRoot()->AddChild(window_);
// Set the title and message strings if they are given
titleText_ = dynamic_cast<Text*>(window_->GetChild("TitleText", true));
if (titleText_ && !titleString.Empty())
titleText_->SetText(titleString);
messageText_ = dynamic_cast<Text*>(window_->GetChild("MessageText", true));
if (messageText_ && !messageString.Empty())
messageText_->SetText(messageString);
// Center window after the message is set
Window* window = dynamic_cast<Window*>(window_.Get());
if (window)
{
Graphics* graphics = GetSubsystem<Graphics>(); // May be null if headless
if (graphics)
{
const IntVector2& size = window->GetSize();
window->SetPosition((graphics->GetWidth() - size.x_) / 2, (graphics->GetHeight() - size.y_) / 2);
}
else
LOGWARNING("Instantiating a modal window in headless mode!");
window->SetModal(true);
SubscribeToEvent(window, E_MODALCHANGED, HANDLER(MessageBox, HandleMessageAcknowledged));
}
// Bind the buttons (if any in the loaded UI layout) to event handlers
okButton_ = dynamic_cast<Button*>(window_->GetChild("OkButton", true));
if (okButton_)
{
ui->SetFocusElement(okButton_);
SubscribeToEvent(okButton_, E_RELEASED, HANDLER(MessageBox, HandleMessageAcknowledged));
}
Button* cancelButton = dynamic_cast<Button*>(window_->GetChild("CancelButton", true));
if (cancelButton)
SubscribeToEvent(cancelButton, E_RELEASED, HANDLER(MessageBox, HandleMessageAcknowledged));
Button* closeButton = dynamic_cast<Button*>(window_->GetChild("CloseButton", true));
if (closeButton)
SubscribeToEvent(closeButton, E_RELEASED, HANDLER(MessageBox, HandleMessageAcknowledged));
}
示例4: ElementStart
Element* XMLNodeHandlerHead::ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes)
{
if (name == "head")
{
// Process the head attribute
parser->GetDocumentHeader()->source = parser->GetSourceURL().GetURL();
}
// Is it a link tag?
else if (name == "link")
{
// Lookup the type and href
String type = attributes.Get<String>("type", "").ToLower();
String href = attributes.Get<String>("href", "");
if (!type.Empty() && !href.Empty())
{
// If its RCSS (... or CSS!), add to the RCSS fields.
if (type == "text/rcss" ||
type == "text/css")
{
parser->GetDocumentHeader()->rcss_external.push_back(href);
}
// If its an template, add to the template fields
else if (type == "text/template")
{
parser->GetDocumentHeader()->template_resources.push_back(href);
}
else
{
Log::ParseError(parser->GetSourceURL().GetURL(), parser->GetLineNumber(), "Invalid link type '%s'", type.CString());
}
}
else
{
Log::ParseError(parser->GetSourceURL().GetURL(), parser->GetLineNumber(), "Link tag requires type and href attributes");
}
}
// Process script tags
else if (name == "script")
{
// Check if its an external string
String src = attributes.Get<String>("src", "");
if (src.Length() > 0)
{
parser->GetDocumentHeader()->scripts_external.push_back(src);
}
}
// No elements constructed
return NULL;
}
示例5: UncompressToFile
bool CFile::UncompressToFile ( String toFile, CBaseFile *spkfile, bool includedir, CProgressInfo *progress )
{
#ifdef _WIN32
if ( (!m_sData) || (!m_lDataSize) )
return false;
// if theres a tmp file, open it and check it still exists
if ( !m_sTmpFile.Empty() )
{
FILE *id = fopen ( m_sTmpFile.c_str(), "rb" );
if ( id )
{
fclose ( id );
return true;
}
m_sTmpFile = "";
}
// now uncompress to the file
String file = toFile;
if ( file.Empty() )
{
m_iTempNum++;
file = String("uncompr") + (long)m_iTempNum + ".tmp";
}
else
file = GetFullFileToDir ( file, includedir, spkfile );
FILE *id = fopen ( "compr.tmp", "wb" );
if ( !id )
return false;
fwrite ( m_sData, sizeof(unsigned char), m_lDataSize, id );
bool ret = false;
int err = ferror(id);
fclose ( id );
if ( !err )
{
if ( LZMADecodeFile ( "compr.tmp", file.c_str(), (CProgressInfo7Zip *)progress ) )
{
ret = true;
if ( toFile.Empty() )
m_sTmpFile = file;
}
}
remove ( "compr.tmp" );
return ret;
#else
return false;
#endif
}
示例6: if
std::vector<String>
IMAPFetchParser::_ParseString(String &sString)
{
std::vector<String> vecResult;
_CleanFetchString(sString);
while (!sString.IsEmpty())
{
long lFirstLeftBracket = sString.Find(_T("["));
long lFirstSpace = sString.Find(_T(" "));
if (lFirstLeftBracket >= 0 && lFirstLeftBracket < lFirstSpace)
{
// Find end bracket.
long lFirstRightBracket = sString.Find(_T("]"), lFirstLeftBracket);
// Check if we got a <> directly after the []
if (sString.SafeGetAt(lFirstRightBracket + 1) == '<')
lFirstRightBracket = sString.Find(_T(">"), lFirstRightBracket);
// Parse out string between brackets.
if (lFirstRightBracket <= 0)
{
sString = sString.Mid(lFirstRightBracket + 1);
continue;
}
// String between brackets.
String sResString = sString.Mid(0, lFirstRightBracket+1 );
vecResult.push_back(sResString);
// Cut away this from the start string.
sString = sString.Mid(lFirstRightBracket + 1);
}
else if (lFirstSpace >= 0)
{
// Copy string from here to end.
String sResString = sString.Mid(0, lFirstSpace );
vecResult.push_back(sResString);
sString = sString.Mid(lFirstSpace + 1);
}
else
{
vecResult.push_back(sString);
sString.Empty();
}
_CleanFetchString(sString);
}
return vecResult;
}
示例7:
void
StringParser::Base64Decode(const String &sInput, String &sOutput)
{
if (sInput.GetLength() == 0)
{
sOutput.Empty();
return;
}
AnsiString sInputStr = sInput;
MimeCodeBase64 DeCoder;
DeCoder.AddLineBreak(false);
DeCoder.SetInput(sInputStr, sInputStr.GetLength(), false);
AnsiString output;
DeCoder.GetOutput(output);
int length = output.GetLength();
// Since we're going to store the result in
// a normal StdString, we can't return null
// characters.
for (int i = 0; i < length; i++)
{
if (output[i] == 0)
output[i] = '\t';
}
sOutput = output;
}
示例8: RegisterPath
void FileSystem::RegisterPath(const String& pathName)
{
if (pathName.Empty())
return;
allowedPaths_.Insert(AddTrailingSlash(pathName));
}
示例9: SystemOpen
bool FileSystem::SystemOpen(const String& fileName, const String& mode)
{
if (allowedPaths_.Empty())
{
if (!FileExists(fileName) && !DirExists(fileName))
{
LOGERROR("File or directory " + fileName + " not found");
return false;
}
#ifdef WIN32
bool success = (size_t)ShellExecuteW(0, !mode.Empty() ? WString(mode).CString() : 0,
GetWideNativePath(fileName).CString(), 0, 0, SW_SHOW) > 32;
#else
Vector<String> arguments;
arguments.Push(fileName);
bool success = SystemRun(
#if defined(__APPLE__)
"/usr/bin/open",
#else
"/usr/bin/xdg-open",
#endif
arguments) == 0;
#endif
if (!success)
LOGERROR("Failed to open " + fileName + " externally");
return success;
}
else
{
LOGERROR("Opening a file externally is not allowed");
return false;
}
}
示例10: LoadRawFile
bool LuaScript::LoadRawFile(const String& fileName)
{
PROFILE(LoadRawFile);
LOGINFO("Finding Lua file on file system: " + fileName);
ResourceCache* cache = GetSubsystem<ResourceCache>();
String filePath = cache->GetResourceFileName(fileName);
if (filePath.Empty())
{
LOGINFO("Lua file not found: " + fileName);
return false;
}
filePath = GetNativePath(filePath);
LOGINFO("Loading Lua file from file system: " + filePath);
if (luaL_loadfile(luaState_, filePath.CString()))
{
const char* message = lua_tostring(luaState_, -1);
LOGERRORF("Load Lua file failed: %s", message);
lua_pop(luaState_, 1);
return false;
}
LOGINFO("Lua file loaded: " + filePath);
return true;
}
示例11: HandleTextFinished
void Console::HandleTextFinished(StringHash eventType, VariantMap& eventData)
{
using namespace TextFinished;
String line = lineEdit_->GetText();
if (!line.Empty())
{
// Send the command as an event for script subsystem
using namespace ConsoleCommand;
SendEvent(E_CONSOLECOMMAND,
P_COMMAND, line,
P_ID, static_cast<Text*>(interpreters_->GetSelectedItem())->GetText());
// Make sure the line isn't the same as the last one
if (history_.Empty() || line != history_.Back())
{
// Store to history, then clear the lineedit
history_.Push(line);
if (history_.Size() > historyRows_)
history_.Erase(history_.Begin());
}
historyPosition_ = history_.Size(); // Reset
autoCompletePosition_ = autoComplete_.Size(); // Reset
currentRow_.Clear();
lineEdit_->SetText(currentRow_);
}
}
示例12: Load
bool ScriptFile::Load(Deserializer& source)
{
PROFILE(LoadScript);
ReleaseModule();
// Create the module. Discard previous module if there was one
asIScriptEngine* engine = script_->GetScriptEngine();
scriptModule_ = engine->GetModule(GetName().CString(), asGM_ALWAYS_CREATE);
if (!scriptModule_)
{
LOGERROR("Failed to create script module " + GetName());
return false;
}
// Check if this file is precompiled bytecode
if (source.ReadFileID() == "ASBC")
{
ByteCodeDeserializer deserializer = ByteCodeDeserializer(source);
if (scriptModule_->LoadByteCode(&deserializer) >= 0)
{
LOGINFO("Loaded script module " + GetName() + " from bytecode");
compiled_ = true;
// Map script module to script resource with userdata
scriptModule_->SetUserData(this);
return true;
}
else
return false;
}
else
source.Seek(0);
// Not bytecode: add the initial section and check for includes
if (!AddScriptSection(engine, source))
return false;
// Compile. Set script engine logging to retained mode so that potential exceptions can show all error info
ScriptLogMode oldLogMode = script_->GetLogMode();
script_->SetLogMode(LOGMODE_RETAINED);
script_->ClearLogMessages();
int result = scriptModule_->Build();
String errors = script_->GetLogMessages();
script_->SetLogMode(oldLogMode);
if (result < 0)
{
LOGERROR("Failed to compile script module " + GetName() + ":\n" + errors);
return false;
}
if (!errors.Empty())
LOGWARNING(errors);
LOGINFO("Compiled script module " + GetName());
compiled_ = true;
// Map script module to script resource with userdata
scriptModule_->SetUserData(this);
return true;
}
示例13: LoadTexture
bool ElementImage::LoadTexture()
{
// Get the source URL for the image.
String source = GetAttribute< String >("src", "");
bool nocache = GetAttribute< int >("nocache", 0) != 0;
SetPseudoClass( "loading", true );
if( !source.Empty() ) {
if( trap::FS_IsUrl( source.CString() ) ) {
texture_dirty = false;
// the stream cache object references this element
// (passed as the void * pointer below)
AddReference();
UI_Main::Get()->getStreamCache()->PerformRequest(
source.CString(), "GET", NULL,
NULL, NULL, &CacheRead, (void *)this,
WSW_UI_STREAMCACHE_TIMEOUT, nocache ? 0 : WSW_UI_IMAGES_CACHE_TTL
);
return false;
}
}
bool res = LoadDiskTexture();
SetPseudoClass( "loading", false );
return res;
}
示例14: HandleTextFinished
void Console::HandleTextFinished(StringHash eventType, VariantMap& eventData)
{
using namespace TextFinished;
String line = lineEdit_->GetText();
if (!line.Empty())
{
// Send the command as an event for script subsystem
using namespace ConsoleCommand;
VariantMap& eventData = GetEventDataMap();
eventData[P_COMMAND] = line;
eventData[P_ID] = static_cast<Text*>(interpreters_->GetSelectedItem())->GetText();
SendEvent(E_CONSOLECOMMAND, eventData);
// Store to history, then clear the lineedit
history_.Push(line);
if (history_.Size() > historyRows_)
history_.Erase(history_.Begin());
historyPosition_ = history_.Size();
currentRow_.Clear();
lineEdit_->SetText(currentRow_);
}
}
示例15: GetNameDirectory
String CFile::GetNameDirectory ( CBaseFile *file )
{
String dir = GetDirectory( file );
if ( !dir.Empty() )
dir += "/";
return String(dir + m_sName).FindReplace ( "\\", "/" );
}