Skip to content

Commit

Permalink
Merge pull request xbmc#6518 from denizt/decouple
Browse files Browse the repository at this point in the history
Decouple Util and StringUtil
  • Loading branch information
MartijnKaijser committed Mar 3, 2015
2 parents dad4b5e + a505e20 commit 8bd38ef
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 13 deletions.
13 changes: 0 additions & 13 deletions xbmc/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <vector>
#include <string.h>
#include <stdint.h>
#include "utils/StringUtils.h"
#include "MediaSource.h"

#define ARRAY_SIZE(X) (sizeof(X)/sizeof((X)[0]))
Expand All @@ -37,18 +36,6 @@
class CFileItemList;
class CURL;

struct sortstringbyname
{
bool operator()(const std::string& strItem1, const std::string& strItem2)
{
std::string strLine1 = strItem1;
std::string strLine2 = strItem2;
StringUtils::ToLower(strLine1);
StringUtils::ToLower(strLine2);
return strcmp(strLine1.c_str(), strLine2.c_str()) < 0;
}
};

struct ExternalStreamInfo
{
std::string name;
Expand Down
1 change: 1 addition & 0 deletions xbmc/addons/AddonCallbacksPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "AddonCallbacksPVR.h"
#include "settings/AdvancedSettings.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "dialogs/GUIDialogKaiToast.h"

#include "epg/EpgContainer.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/dialogs/GUIDialogFileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "GUIDialogFileBrowser.h"
#include "Util.h"
#include "utils/URIUtils.h"
#include "utils/StringUtils.h"
#include "network/GUIDialogNetworkSetup.h"
#include "GUIDialogMediaSource.h"
#include "GUIDialogContextMenu.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/filesystem/AFPFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "settings/AdvancedSettings.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/TimeUtils.h"

using namespace XFILE;
Expand Down
1 change: 1 addition & 0 deletions xbmc/filesystem/HDHomeRunFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "HDHomeRunFile.h"
#include "utils/TimeUtils.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "Util.h"
#include "DllHDHomeRun.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/filesystem/IDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "URL.h"
#include "PasswordManager.h"
#include "utils/URIUtils.h"
#include "utils/StringUtils.h"

using namespace XFILE;

Expand Down
1 change: 1 addition & 0 deletions xbmc/filesystem/PVRDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Util.h"
#include "URL.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "guilib/LocalizeStrings.h"

Expand Down
1 change: 1 addition & 0 deletions xbmc/playlists/PlayListB4S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "music/tags/MusicInfoTag.h"
#include "filesystem/File.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/XMLUtils.h"

Expand Down
1 change: 1 addition & 0 deletions xbmc/playlists/PlayListWPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "settings/AdvancedSettings.h"
#include "filesystem/File.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/XMLUtils.h"

Expand Down
1 change: 1 addition & 0 deletions xbmc/playlists/PlayListXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Util.h"
#include "utils/RegExp.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/XMLUtils.h"
#include "utils/Variant.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "settings/lib/Setting.h"
#include "storage/MediaManager.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"

#define CONTROL_PROFILE_IMAGE CONTROL_SETTINGS_CUSTOM + 1
Expand Down
1 change: 1 addition & 0 deletions xbmc/pvr/addons/PVRClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "utils/log.h"
#include "utils/StringUtils.h"

#include <assert.h>

Expand Down
1 change: 1 addition & 0 deletions xbmc/pvr/windows/GUIWindowPVRChannels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "epg/EpgContainer.h"
#include "settings/Settings.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "threads/SingleLock.h"

using namespace PVR;
Expand Down
1 change: 1 addition & 0 deletions xbmc/utils/HttpRangeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "HttpRangeUtils.h"
#include "Util.h"
#include "network/httprequesthandler/IHTTPRequestHandler.h"
#include "utils/StringUtils.h"
#include "utils/Variant.h"

#include <algorithm>
Expand Down
8 changes: 8 additions & 0 deletions xbmc/utils/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,11 @@ class StringUtils
private:
static std::string m_lastUUID;
};

struct sortstringbyname
{
bool operator()(const std::string& strItem1, const std::string& strItem2)
{
return StringUtils::CompareNoCase(strItem1, strItem2) < 0;
}
};
14 changes: 14 additions & 0 deletions xbmc/utils/test/TestStringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "utils/StringUtils.h"
#include <algorithm>

#include "gtest/gtest.h"

Expand Down Expand Up @@ -478,3 +479,16 @@ TEST(TestStringUtils, Paramify)
std::string result = StringUtils::Paramify(input);
EXPECT_STREQ(ref, result.c_str());
}

TEST(TestStringUtils, sortstringbyname)
{
std::vector<std::string> strarray;
strarray.push_back("B");
strarray.push_back("c");
strarray.push_back("a");
std::sort(strarray.begin(), strarray.end(), sortstringbyname());

EXPECT_STREQ("a", strarray[0].c_str());
EXPECT_STREQ("B", strarray[1].c_str());
EXPECT_STREQ("c", strarray[2].c_str());
}

0 comments on commit 8bd38ef

Please sign in to comment.