当前位置: 首页>>代码示例>>C++>>正文


C++ AStringVector类代码示例

本文整理汇总了C++中AStringVector的典型用法代码示例。如果您正苦于以下问题:C++ AStringVector类的具体用法?C++ AStringVector怎么用?C++ AStringVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AStringVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StringSplit

std::pair<AString, AString> cWebPlugin::GetTabNameForRequest(const HTTPRequest & a_Request)
{
	AStringVector Split = StringSplit(a_Request.Path, "/");
	if (Split.empty())
	{
		return std::make_pair(AString(), AString());
	}

	cCSLock Lock(m_CSTabs);
	cTabPtr Tab;
	if (Split.size() > 2)  // If we got the tab name, show that page
	{
		for (auto itr = m_Tabs.cbegin(), end = m_Tabs.cend(); itr != end; ++itr)
		{
			if ((*itr)->m_SafeTitle.compare(Split[2]) == 0)  // This is the one!
			{
				return std::make_pair((*itr)->m_Title, (*itr)->m_SafeTitle);
			}
		}
		// Tab name not found, display an "empty" page:
		return std::make_pair(AString(), AString());
	}

	// Show the first tab:
	if (!m_Tabs.empty())
	{
		return std::make_pair(m_Tabs.front()->m_SafeTitle, m_Tabs.front()->m_SafeTitle);
	}

	// No tabs at all:
	return std::make_pair(AString(), AString());
}
开发者ID:1285done,项目名称:cuberite,代码行数:32,代码来源:WebPlugin.cpp

示例2: StringSplit

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();
}
开发者ID:36451,项目名称:MCServer,代码行数:32,代码来源:HTTPFormParser.cpp

示例3: StringSplit

void cPlayer::LoadPermissionsFromDisk()
{
    m_Groups.clear();
    m_Permissions.clear();

    cIniFile IniFile;
    if (IniFile.ReadFile("users.ini"))
    {
        std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", "");
        if (!Groups.empty())
        {
            AStringVector Split = StringSplit( Groups, "," );
            for( unsigned int i = 0; i < Split.size(); i++ )
            {
                AddToGroup( Split[i].c_str() );
            }
        }
        else
        {
            AddToGroup("Default");
        }

        m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0];
    }
    else
    {
        LOGWARN("Failed to read the users.ini file. The player will be added only to the Default group.");
        AddToGroup("Default");
    }
    ResolvePermissions();
}
开发者ID:Noraaron1,项目名称:MCServer,代码行数:31,代码来源:Player.cpp

示例4: StringSplit

std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest * a_Request)
{
	std::pair< AString, AString > Names;
	AStringVector Split = StringSplit(a_Request->Path, "/");

	if( Split.size() > 1 )
	{
		sWebPluginTab* Tab = 0;
		if( Split.size() > 2 )	// If we got the tab name, show that page
		{
			for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
			{
				if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr
				{
					Tab = *itr;
					break;
				}
			}
		}
		else	// Otherwise show the first tab
		{
			if( GetTabs().size() > 0 )
				Tab = *GetTabs().begin();
		}

		if( Tab )
		{
			Names.first = Tab->Title;
			Names.second = Tab->SafeTitle;
		}
	}

	return Names;
}
开发者ID:Dam63,项目名称:MCServer,代码行数:34,代码来源:WebPlugin.cpp

示例5: PermissionMatches

bool cPlayer::PermissionMatches(const AStringVector & a_Permission, const AStringVector & a_Template)
{
	// Check the sub-items if they are the same or there's a wildcard:
	size_t lenP = a_Permission.size();
	size_t lenT = a_Template.size();
	size_t minLen = std::min(lenP, lenT);
	for (size_t i = 0; i < minLen; i++)
	{
		if (a_Template[i] == "*")
		{
			// Has matched so far and now there's a wildcard in the template, so the permission matches:
			return true;
		}
		if (a_Permission[i] != a_Template[i])
		{
			// Found a mismatch
			return false;
		}
	}

	// So far all the sub-items have matched
	// If the sub-item count is the same, then the permission matches:
	if (lenP == lenT)
	{
		return true;
	}

	// There are more sub-items in either the permission or the template, not a match:
	return false;
}
开发者ID:cedeel,项目名称:MCServer,代码行数:30,代码来源:Player.cpp

示例6: StringSplit

bool cCraftingRecipes::ParseItem(const AString & a_String, cItem & a_Item)
{
	// The caller provides error logging
	
	AStringVector Split = StringSplit(a_String, "^");
	if (Split.empty())
	{
		return false;
	}
	
	if (!StringToItem(Split[0], a_Item))
	{
		return false;
	}
	
	if (Split.size() > 1)
	{
		AString Damage = TrimString(Split[1]);
		if (!StringToInteger<short>(Damage.c_str(), a_Item.m_ItemDamage))
		{
			// Parsing the number failed
			return false;
		}
	}
	
	// Success
	return true;
}
开发者ID:DjKiDD,项目名称:MCServer,代码行数:28,代码来源:CraftingRecipes.cpp

示例7: GenerateDefaultUsersIni

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;
}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:30,代码来源:GroupManager.cpp

示例8: 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;
}
开发者ID:l0ud,项目名称:MCServer,代码行数:34,代码来源:Plugin_NewLua.cpp

示例9: ASSERT

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[]
}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:34,代码来源:Prefab.cpp

示例10: InsertDefaultPlugins

