From c75a5ae212bc01d1b3d37ffcf0f3cf879f7775a4 Mon Sep 17 00:00:00 2001 From: eduard Date: Fri, 28 Dec 2012 18:05:52 +0100 Subject: [PATCH] string compare and tolower --- apps/openmw/mwworld/containerstore.cpp | 18 ++++++++++++------ components/misc/stringops.cpp | 7 +------ components/misc/stringops.hpp | 5 ++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index f736a5253..5c4dd03a4 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -34,6 +34,12 @@ namespace return sum; } + + bool compare_string_ci(std::string str1, std::string str2) + { + boost::algorithm::to_lower(str1); + return str1 == str2; + } } MWWorld::ContainerStore::ContainerStore() : mStateId (0), mCachedWeight (0), mWeightUpToDate (false) {} @@ -75,11 +81,11 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) MWWorld::LiveCellRef *gold = ptr.get(); - if (Misc::compare_string_ci(gold->ref.mRefID, "gold_001") - || Misc::compare_string_ci(gold->ref.mRefID, "gold_005") - || Misc::compare_string_ci(gold->ref.mRefID, "gold_010") - || Misc::compare_string_ci(gold->ref.mRefID, "gold_025") - || Misc::compare_string_ci(gold->ref.mRefID, "gold_100")) + if (compare_string_ci(gold->ref.mRefID, "gold_001") + || compare_string_ci(gold->ref.mRefID, "gold_005") + || compare_string_ci(gold->ref.mRefID, "gold_010") + || compare_string_ci(gold->ref.mRefID, "gold_025") + || compare_string_ci(gold->ref.mRefID, "gold_100")) { MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001"); @@ -87,7 +93,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) ref.getPtr().getRefData().setCount(count); for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) { - if (Misc::compare_string_ci((*iter).get()->ref.mRefID, "gold_001")) + if (compare_string_ci((*iter).get()->ref.mRefID, "gold_001")) { (*iter).getRefData().setCount( (*iter).getRefData().getCount() + count); flagAsModified(); diff --git a/components/misc/stringops.cpp b/components/misc/stringops.cpp index f209bf46b..51cf2105a 100644 --- a/components/misc/stringops.cpp +++ b/components/misc/stringops.cpp @@ -6,7 +6,6 @@ #include #include -#include @@ -92,10 +91,6 @@ bool stringCompareNoCase (std::string first, std::string second) else return false; } -bool compare_string_ci(std::string str1, std::string str2) -{ - boost::algorithm::to_lower(str1); - return str1 == str2; -} + } diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp index 6403a7128..4dbfd40d4 100644 --- a/components/misc/stringops.hpp +++ b/components/misc/stringops.hpp @@ -18,13 +18,12 @@ bool ibegins(const char* str1, const char* str2); /// Case insensitive, returns true if str1 ends with substring str2 bool iends(const char* str1, const char* str2); - +/// std::string toLower (const std::string& name); +/// Case fold compare bool stringCompareNoCase (std::string first, std::string second); -bool compare_string_ci (std::string first, std::string second); - } #endif