本文整理汇总了C++中AString::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::empty方法的具体用法?C++ AString::empty怎么用?C++ AString::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault)
{
AString BiomeGenName = a_IniFile.GetValueSet("Generator", "BiomeGen", "");
if (BiomeGenName.empty())
{
LOGWARN("[Generator] BiomeGen value not set in world.ini, using \"MultiStepMap\".");
BiomeGenName = "MultiStepMap";
}
cBiomeGen * res = NULL;
a_CacheOffByDefault = false;
if (NoCaseCompare(BiomeGenName, "constant") == 0)
{
res = new cBioGenConstant;
a_CacheOffByDefault = true; // we're generating faster than a cache would retrieve data :)
}
else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0)
{
res = new cBioGenCheckerboard;
a_CacheOffByDefault = true; // we're (probably) generating faster than a cache would retrieve data
}
else if (NoCaseCompare(BiomeGenName, "voronoi") == 0)
{
res = new cBioGenVoronoi(a_Seed);
}
else if (NoCaseCompare(BiomeGenName, "distortedvoronoi") == 0)
{
res = new cBioGenDistortedVoronoi(a_Seed);
}
else if (NoCaseCompare(BiomeGenName, "twolevel") == 0)
{
res = new cBioGenTwoLevel(a_Seed);
}
else
{
if (NoCaseCompare(BiomeGenName, "multistepmap") != 0)
{
LOGWARNING("Unknown BiomeGen \"%s\", using \"MultiStepMap\" instead.", BiomeGenName.c_str());
}
res = new cBioGenMultiStepMap(a_Seed);
/*
// Performance-testing:
LOGINFO("Measuring performance of cBioGenMultiStepMap...");
clock_t BeginTick = clock();
for (int x = 0; x < 5000; x++)
{
cChunkDef::BiomeMap Biomes;
res->GenBiomes(x * 5, x * 5, Biomes);
}
clock_t Duration = clock() - BeginTick;
LOGINFO("cBioGenMultiStepMap for 5000 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
//*/
}
res->InitializeBiomeGen(a_IniFile);
return res;
}
示例2:
Air::U1 Converter::SplitFilePath( const AString& str, AString* strPath /*= NULL*/, AString* strFileName /*= NULL*/, AString* strExe /*= NULL*/ )
{
if(str.empty())
return false;
U32 uiStrSize = str.size();
S32 uiPoint = uiStrSize;
S32 uiSlash = -1;
for(S32 i=uiStrSize-1;i>-1;i--){
if(str[i] == '.' && uiPoint == uiStrSize){
uiPoint = i;
}
if( str[i] == '/' ||
str[i] == '\\'){
uiSlash = i;
break;
}
}
if( uiPoint != uiStrSize &&
strExe != NULL)
{
if(uiPoint!=uiStrSize-1)
*strExe = &str[uiPoint+1];
}
if( uiSlash != -1 &&
strPath != NULL)
{
if(uiSlash<uiStrSize){
strPath->resize(uiSlash+1);
memcpy(&((*strPath)[0]),&str[0],uiSlash+1);
}else{
*strPath = str;
}
}
if(strFileName!=NULL){
U32 uiFileNameSize = uiPoint;
U32 uiFileNameStart = 0;
if(uiPoint==uiStrSize)
uiFileNameSize--;
if(uiSlash<uiStrSize){
if(uiSlash!=-1){
uiFileNameSize -= uiSlash+1;
uiFileNameStart = uiSlash+1;
}
strFileName->resize(uiFileNameSize);
memcpy(&((*strFileName)[0]),&str[uiFileNameStart],uiFileNameSize);
}
}
return true;
}
示例3: receiveRTSPRequest
bool ARTSPConnection::receiveRTSPRequest() {
AString requestLine;
LOGI(LOG_TAG,"start receiveLine ......\n");
if (!receiveLine(&requestLine)) {
return false;
}
// LOGI(LOG_TAG,"receiveLine OK\n");
sp<AMessage> request = new AMessage(kWhatRequest,mhandlerID);
request->setInt32("SessionID",mSessionID);
LOGI(LOG_TAG,"request->setInt32 SessionID %d\n",mSessionID);
LOGI(LOG_TAG,"request: %s\n", requestLine.c_str());
ssize_t space1 = requestLine.find(" ");//寻找空格
if (space1 < 0) {
return false;
}
ssize_t space2 = requestLine.find(" ", space1 + 1);
if (space2 < 0) {
return false;
}
AString Method(requestLine.c_str(), space1);
request->setString("Method",Method.c_str());
AString URI(requestLine,space1+1,space2-space1-1);
request->setString("URI",URI.c_str());
AString line;
for (;;) {
if (!receiveLine(&line)) {
break;
}
if (line.empty()) {
break;
}
ssize_t colonPos = line.find(":");
if (colonPos < 0) {
// Malformed header line.
return false;
}
AString key(line, 0, colonPos);
key.trim();
// key.tolower();
line.erase(0, colonPos + 1);
line.trim();
LOGI(LOG_TAG,"line: %s:%s\n", key.c_str(),line.c_str());
request->setString(key.c_str(),line.c_str());
}
LOGI(LOG_TAG,"Post the request to handler\n");
request->post();//将请求消息发送给uplayer 处理
return OK;
}
示例4: ReloadPluginsNow
void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
{
LOG("-- Loading Plugins --");
m_bReloadPlugins = false;
UnloadPluginsNow();
FindPlugins();
cServer::BindBuiltInConsoleCommands();
// Check if the Plugins section exists.
int KeyNum = a_SettingsIni.FindKey("Plugins");
// If it does, how many plugins are there?
int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
if (KeyNum == -1)
{
InsertDefaultPlugins(a_SettingsIni);
}
else if (NumPlugins > 0)
{
for (int i = 0; i < NumPlugins; i++)
{
AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
if (ValueName.compare("Plugin") == 0)
{
AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
if (!PluginFile.empty())
{
if (m_Plugins.find(PluginFile) != m_Plugins.end())
{
LoadPlugin(PluginFile);
}
}
}
}
}
size_t NumLoadedPlugins = GetNumPlugins();
if (NumLoadedPlugins == 0)
{
LOG("-- No Plugins Loaded --");
}
else if (NumLoadedPlugins > 1)
{
LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
}
else
{
LOG("-- Loaded 1 Plugin --");
}
CallHookPluginsLoaded();
}
示例5: ReloadRecipes
void cFurnaceRecipe::ReloadRecipes(void)
{
ClearRecipes();
LOGD("Loading furnace recipes...");
std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in);
if (!f.good())
{
LOG("Could not open the furnace recipes file \"%s\". No furnace recipes are available.", FURNACE_RECIPE_FILE);
return;
}
unsigned int LineNum = 0;
AString ParsingLine;
while (std::getline(f, ParsingLine))
{
LineNum++;
if (ParsingLine.empty())
{
continue;
}
// Remove comments from the line:
size_t FirstCommentSymbol = ParsingLine.find('#');
if ((FirstCommentSymbol != AString::npos) && (FirstCommentSymbol != 0))
{
ParsingLine.erase(ParsingLine.begin() + static_cast<const long>(FirstCommentSymbol), ParsingLine.end());
}
switch (ParsingLine[0])
{
case '#':
{
// Comment
break;
}
case '!':
{
AddFuelFromLine(ParsingLine, LineNum);
break;
}
default:
{
AddRecipeFromLine(ParsingLine, LineNum);
break;
}
} // switch (ParsingLine[0])
} // while (getline(ParsingLine))
LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
}
示例6: GetMetadata
void cPrefabPiecePool::ApplyBaseMetadataCubesetVer1(
const AString & a_FileName,
bool a_LogWarnings
)
{
// Set the metadata values to defaults:
m_MinDensity = 100;
m_MaxDensity = 100;
m_VillageRoadBlockType = E_BLOCK_GRAVEL;
m_VillageRoadBlockMeta = 0;
m_VillageWaterRoadBlockType = E_BLOCK_PLANKS;
m_VillageWaterRoadBlockMeta = 0;
// Read the metadata values:
m_IntendedUse = GetMetadata("IntendedUse");
GetStringMapInteger(m_Metadata, "MaxDensity", m_MaxDensity);
GetStringMapInteger(m_Metadata, "MinDensity", m_MinDensity);
GetStringMapInteger(m_Metadata, "VillageRoadBlockType", m_VillageRoadBlockType);
GetStringMapInteger(m_Metadata, "VillageRoadBlockMeta", m_VillageRoadBlockMeta);
GetStringMapInteger(m_Metadata, "VillageWaterRoadBlockType", m_VillageWaterRoadBlockType);
GetStringMapInteger(m_Metadata, "VillageWaterRoadBlockMeta", m_VillageWaterRoadBlockMeta);
// Read the allowed biomes:
AString allowedBiomes = GetMetadata("AllowedBiomes");
if (allowedBiomes.empty())
{
// All biomes are allowed:
for (int b = biFirstBiome; b <= biMaxBiome; b++)
{
m_AllowedBiomes.insert(static_cast<EMCSBiome>(b));
}
for (int b = biFirstVariantBiome; b <= biMaxVariantBiome; b++)
{
m_AllowedBiomes.insert(static_cast<EMCSBiome>(b));
}
}
else
{
auto biomes = StringSplitAndTrim(allowedBiomes, ",");
for (const auto & biome: biomes)
{
EMCSBiome b = StringToBiome(biome);
if (b == biInvalidBiome)
{
CONDWARNING(a_LogWarnings, "Invalid biome (\"%s\") specified in AllowedBiomes in cubeset file %s. Skipping the biome.",
biome.c_str(), a_FileName.c_str()
);
continue;
}
m_AllowedBiomes.insert(b);
}
}
}
示例7: Command
virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override
{
if (!a_HelpString.empty())
{
m_Commands.push_back(AStringPair(a_Command, a_HelpString));
if (m_MaxLen < a_Command.length())
{
m_MaxLen = a_Command.length();
}
}
return false;
}
示例8: HandleCommand
cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
{
AStringVector Split(StringSplit(a_Command, " "));
if (Split.empty())
{
return crUnknownCommand;
}
CommandMap::iterator cmd = m_Commands.find(Split[0]);
if (cmd == m_Commands.end())
{
// Command not found
// If it started with a slash, ask the plugins if they still want to handle it:
if (!a_Command.empty() && (a_Command[0] == '/'))
{
CommandResult Result = crUnknownCommand;
CallHookExecuteCommand(&a_Player, Split, a_Command, Result);
return Result;
}
return crUnknownCommand;
}
// Ask plugins first if a command is okay to execute the command:
CommandResult Result = crBlocked;
if (CallHookExecuteCommand(&a_Player, Split, a_Command, Result))
{
if (Result == crBlocked)
{
LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player.GetName().c_str(), Split[0].c_str());
}
return Result;
}
if (
a_ShouldCheckPermissions &&
!cmd->second.m_Permission.empty() &&
!a_Player.HasPermission(cmd->second.m_Permission)
)
{
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player.GetName().c_str(), Split[0].c_str());
return crNoPermission;
}
ASSERT(cmd->second.m_Handler != nullptr);
if (!cmd->second.m_Handler->ExecuteCommand(Split, &a_Player, a_Command, nullptr))
{
return crError;
}
return crExecuted;
}
示例9: Load
bool cStatSerializer::Load(void)
{
AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path);
if (Data.empty())
{
Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_LegacyPath);
if (Data.empty())
{
return false;
}
}
Json::Value Root;
Json::Reader Reader;
if (Reader.parse(Data, Root, false))
{
return LoadStatFromJSON(Root);
}
return false;
}
示例10: Initialize
bool cHTTPServer::Initialize(void)
{
// Read the HTTPS cert + key:
AString CertFile = cFile::ReadWholeFile("webadmin/httpscert.crt");
AString KeyFile = cFile::ReadWholeFile("webadmin/httpskey.pem");
if (!CertFile.empty() && !KeyFile.empty())
{
m_Cert.reset(new cX509Cert);
int res = m_Cert->Parse(CertFile.data(), CertFile.size());
if (res == 0)
{
m_CertPrivKey.reset(new cCryptoKey);
int res2 = m_CertPrivKey->ParsePrivate(KeyFile.data(), KeyFile.size(), "");
if (res2 != 0)
{
// Reading the private key failed, reset the cert:
LOGWARNING("WebServer: Cannot read HTTPS certificate private key: -0x%x", -res2);
m_Cert.reset();
}
}
else
{
LOGWARNING("WebServer: Cannot read HTTPS certificate: -0x%x", -res);
}
}
// Notify the admin about the HTTPS / HTTP status
if (m_Cert.get() == nullptr)
{
LOGWARNING("WebServer: The server will run in unsecured HTTP mode.");
LOGINFO("Put a valid HTTPS certificate in file 'webadmin/httpscert.crt' and its corresponding private key to 'webadmin/httpskey.pem' (without any password) to enable HTTPS support");
}
else
{
LOGINFO("WebServer: The server will run in secure HTTPS mode.");
}
return true;
}
示例11: ReloadPluginsNow
void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
{
LOG("-- Loading Plugins --");
m_bReloadPlugins = false;
UnloadPluginsNow();
FindPlugins();
cServer::BindBuiltInConsoleCommands();
unsigned int KeyNum = a_SettingsIni.FindKey("Plugins");
unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
if (KeyNum == -1)
{
InsertDefaultPlugins(a_SettingsIni);
}
else if (NumPlugins > 0)
{
for(unsigned int i = 0; i < NumPlugins; i++)
{
AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
if (ValueName.compare("Plugin") == 0)
{
AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
if (!PluginFile.empty())
{
if (m_Plugins.find(PluginFile) != m_Plugins.end())
{
LoadPlugin( PluginFile );
}
}
}
}
}
if (GetNumPlugins() == 0)
{
LOG("-- No Plugins Loaded --");
}
else if (GetNumPlugins() > 1)
{
LOG("-- Loaded %i Plugins --", GetNumPlugins());
}
else
{
LOG("-- Loaded 1 Plugin --");
}
}
示例12: GetOSErrorString
AString GetOSErrorString( int a_ErrNo)
{
char buffer[ 1024 ];
AString Out;
#ifdef _WIN32
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, a_ErrNo, 0, buffer, ARRAYCOUNT(buffer), NULL);
Printf(Out, "%d: %s", a_ErrNo, buffer);
if (!Out.empty() && (Out[Out.length() - 1] == '\n'))
{
Out.erase(Out.length() - 2);
}
return Out;
#else // _WIN32
// According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r():
#if !defined(__APPLE__) && ( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r()
char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
if (res != NULL)
{
Printf(Out, "%d: %s", a_ErrNo, res);
return Out;
}
#else // XSI version of strerror_r():
int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
if (res == 0)
{
Printf(Out, "%d: %s", a_ErrNo, buffer);
return Out;
}
#endif // strerror_r() version
else
{
Printf(Out, "Error %d while getting error string for error #%d!", errno, a_ErrNo);
return Out;
}
#endif // else _WIN32
}
示例13: ParsePrivate
int cCryptoKey::ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password)
{
ASSERT(!IsValid()); // Cannot parse a second key
if (a_Password.empty())
{
return pk_parse_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes, NULL, 0);
}
else
{
return pk_parse_key(
&m_Pk,
(const unsigned char *)a_Data, a_NumBytes,
(const unsigned char *)a_Password.c_str(), a_Password.size()
);
}
}
示例14: AddStyle
void cCompositeChat::AddStyle(AString & a_Style, const AString & a_AddStyle)
{
if (a_AddStyle.empty())
{
return;
}
if (a_AddStyle[0] == '@')
{
size_t idx = a_Style.find('@');
if ((idx != AString::npos) && (idx != a_Style.length()))
{
a_Style.erase(idx, 2);
}
a_Style.append(a_AddStyle);
return;
}
a_Style.append(a_AddStyle);
}
示例15: SaveToSchematicString
bool cSchematicFileSerializer::SaveToSchematicString(const cBlockArea & a_BlockArea, AString & a_Out)
{
// Serialize into NBT data:
AString NBT = SaveToSchematicNBT(a_BlockArea);
if (NBT.empty())
{
LOG("%s: Cannot serialize the area into an NBT representation.", __FUNCTION__);
return false;
}
// Gzip the data:
int res = CompressStringGZIP(NBT.data(), NBT.size(), a_Out);
if (res != Z_OK)
{
LOG("%s: Cannot Gzip the area data NBT representation: %d", __FUNCTION__, res);
return false;
}
return true;
}