AStringVector cPluginManager::GetFoldersToLoad(cSettingsRepositoryInterface & a_Settings)
{
	// Check if the Plugins section exists.
	if (!a_Settings.KeyExists("Plugins"))
	{
		InsertDefaultPlugins(a_Settings);
	}

	// Get the list of plugins to load:
	AStringVector res;
	auto Values = a_Settings.GetValues("Plugins");
	for (auto NameValue : Values)
	{
		AString ValueName = NameValue.first;
		if (ValueName.compare("Plugin") == 0)
		{
			AString PluginFile = NameValue.second;
			if (!PluginFile.empty())
			{
				res.push_back(PluginFile);
			}
		}
	}  // for i - ini values

	return res;
}
开发者ID:GoogleIt15973,项目名称:cuberite,代码行数:26,代码来源:PluginManager.cpp

示例11: StringSplit

sWebAdminPage cWebAdmin::GetPage(const HTTPRequest & a_Request)
{
	sWebAdminPage Page;
	AStringVector Split = StringSplit(a_Request.Path, "/");

	// Find the plugin that corresponds to the requested path
	AString FoundPlugin;
	if (Split.size() > 1)
	{
		for (PluginList::iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
		{
			if ((*itr)->GetWebTitle() == Split[1])
			{
				Page.Content = (*itr)->HandleWebRequest(&a_Request);
				cWebPlugin * WebPlugin = *itr;
				FoundPlugin = WebPlugin->GetWebTitle();
				AString TabName = WebPlugin->GetTabNameForRequest(&a_Request).first;
				Page.PluginName = FoundPlugin;
				Page.TabName = TabName;
				break;
			}
		}
	}

	// Return the page contents
	return Page;
}
开发者ID:crexalbo,项目名称:MCServer,代码行数:27,代码来源:WebAdmin.cpp

示例12: StringSplitAndTrim

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();
}
开发者ID:Kortak,项目名称:MCServer,代码行数:35,代码来源:Player.cpp

示例13: StringSplit

void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output)
{
	AStringVector split = StringSplit(a_Cmd, " ");
	if (split.empty())
	{
		return;
	}
	
	// Special handling: "stop" and "restart" are built in
	if ((split[0].compare("stop") == 0) || (split[0].compare("restart") == 0))
	{
		return;
	}
	
	// "help" and "reload" are to be handled by MCS, so that they work no matter what
	if (split[0] == "help")
	{
		PrintHelp(split, a_Output);
		return;
	}
	if (split[0] == "reload")
	{
		cPluginManager::Get()->ReloadPlugins();
		return;
	}
	
	// There is currently no way a plugin can do these (and probably won't ever be):
	if (split[0].compare("chunkstats") == 0)
	{
		cRoot::Get()->LogChunkStats(a_Output);
		a_Output.Finished();
		return;
	}
	#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
	if (split[0].compare("dumpmem") == 0)
	{
		LeakFinderXmlOutput Output("memdump.xml");
		DumpUsedMemory(&Output);
		return;
	}
	
	if (split[0].compare("killmem") == 0)
	{
		while (true)
		{
			new char[100 * 1024 * 1024];  // Allocate and leak 100 MiB in a loop -> fill memory and kill MCS
		}
	}
	#endif
	
	if (cPluginManager::Get()->ExecuteConsoleCommand(split, a_Output))
	{
		a_Output.Finished();
		return;
	}
	
	a_Output.Out("Unknown command, type 'help' for all commands.");
	a_Output.Finished();
}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:59,代码来源:Server.cpp

示例14: GetFolderContents

AStringVector cFile::GetFolderContents(const AString & a_Folder)
{
	AStringVector AllFiles;

	#ifdef _WIN32

		// If the folder name doesn't contain the terminating slash / backslash, add it:
		AString FileFilter = a_Folder;
		if (
			!FileFilter.empty() &&
			(FileFilter[FileFilter.length() - 1] != '\\') &&
			(FileFilter[FileFilter.length() - 1] != '/')
		)
		{
			FileFilter.push_back('\\');
		}

		// Find all files / folders:
		FileFilter.append("*.*");
		HANDLE hFind;
		WIN32_FIND_DATAA FindFileData;
		if ((hFind = FindFirstFileA(FileFilter.c_str(), &FindFileData)) != INVALID_HANDLE_VALUE)
		{
			do
			{
				AllFiles.push_back(FindFileData.cFileName);
			} while (FindNextFileA(hFind, &FindFileData));
			FindClose(hFind);
		}

	#else  // _WIN32

		DIR * dp;
		AString Folder = a_Folder;
		if (Folder.empty())
		{
			Folder = ".";
		}
		if ((dp = opendir(Folder.c_str())) == nullptr)
		{
			LOGERROR("Error (%i) opening directory \"%s\"\n", errno, Folder.c_str());
		}
		else
		{
			struct dirent *dirp;
			while ((dirp = readdir(dp)) != nullptr)
			{
				AllFiles.push_back(dirp->d_name);
			}
			closedir(dp);
		}

	#endif  // else _WIN32

	return AllFiles;
}
开发者ID:1285done,项目名称:cuberite,代码行数:56,代码来源:File.cpp

示例15: CacheNamesToUUIDs

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;
}
开发者ID:TigerHix,项目名称:MCServer,代码行数:30,代码来源:MojangAPI.cpp


注:本文中的AStringVector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。