Rename to lowerCaseInPlace

(cherry picked from commit 07b064f616)

# Conflicts:
#	apps/opencs/model/world/commanddispatcher.cpp
#	apps/opencs/model/world/regionmap.cpp
#	apps/opencs/model/world/scriptcontext.cpp
#	apps/openmw/mwrender/animation.cpp
#	apps/openmw/mwscript/statsextensions.cpp
#	apps/openmw/mwworld/store.cpp
#	components/misc/stringops.hpp
pull/541/head
scrawl 9 years ago committed by cc9cii
parent 98ea184dda
commit f456174af8

@ -395,7 +395,7 @@ public:
virtual void read(ESM::ESMReader &esm)
{
std::string itemid = esm.getHNString("NAME");
Misc::StringUtils::toLower(itemid);
Misc::StringUtils::lowerCaseInPlace(itemid);
while (esm.isNextSub("FNAM") || esm.isNextSub("ONAM"))
{

@ -847,7 +847,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co
for(std::vector<std::string>::const_iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
std::string filetype(entry->substr(entry->length()-3));
Misc::StringUtils::toLower(filetype);
Misc::StringUtils::lowerCaseInPlace(filetype);
if(filetype.compare("esm") == 0 || filetype.compare("esp") == 0) {
boost::filesystem::path filepath(gameFilesDir);

@ -93,7 +93,7 @@ void CSMWorld::CommandDispatcher::setEditLock (bool locked)
void CSMWorld::CommandDispatcher::setSelection (const std::vector<std::string>& selection)
{
mSelection = selection;
std::for_each (mSelection.begin(), mSelection.end(), Misc::StringUtils::toLower);
std::for_each (mSelection.begin(), mSelection.end(), Misc::StringUtils::lowerCaseInPlace);
std::sort (mSelection.begin(), mSelection.end());
}

@ -168,7 +168,7 @@ void CSMWorld::RegionMap::updateRegions (const std::vector<std::string>& regions
{
std::vector<std::string> regions2 (regions);
std::for_each (regions2.begin(), regions2.end(), &Misc::StringUtils::lowerCase);
std::for_each (regions2.begin(), regions2.end(), Misc::StringUtils::lowerCaseInPlace);
std::sort (regions2.begin(), regions2.end());
for (std::map<CellCoordinates, CellDescription>::const_iterator iter (mMap.begin());

@ -93,7 +93,7 @@ bool CSMWorld::ScriptContext::isId (const std::string& name) const
{
mIds = mData.getIds();
std::for_each (mIds.begin(), mIds.end(), &Misc::StringUtils::toLower);
std::for_each (mIds.begin(), mIds.end(), &Misc::StringUtils::lowerCaseInPlace);
std::sort (mIds.begin(), mIds.end());
mIdsUpdated = true;

@ -146,11 +146,11 @@ namespace MWClass
// make key id lowercase
std::string keyId = ptr.getCellRef().getKey();
Misc::StringUtils::toLower(keyId);
Misc::StringUtils::lowerCaseInPlace(keyId);
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
{
std::string refId = it->getCellRef().getRefId();
Misc::StringUtils::toLower(refId);
Misc::StringUtils::lowerCaseInPlace(refId);
if (refId == keyId)
{
hasKey = true;

@ -113,11 +113,11 @@ namespace MWClass
// make key id lowercase
std::string keyId = ptr.getCellRef().getKey();
Misc::StringUtils::toLower(keyId);
Misc::StringUtils::lowerCaseInPlace(keyId);
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
{
std::string refId = it->getCellRef().getRefId();
Misc::StringUtils::toLower(refId);
Misc::StringUtils::lowerCaseInPlace(refId);
if (refId == keyId)
{
hasKey = true;

@ -129,7 +129,7 @@ namespace MWGui
size_t tagNameEndPos = tag.find(' ');
mAttributes.clear();
mTag = tag.substr(0, tagNameEndPos);
Misc::StringUtils::toLower(mTag);
Misc::StringUtils::lowerCaseInPlace(mTag);
if (mTag.empty())
return;
@ -151,7 +151,7 @@ namespace MWGui
return;
std::string key = tag.substr(0, sepPos);
Misc::StringUtils::toLower(key);
Misc::StringUtils::lowerCaseInPlace(key);
tag.erase(0, sepPos+1);
std::string value;

@ -35,7 +35,7 @@ namespace MWGui
{
const ESM::GameSetting &currentSetting = *currentIteration;
std::string currentGMSTID = currentSetting.mId;
Misc::StringUtils::toLower(currentGMSTID);
Misc::StringUtils::lowerCaseInPlace(currentGMSTID);
// Don't bother checking this GMST if it's not a sMagicBound* one.
const std::string& toFind = "smagicbound";
@ -44,7 +44,7 @@ namespace MWGui
// All sMagicBound* GMST's should be of type string
std::string currentGMSTValue = currentSetting.getString();
Misc::StringUtils::toLower(currentGMSTValue);
Misc::StringUtils::lowerCaseInPlace(currentGMSTValue);
boundItemIDCache.insert(currentGMSTValue);
}
@ -52,7 +52,7 @@ namespace MWGui
// Perform bound item check and assign the Flag_Bound bit if it passes
std::string tempItemID = base.getCellRef().getRefId();
Misc::StringUtils::toLower(tempItemID);
Misc::StringUtils::lowerCaseInPlace(tempItemID);
if (boundItemIDCache.count(tempItemID) != 0)
mFlags |= Flag_Bound;

@ -132,15 +132,11 @@ namespace MWMechanics
return scaledDuration-usedUp;
}
bool ActiveSpells::isSpellActive(std::string id) const
bool ActiveSpells::isSpellActive(const std::string& id) const
{
Misc::StringUtils::toLower(id);
for (TContainer::iterator iter = mSpells.begin(); iter != mSpells.end(); ++iter)
{
std::string left = iter->first;
Misc::StringUtils::toLower(left);
if (iter->first == id)
if (Misc::StringUtils::ciEqual(iter->first, id))
return true;
}
return false;

@ -97,7 +97,7 @@ namespace MWMechanics
/// Remove all spells
void clear();
bool isSpellActive (std::string id) const;
bool isSpellActive (const std::string& id) const;
///< case insensitive
const MagicEffects& getMagicEffects() const;

@ -607,7 +607,7 @@ namespace MWMechanics
int rank = 0;
std::string npcFaction = ptr.getClass().getPrimaryFaction(ptr);
Misc::StringUtils::toLower(npcFaction);
Misc::StringUtils::lowerCaseInPlace(npcFaction);
if (playerStats.getFactionRanks().find(npcFaction) != playerStats.getFactionRanks().end())
{
@ -1045,7 +1045,7 @@ namespace MWMechanics
owner.first = ownerCellRef->getFaction();
owner.second = true;
}
Misc::StringUtils::toLower(owner.first);
Misc::StringUtils::lowerCaseInPlace(owner.first);
if (!Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId))
mStolenItems[Misc::StringUtils::lowerCase(item.getClass().getId(item))][owner] += count;

@ -430,12 +430,8 @@ NifOgre::TextKeyMap::const_iterator Animation::findGroupStart(const NifOgre::Tex
NifOgre::TextKeyMap::const_iterator iter(keys.begin());
for(;iter != keys.end();++iter)
{
if(iter->second.compare(0, groupname.size(), groupname) == 0 &&
iter->second.compare(groupname.size(), 2, ": ") == 0)
break;
}
return iter;
}
std::string kfname = model;
Misc::StringUtils::lowerCaseInPlace(kfname);
bool Animation::hasAnimation(const std::string &anim)

@ -120,7 +120,7 @@ namespace MWScript
const MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell();
std::string current = MWBase::Environment::get().getWorld()->getCellName(cell);
Misc::StringUtils::toLower(current);
Misc::StringUtils::lowerCaseInPlace(current);
bool match = current.length()>=name.length() &&
current.substr (0, name.length())==name;

@ -114,7 +114,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
std::string cell = (runtime.getStringLiteral (runtime[0].mInteger));
::Misc::StringUtils::toLower(cell);
::Misc::StringUtils::lowerCaseInPlace(cell);
runtime.pop();
// "Will match complete or partial cells, so ShowMap, "Vivec" will show cells Vivec and Vivec, Fred's House as well."
@ -127,7 +127,7 @@ namespace MWScript
for (; it != cells.extEnd(); ++it)
{
std::string name = it->mName;
::Misc::StringUtils::toLower(name);
::Misc::StringUtils::lowerCaseInPlace(name);
if (name.find(cell) != std::string::npos)
MWBase::Environment::get().getWindowManager()->addVisitedLocation (
it->mName,

@ -542,7 +542,7 @@ namespace MWScript
factionID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
}
::Misc::StringUtils::toLower(factionID);
::Misc::StringUtils::lowerCaseInPlace(factionID);
// Make sure this faction exists
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionID);
@ -574,7 +574,7 @@ namespace MWScript
factionID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
}
::Misc::StringUtils::toLower(factionID);
::Misc::StringUtils::lowerCaseInPlace(factionID);
// Make sure this faction exists
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionID);
@ -613,7 +613,7 @@ namespace MWScript
factionID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
}
::Misc::StringUtils::toLower(factionID);
::Misc::StringUtils::lowerCaseInPlace(factionID);
// Make sure this faction exists
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionID);
@ -644,7 +644,7 @@ namespace MWScript
{
factionID = ptr.getClass().getPrimaryFaction(ptr);
}
::Misc::StringUtils::toLower(factionID);
::Misc::StringUtils::lowerCaseInPlace(factionID);
// Make sure this faction exists
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionID);
@ -755,7 +755,7 @@ namespace MWScript
if (factionId.empty())
throw std::runtime_error ("failed to determine faction");
::Misc::StringUtils::toLower (factionId);
::Misc::StringUtils::lowerCaseInPlace (factionId);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
runtime.push (
@ -790,7 +790,7 @@ namespace MWScript
if (factionId.empty())
throw std::runtime_error ("failed to determine faction");
::Misc::StringUtils::toLower (factionId);
::Misc::StringUtils::lowerCaseInPlace (factionId);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
player.getClass().getNpcStats (player).setFactionReputation (factionId, value);
@ -824,7 +824,7 @@ namespace MWScript
if (factionId.empty())
throw std::runtime_error ("failed to determine faction");
::Misc::StringUtils::toLower (factionId);
::Misc::StringUtils::lowerCaseInPlace (factionId);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
player.getClass().getNpcStats (player).setFactionReputation (factionId,
@ -869,11 +869,11 @@ namespace MWScript
MWWorld::Ptr ptr = R()(runtime);
std::string race = runtime.getStringLiteral(runtime[0].mInteger);
::Misc::StringUtils::toLower(race);
::Misc::StringUtils::lowerCaseInPlace(race);
runtime.pop();
std::string npcRace = ptr.get<ESM::NPC>()->mBase->mRace;
::Misc::StringUtils::toLower(npcRace);
::Misc::StringUtils::lowerCaseInPlace(npcRace);
runtime.push (npcRace == race);
}
@ -910,7 +910,7 @@ namespace MWScript
{
factionID = ptr.getClass().getPrimaryFaction(ptr);
}
::Misc::StringUtils::toLower(factionID);
::Misc::StringUtils::lowerCaseInPlace(factionID);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if(factionID!="")
{

@ -540,7 +540,7 @@ namespace MWWorld
void CellStore::loadRef (ESM::CellRef& ref, bool deleted, const ESMStore& store)
{
Misc::StringUtils::toLower (ref.mRefID);
Misc::StringUtils::lowerCaseInPlace (ref.mRefID);
switch (store.find (ref.mRefID))
{

@ -96,7 +96,7 @@ namespace MWWorld
// This readRecord() method is used when reading a saved game.
// Deleted globals can't appear there, so isDeleted will be ignored here.
global.load(reader, isDeleted);
Misc::StringUtils::toLower(global.mId);
Misc::StringUtils::lowerCaseInPlace(global.mId);
Collection::iterator iter = mVariables.find (global.mId);
if (iter!=mVariables.end())

@ -66,7 +66,51 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm)
// spawn a new cell
cell.loadCell(esm, true);
mInt[idLower] = cell;
record.load(esm, isDeleted);
Misc::StringUtils::lowerCaseInPlace(record.mId);
std::pair<typename Static::iterator, bool> inserted = mStatic.insert(std::make_pair(record.mId, record));
if (inserted.second)
mShared.push_back(&inserted.first->second);
else
inserted.first->second = record;
return RecordId(record.mId, isDeleted);
}
template<typename T>
void Store<T>::setUp()
{
}
template<typename T>
typename Store<T>::iterator Store<T>::begin() const
{
return mShared.begin();
}
template<typename T>
typename Store<T>::iterator Store<T>::end() const
{
return mShared.end();
}
template<typename T>
size_t Store<T>::getSize() const
{
return mShared.size();
}
template<typename T>
int Store<T>::getDynamicSize() const
{
return mDynamic.size();
}
template<typename T>
void Store<T>::listIdentifier(std::vector<std::string> &list) const
{
list.reserve(list.size() + getSize());
typename std::vector<T *>::const_iterator it = mShared.begin();
for (; it != mShared.end(); ++it) {
list.push_back((*it)->mId);
}
}
else

@ -49,7 +49,7 @@ std::string Misc::ResourceHelpers::correctResourcePath(const std::string &topLev
std::string prefix2 = topLevelDirectory + '/';
std::string correctedPath = resPath;
Misc::StringUtils::toLower(correctedPath);
Misc::StringUtils::lowerCaseInPlace(correctedPath);
// Apparently, leading separators are allowed
while (correctedPath.size() && (correctedPath[0] == '/' || correctedPath[0] == '\\'))

@ -70,7 +70,7 @@ public:
}
/// Transforms input string to lower case w/o copy
static std::string &toLower(std::string &inout) {
static void lowerCaseInPlace(std::string &inout) {
for (unsigned int i=0; i<inout.size(); ++i)
inout[i] = tolower(inout[i]);
return inout;
@ -80,7 +80,8 @@ public:
static std::string lowerCase(const std::string &in)
{
std::string out = in;
return toLower(out);
lowerCaseInPlace(out);
return out;
}
};

Loading…
Cancel
Save