本文整理汇总了C++中AStringVector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ AStringVector::begin方法的具体用法?C++ AStringVector::begin怎么用?C++ AStringVector::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStringVector
的用法示例。
在下文中一共展示了AStringVector::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetUUIDsFromPlayerNames
AStringVector cMojangAPI::GetUUIDsFromPlayerNames(const AStringVector & a_PlayerNames, bool a_UseOnlyCached)
{
// Convert all playernames to lowercase:
AStringVector PlayerNames;
for (AStringVector::const_iterator itr = a_PlayerNames.begin(), end = a_PlayerNames.end(); itr != end; ++itr)
{
PlayerNames.push_back(StrToLower(*itr));
} // for itr - a_PlayerNames[]
// Request the cache to populate any names not yet contained:
if (!a_UseOnlyCached)
{
CacheNamesToUUIDs(PlayerNames);
}
// Retrieve from cache:
size_t idx = 0;
AStringVector res;
res.resize(PlayerNames.size());
cCSLock Lock(m_CSNameToUUID);
for (AStringVector::const_iterator itr = PlayerNames.begin(), end = PlayerNames.end(); itr != end; ++itr, ++idx)
{
cProfileMap::const_iterator itrN = m_NameToUUID.find(*itr);
if (itrN != m_NameToUUID.end())
{
res[idx] = itrN->second.m_UUID;
}
} // for itr - PlayerNames[]
return res;
}
示例2: LoadPermissionsFromDisk
void cPlayer::LoadPermissionsFromDisk()
{
m_Groups.clear();
m_Permissions.clear();
cIniFile IniFile;
if (IniFile.ReadFile("users.ini"))
{
AString Groups = IniFile.GetValueSet(GetName(), "Groups", "Default");
AStringVector Split = StringSplitAndTrim(Groups, ",");
for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
{
if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr))
{
LOGWARNING("The group %s for player %s was not found!", itr->c_str(), GetName().c_str());
}
AddToGroup(*itr);
}
AString Color = IniFile.GetValue(GetName(), "Color", "-");
if (!Color.empty())
{
m_Color = Color[0];
}
}
else
{
cGroupManager::GenerateDefaultUsersIni(IniFile);
IniFile.AddValue("Groups", GetName(), "Default");
AddToGroup("Default");
}
IniFile.WriteFile("users.ini");
ResolvePermissions();
}
示例3: SetDefString
bool cProbabDistrib::SetDefString(const AString & a_DefString)
{
AStringVector Points = StringSplitAndTrim(a_DefString, ";");
if (Points.empty())
{
return false;
}
cPoints Pts;
for (AStringVector::const_iterator itr = Points.begin(), end = Points.end(); itr != end; ++itr)
{
AStringVector Split = StringSplitAndTrim(*itr, ",");
if (Split.size() != 2)
{
// Bad format
return false;
}
int Value = atoi(Split[0].c_str());
int Prob = atoi(Split[1].c_str());
if (
((Value == 0) && (Split[0] != "0")) ||
((Prob == 0) && (Split[1] != "0"))
)
{
// Number parse error
return false;
}
Pts.push_back(cPoint(Value, Prob));
} // for itr - Points[]
SetPoints(Pts);
return true;
}
示例4: OnExecuteCommand
bool cPlugin_NewLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
cCSLock Lock(m_CriticalSection);
const char * FnName = GetHookFnName(cPluginManager::HOOK_EXECUTE_COMMAND);
ASSERT(FnName != NULL);
if (!PushFunction(FnName))
{
return false;
}
tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
// Push the split:
lua_createtable(m_LuaState, a_Split.size(), 0);
int newTable = lua_gettop(m_LuaState);
int index = 1;
std::vector<std::string>::const_iterator iter = a_Split.begin(), end = a_Split.end();
while(iter != end)
{
tolua_pushstring(m_LuaState, (*iter).c_str());
lua_rawseti(m_LuaState, newTable, index);
++iter;
++index;
}
if (!CallFunction(2, 1, FnName))
{
return false;
}
bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
lua_pop(m_LuaState, 1);
return bRetVal;
}
示例5: CheckUsers
bool cGroupManager::CheckUsers()
{
cIniFile IniFile;
if (!IniFile.ReadFile("users.ini"))
{
GenerateDefaultUsersIni(IniFile);
return true;
}
int NumKeys = IniFile.GetNumKeys();
for (int i = 0; i < NumKeys; i++)
{
AString Player = IniFile.GetKeyName(i);
AString Groups = IniFile.GetValue(Player, "Groups", "");
if (Groups.empty())
{
continue;
}
AStringVector Split = StringSplitAndTrim(Groups, ",");
for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
{
if (!ExistsGroup(*itr))
{
LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str());
}
} // for itr - Split[]
} // for i - ini file keys
// Always return true for now, just but we can handle writefile fails later.
return true;
}
示例6: ParseCharMap
void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef)
{
ASSERT(a_CharMapDef != NULL);
// Initialize the charmap to all-invalid values:
for (size_t i = 0; i < ARRAYCOUNT(a_CharMapOut); i++)
{
a_CharMapOut[i].m_BlockType = 0;
a_CharMapOut[i].m_BlockMeta = 16; // Mark unassigned entries with a meta that is impossible otherwise
}
// Process the lines in the definition:
AStringVector Lines = StringSplitAndTrim(a_CharMapDef, "\n");
for (AStringVector::const_iterator itr = Lines.begin(), end = Lines.end(); itr != end; ++itr)
{
AStringVector CharDef = StringSplitAndTrim(*itr, ":");
size_t NumElements = CharDef.size();
if ((NumElements < 2) || CharDef[0].empty() || CharDef[1].empty())
{
LOGWARNING("Bad prefab CharMap definition line: \"%s\", skipping.", itr->c_str());
continue;
}
unsigned char Src = (unsigned char)CharDef[0][0];
ASSERT(a_CharMapOut[Src].m_BlockMeta == 16); // This letter has not been assigned yet?
a_CharMapOut[Src].m_BlockType = (BLOCKTYPE)atoi(CharDef[1].c_str());
NIBBLETYPE BlockMeta = 0;
if ((NumElements >= 3) && !CharDef[2].empty())
{
BlockMeta = (NIBBLETYPE)atoi(CharDef[2].c_str());
ASSERT((BlockMeta <= 15));
}
a_CharMapOut[Src].m_BlockMeta = BlockMeta;
} // for itr - Lines[]
}
示例7: ParseFormUrlEncoded
void cHTTPFormParser::ParseFormUrlEncoded(void)
{
// Parse m_IncomingData for all the variables; no more data is incoming, since this is called from Finish()
// This may not be the most performant version, but we don't care, the form data is small enough and we're not a full-fledged web server anyway
AStringVector Lines = StringSplit(m_IncomingData, "&");
for (AStringVector::iterator itr = Lines.begin(), end = Lines.end(); itr != end; ++itr)
{
AStringVector Components = StringSplit(*itr, "=");
switch (Components.size())
{
default:
{
// Neither name nor value, or too many "="s, mark this as invalid form:
m_IsValid = false;
return;
}
case 1:
{
// Only name present
(*this)[URLDecode(ReplaceAllCharOccurrences(Components[0], '+', ' '))] = "";
break;
}
case 2:
{
// name=value format:
(*this)[URLDecode(ReplaceAllCharOccurrences(Components[0], '+', ' '))] = URLDecode(ReplaceAllCharOccurrences(Components[1], '+', ' '));
break;
}
}
} // for itr - Lines[]
m_IncomingData.clear();
}
示例8: InitFinishGens
void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
int Seed = m_ChunkGenerator.GetSeed();
eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
AStringVector Str = StringSplitAndTrim(Finishers, ",");
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
{
// Finishers, alpha-sorted:
if (NoCaseCompare(*itr, "BottomLava") == 0)
{
int DefaultBottomLavaLevel = (Dimension == dimNether) ? 30 : 10;
int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
}
else if (NoCaseCompare(*itr, "DeadBushes") == 0)
{
m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
}
else if (NoCaseCompare(*itr, "Ice") == 0)
{
m_FinishGens.push_back(new cFinishGenIce);
}
else if (NoCaseCompare(*itr, "LavaSprings") == 0)
{
m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, Dimension));
}
else if (NoCaseCompare(*itr, "Lilypads") == 0)
{
m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
}
else if (NoCaseCompare(*itr, "NetherClumpFoliage") == 0)
{
m_FinishGens.push_back(new cFinishGenNetherClumpFoliage(Seed));
}
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
{
m_FinishGens.push_back(new cFinishGenPreSimulator);
}
else if (NoCaseCompare(*itr, "Snow") == 0)
{
m_FinishGens.push_back(new cFinishGenSnow);
}
else if (NoCaseCompare(*itr, "SprinkleFoliage") == 0)
{
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
}
else if (NoCaseCompare(*itr, "WaterSprings") == 0)
{
m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, Dimension));
}
} // for itr - Str[]
}
示例9: Push
void cLuaState::Push(const AStringVector & a_Vector)
{
ASSERT(IsValid());
lua_createtable(m_LuaState, static_cast<int>(a_Vector.size()), 0);
int newTable = lua_gettop(m_LuaState);
int index = 1;
for (AStringVector::const_iterator itr = a_Vector.begin(), end = a_Vector.end(); itr != end; ++itr, ++index)
{
tolua_pushstring(m_LuaState, itr->c_str());
lua_rawseti(m_LuaState, newTable, index);
}
m_NumCurrentFunctionArgs += 1;
}
示例10: HandleConsoleCommand
bool cPlugin_NewLua::HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output)
{
ASSERT(!a_Split.empty());
CommandMap::iterator cmd = m_ConsoleCommands.find(a_Split[0]);
if (cmd == m_ConsoleCommands.end())
{
LOGWARNING("Console command handler is registered in cPluginManager but not in cPlugin, wtf? Console command \"%s\", plugin \"%s\".",
a_Split[0].c_str(), GetName().c_str()
);
return false;
}
cCSLock Lock(m_CriticalSection);
// Push the function to be called:
lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, cmd->second); // same as lua_getref()
// Push the split:
lua_createtable(m_LuaState, a_Split.size(), 0);
int newTable = lua_gettop(m_LuaState);
int index = 1;
std::vector<std::string>::const_iterator iter = a_Split.begin(), end = a_Split.end();
while(iter != end)
{
tolua_pushstring(m_LuaState, (*iter).c_str());
lua_rawseti(m_LuaState, newTable, index);
++iter;
++index;
}
// Call function:
int s = lua_pcall(m_LuaState, 1, 2, 0);
if (report_errors(m_LuaState, s))
{
LOGERROR("Lua error. Stack size: %i", lua_gettop(m_LuaState));
return false;
}
// Handle return values:
if (lua_isstring(m_LuaState, -1))
{
AString str = tolua_tocppstring(m_LuaState, -1, "");
a_Output.Out(str);
}
bool RetVal = (tolua_toboolean(m_LuaState, -2, 0) > 0);
lua_pop(m_LuaState, 2); // Pop return values
return RetVal;
}
示例11: HandleCommand
bool cPlugin_NewLua::HandleCommand(const AStringVector & a_Split, cPlayer * a_Player)
{
ASSERT(!a_Split.empty());
CommandMap::iterator cmd = m_Commands.find(a_Split[0]);
if (cmd == m_Commands.end())
{
LOGWARNING("Command handler is registered in cPluginManager but not in cPlugin, wtf? Command \"%s\".", a_Split[0].c_str());
return false;
}
cCSLock Lock(m_CriticalSection);
// Push the function to be called:
lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, cmd->second); // same as lua_getref()
// Push the split:
lua_createtable(m_LuaState, a_Split.size(), 0);
int newTable = lua_gettop(m_LuaState);
int index = 1;
std::vector<std::string>::const_iterator iter = a_Split.begin(), end = a_Split.end();
while(iter != end)
{
tolua_pushstring(m_LuaState, (*iter).c_str());
lua_rawseti(m_LuaState, newTable, index);
++iter;
++index;
}
// Push player:
tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
// Call function:
int s = lua_pcall(m_LuaState, 2, 1, 0);
if (report_errors(m_LuaState, s))
{
LOGERROR("LUA error in %s. Stack size: %i", __FUNCTION__, lua_gettop(m_LuaState));
return false;
}
// Handle return value:
bool RetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
lua_pop(m_LuaState, 1); // Pop return value
return RetVal;
}
示例12: CacheNamesToUUIDs
void cMojangAPI::CacheNamesToUUIDs(const AStringVector & a_PlayerNames)
{
// Create a list of names to query, by removing those that are already cached:
AStringVector NamesToQuery;
NamesToQuery.reserve(a_PlayerNames.size());
{
cCSLock Lock(m_CSNameToUUID);
for (AStringVector::const_iterator itr = a_PlayerNames.begin(), end = a_PlayerNames.end(); itr != end; ++itr)
{
if (m_NameToUUID.find(*itr) == m_NameToUUID.end())
{
NamesToQuery.push_back(*itr);
}
} // for itr - a_PlayerNames[]
} // Lock(m_CSNameToUUID)
QueryNamesToUUIDs(NamesToQuery);
}
示例13: ParseDepthWeight
void cPrefab::ParseDepthWeight(const char * a_DepthWeightDef)
{
// The member needn't be defined at all, if so, skip:
if (a_DepthWeightDef == NULL)
{
return;
}
// Split into individual records: "Record | Record | Record"
AStringVector Defs = StringSplitAndTrim(a_DepthWeightDef, "|");
// Add each record's contents:
for (AStringVector::const_iterator itr = Defs.begin(), end = Defs.end(); itr != end; ++itr)
{
// Split into components: "Depth : Weight"
AStringVector Components = StringSplitAndTrim(*itr, ":");
if (Components.size() != 2)
{
LOGWARNING("Bad prefab DepthWeight record: \"%s\", skipping.", itr->c_str());
continue;
}
// Parse depth:
int Depth = atoi(Components[0].c_str());
if ((Depth == 0) && (Components[0] != "0"))
{
LOGWARNING("Bad prefab DepthWeight record, cannot parse depth \"%s\", skipping.", Components[0].c_str());
continue;
}
// Parse weight:
int Weight = atoi(Components[1].c_str());
if ((Weight == 0) && (Components[1] != "0"))
{
LOGWARNING("Bad prefab DepthWeight record, cannot parse weight \"%s\", skipping.", Components[1].c_str());
continue;
}
// Save to map:
ASSERT(m_DepthWeight.find(Depth) == m_DepthWeight.end()); // Not a duplicate
m_DepthWeight[Depth] = Weight;
} // for itr - Defs[]
}
示例14: ReadUpgradeIniPorts
AStringVector ReadUpgradeIniPorts(
cSettingsRepositoryInterface & a_Settings,
const AString & a_KeyName,
const AString & a_PortsValueName,
const AString & a_OldIPv4ValueName,
const AString & a_OldIPv6ValueName,
const AString & a_DefaultValue
)
{
// Read the regular value, but don't use the default (in order to detect missing value for upgrade):
AStringVector Ports;
for (auto pair : a_Settings.GetValues(a_KeyName))
{
if (pair.first != a_PortsValueName)
{
continue;
}
AStringVector temp = StringSplitAndTrim(pair.second, ";,");
Ports.insert(Ports.end(), temp.begin(), temp.end());
}
if (Ports.empty())
{
// Historically there were two separate entries for IPv4 and IPv6, merge them and migrate:
AString Ports4 = a_Settings.GetValue(a_KeyName, a_OldIPv4ValueName, a_DefaultValue);
AString Ports6 = a_Settings.GetValue(a_KeyName, a_OldIPv6ValueName);
Ports = MergeStringVectors(StringSplitAndTrim(Ports4, ";,"), StringSplitAndTrim(Ports6, ";,"));
a_Settings.DeleteValue(a_KeyName, a_OldIPv4ValueName);
a_Settings.DeleteValue(a_KeyName, a_OldIPv6ValueName);
// If those weren't present or were empty, use the default:"
if (Ports.empty())
{
Ports = StringSplitAndTrim(a_DefaultValue, ";,");
}
a_Settings.SetValue(a_KeyName, a_PortsValueName, StringsConcat(Ports, ','));
}
return Ports;
}
示例15: Serialized
void cProtocol132::SendTabCompletionResults(const AStringVector & a_Results)
{
if (a_Results.empty())
{
// No results to send
return;
}
AString Serialized(a_Results[0]);
for (AStringVector::const_iterator itr = a_Results.begin() + 1, end = a_Results.end(); itr != end; ++itr)
{
Serialized.push_back(0);
Serialized.append(*itr);
} // for itr - a_Results[]
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_TAB_COMPLETION);
WriteString(Serialized);
Flush();
}