mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-23 00:28:08 +02:00
.github
AI
CI
Mods
android
client
clientapp
cmake_modules
config
debian
docker
docs
include
ios
launcher
lib
battle
bonuses
campaign
constants
entities
events
filesystem
gameState
json
logging
mapObjectConstructors
mapObjects
mapping
minizip
modding
ActiveModsInSaveList.cpp
ActiveModsInSaveList.h
CModHandler.cpp
CModHandler.h
CModVersion.cpp
CModVersion.h
ContentTypeHandler.cpp
ContentTypeHandler.h
IdentifierStorage.cpp
IdentifierStorage.h
ModDescription.cpp
ModDescription.h
ModIncompatibility.h
ModManager.cpp
ModManager.h
ModScope.h
ModUtility.cpp
ModUtility.h
ModVerificationInfo.cpp
ModVerificationInfo.h
network
networkPacks
pathfinder
rewardable
rmg
serializer
spells
texts
vstd
AI_Base.h
ArtifactUtils.cpp
ArtifactUtils.h
AsyncRunner.h
BasicTypes.cpp
BattleFieldHandler.cpp
BattleFieldHandler.h
CAndroidVMHelper.cpp
CAndroidVMHelper.h
CArtHandler.cpp
CArtHandler.h
CArtifactInstance.cpp
CArtifactInstance.h
CBonusTypeHandler.cpp
CBonusTypeHandler.h
CConfigHandler.cpp
CConfigHandler.h
CConsoleHandler.cpp
CConsoleHandler.h
CCreatureHandler.cpp
CCreatureHandler.h
CCreatureSet.cpp
CCreatureSet.h
CGameInfoCallback.cpp
CGameInfoCallback.h
CGameInterface.cpp
CGameInterface.h
CMakeLists.txt
CPlayerState.cpp
CPlayerState.h
CRandomGenerator.cpp
CRandomGenerator.h
CScriptingModule.cpp
CScriptingModule.h
CSkillHandler.cpp
CSkillHandler.h
CSoundBase.h
CStack.cpp
CStack.h
CStopWatch.h
CThreadHelper.cpp
CThreadHelper.h
Color.h
ConditionalWait.h
ConstTransitivePtr.h
ExceptionsCommon.h
ExtraOptionsInfo.cpp
ExtraOptionsInfo.h
FunctionList.h
GameCallbackHolder.h
GameConstants.h
GameLibrary.cpp
GameLibrary.h
GameSettings.cpp
GameSettings.h
IBonusTypeHandler.h
IGameCallback.cpp
IGameCallback.h
IGameEventsReceiver.h
IGameSettings.h
IHandlerBase.cpp
IHandlerBase.h
LoadProgress.cpp
LoadProgress.h
LogicalExpression.cpp
LogicalExpression.h
ObstacleHandler.cpp
ObstacleHandler.h
Point.h
Rect.cpp
Rect.h
ResourceSet.cpp
ResourceSet.h
RiverHandler.cpp
RiverHandler.h
RoadHandler.cpp
RoadHandler.h
ScopeGuard.h
ScriptHandler.cpp
ScriptHandler.h
StartInfo.cpp
StartInfo.h
StdInc.cpp
StdInc.h
TerrainHandler.cpp
TerrainHandler.h
TurnTimerInfo.cpp
TurnTimerInfo.h
UnlockGuard.h
VCMIDirs.cpp
VCMIDirs.h
int3.h
vcmi_endian.h
lobby
mapeditor
osx
rpm
scripting
scripts
server
serverapp
test
vcmiqt
win
xcode
.editorconfig
.gitattributes
.gitignore
.gitmodules
.travis.yml
AUTHORS.h
CCallback.cpp
CCallback.h
CMakeLists.txt
CMakePresets.json
ChangeLog.md
Global.h
Version.cpp.in
Version.h
conanfile.py
fuzzylite.pc.in
license.txt
vcmibuilder
- IdentifierStorage is now a separate handler in VLC - Renamed ModHandler::Incompatibility exception to ModIncompatibility - Extracted ModScope namespace from ModHandler - Extracted ModUtilities namespace from ModHandler - Split CModHandler.cpp on per-class basis - Replaced some direct members with unique_ptr to reduce header includes
78 lines
1.8 KiB
C++
78 lines
1.8 KiB
C++
/*
|
|
* CModHandler.cpp, part of VCMI engine
|
|
*
|
|
* Authors: listed in file AUTHORS in main folder
|
|
*
|
|
* License: GNU General Public License v2.0 or later
|
|
* Full text of license available in license.txt file, in main folder
|
|
*
|
|
*/
|
|
#include "StdInc.h"
|
|
#include "ModUtility.h"
|
|
|
|
#include <vstd/StringUtils.h>
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
std::string ModUtility::normalizeIdentifier(const std::string & scope, const std::string & remoteScope, const std::string & identifier)
|
|
{
|
|
auto p = vstd::splitStringToPair(identifier, ':');
|
|
|
|
if(p.first.empty())
|
|
p.first = scope;
|
|
|
|
if(p.first == remoteScope)
|
|
p.first.clear();
|
|
|
|
return p.first.empty() ? p.second : p.first + ":" + p.second;
|
|
}
|
|
|
|
void ModUtility::parseIdentifier(const std::string & fullIdentifier, std::string & scope, std::string & type, std::string & identifier)
|
|
{
|
|
auto p = vstd::splitStringToPair(fullIdentifier, ':');
|
|
|
|
scope = p.first;
|
|
|
|
auto p2 = vstd::splitStringToPair(p.second, '.');
|
|
|
|
if(!p2.first.empty())
|
|
{
|
|
type = p2.first;
|
|
identifier = p2.second;
|
|
}
|
|
else
|
|
{
|
|
type = p.second;
|
|
identifier.clear();
|
|
}
|
|
}
|
|
|
|
std::string ModUtility::makeFullIdentifier(const std::string & scope, const std::string & type, const std::string & identifier)
|
|
{
|
|
if(type.empty())
|
|
logGlobal->error("Full identifier (%s %s) requires type name", scope, identifier);
|
|
|
|
std::string actualScope = scope;
|
|
std::string actualName = identifier;
|
|
|
|
//ignore scope if identifier is scoped
|
|
auto scopeAndName = vstd::splitStringToPair(identifier, ':');
|
|
|
|
if(!scopeAndName.first.empty())
|
|
{
|
|
actualScope = scopeAndName.first;
|
|
actualName = scopeAndName.second;
|
|
}
|
|
|
|
if(actualScope.empty())
|
|
{
|
|
return actualName.empty() ? type : type + "." + actualName;
|
|
}
|
|
else
|
|
{
|
|
return actualName.empty() ? actualScope+ ":" + type : actualScope + ":" + type + "." + actualName;
|
|
}
|
|
}
|
|
|
|
VCMI_LIB_NAMESPACE_END
|