Skip to content
Snippets Groups Projects
Commit f030650a authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[BL] Use boost for case insensitive comparison.

parent 011bb250
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
namespace BaseLib namespace BaseLib
{ {
...@@ -116,10 +117,7 @@ std::string getFileExtension(const std::string &path) ...@@ -116,10 +117,7 @@ std::string getFileExtension(const std::string &path)
bool hasFileExtension(std::string const& extension, std::string const& filename) bool hasFileExtension(std::string const& extension, std::string const& filename)
{ {
std::string ext = stringToUpper(extension); // Copy for modification. return boost::iequals(extension, getFileExtension(filename));
std::string file_ext = stringToUpper(getFileExtension(filename));
return ext == file_ext;
} }
std::string copyPathToFileName(const std::string &file_name, std::string copyPathToFileName(const std::string &file_name,
......
...@@ -129,8 +129,7 @@ std::string getFileExtension(std::string const& filename); ...@@ -129,8 +129,7 @@ std::string getFileExtension(std::string const& filename);
/** /**
* Compares filename's extension with query extension. The comparison is case * Compares filename's extension with query extension. The comparison is case
* insensitive done by converting to upper case with the std::toupper() * insensitive.
* function.
*/ */
bool hasFileExtension(std::string const& extension, bool hasFileExtension(std::string const& extension,
std::string const& filename); std::string const& filename);
......
...@@ -72,13 +72,6 @@ void simplify(std::string &str) ...@@ -72,13 +72,6 @@ void simplify(std::string &str)
); );
} }
std::string stringToUpper(std::string const& str)
{
std::string s = str;
std::transform(s.begin(), s.end(), s.begin(), (int(*)(int)) std::toupper);
return s;
}
std::string padLeft(std::string const& str, int maxlen, char ch) std::string padLeft(std::string const& str, int maxlen, char ch)
{ {
std::stringstream ss(str); std::stringstream ss(str);
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <ctype.h>
namespace BaseLib { namespace BaseLib {
...@@ -69,13 +68,6 @@ void trim(std::string &str, char ch=' '); ...@@ -69,13 +68,6 @@ void trim(std::string &str, char ch=' ');
*/ */
void simplify(std::string &str); void simplify(std::string &str);
/**
* Returns same string with all characters in upper case.
*
* This uses std::toupper() function, and does not care about unicode.
*/
std::string stringToUpper(std::string const& str);
/** /**
* Returns the string which is right aligned with padding on the left. * Returns the string which is right aligned with padding on the left.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment