summaryrefslogtreecommitdiffstats
path: root/src/Common/Hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/Hash.h')
-rw-r--r--src/Common/Hash.h41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/Common/Hash.h b/src/Common/Hash.h
index db581b7..f92779e 100644
--- a/src/Common/Hash.h
+++ b/src/Common/Hash.h
@@ -40,20 +40,23 @@ class MAD_COMMON_EXPORT Hash {
class MAD_COMMON_EXPORT Hashes {
private:
- std::map<std::string, unsigned int> map;
- std::vector<std::string> list;
+ std::map<Core::String, unsigned int> map;
+ std::vector<Core::String> list;
- void addHash(const std::string &name, unsigned id) {
- map.insert(std::make_pair(boost::algorithm::to_lower_copy(name), id));
+ void addHash(const Core::String &name, unsigned id) {
+ Core::String lowerName = name;
+ lowerName.toLower();
+
+ map.insert(std::make_pair(lowerName, id));
list.push_back(name);
}
public:
- const std::vector<std::string>& getList() const {
+ const std::vector<Core::String>& getList() const {
return list;
}
- const std::map<std::string, unsigned int>& getMap() const {
+ const std::map<Core::String, unsigned int>& getMap() const {
return map;
}
@@ -63,30 +66,38 @@ class MAD_COMMON_EXPORT Hash {
static const Hashes hashes;
public:
- static const std::vector<std::string>& getHashList() {
+ static const std::vector<Core::String>& getHashList() {
return hashes.getList();
}
- static bool isHashSupported(const std::string &method) {
- return (hashes.getMap().find(boost::algorithm::to_lower_copy(method)) != hashes.getMap().end());
+ static bool isHashSupported(const Core::String &method) {
+ Core::String lowerMethod = method;
+ lowerMethod.toLower();
+
+ return (hashes.getMap().find(lowerMethod) != hashes.getMap().end());
}
static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, unsigned int method) throw (Core::Exception);
- static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, const std::string &method) throw (Core::Exception) {
- std::map<std::string, unsigned int>::const_iterator methodIt = hashes.getMap().find(boost::algorithm::to_lower_copy(method));
+ static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, const Core::String &method) throw (Core::Exception) {
+ Core::String lowerMethod = method;
+ lowerMethod.toLower();
+
+ std::map<Core::String, unsigned int>::const_iterator methodIt = hashes.getMap().find(lowerMethod);
if(methodIt == hashes.getMap().end())
throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
return hash(in, methodIt->second);
}
- static std::vector<boost::uint8_t> hash(const std::string &in, unsigned int method) throw (Core::Exception) {
- return hash(std::vector<boost::uint8_t>(in.begin(), in.end()), method);
+ static std::vector<boost::uint8_t> hash(const Core::String &in, unsigned int method) throw (Core::Exception) {
+ std::string str = in.extractUTF8();
+ return hash(std::vector<boost::uint8_t>(str.begin(), str.end()), method);
}
- static std::vector<boost::uint8_t> hash(const std::string &in, const std::string &method) throw (Core::Exception) {
- return hash(std::vector<boost::uint8_t>(in.begin(), in.end()), method);
+ static std::vector<boost::uint8_t> hash(const Core::String &in, const Core::String &method) throw (Core::Exception) {
+ std::string str = in.extractUTF8();
+ return hash(std::vector<boost::uint8_t>(str.begin(), str.end()), method);
}
};