diff options
author | lloyd <[email protected]> | 2009-06-04 16:06:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-06-04 16:06:59 +0000 |
commit | 9de911f55808e84e8d14efbecf8379c25afb9d50 (patch) | |
tree | da2d3825ed58833ae40fc0ffa3e704473aafd0e0 /src/utils | |
parent | a96eae0b3394b64aea544f9f0ce4664d3b4a5c58 (diff) | |
parent | 3afb86663583b982e1eab8f46d07fc3d51260602 (diff) |
propagate from branch 'net.randombit.botan' (head 6a746ccf1e957dba703e65372050a7bd4d6b117d)
to branch 'net.randombit.botan.c++0x' (head f54bb7b391eb3b71f380a68ddd460debdc31545d)
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/info.txt | 1 | ||||
-rw-r--r-- | src/utils/mutex.h | 56 | ||||
-rw-r--r-- | src/utils/parsing.cpp | 36 | ||||
-rw-r--r-- | src/utils/scan_name.cpp | 1 | ||||
-rw-r--r-- | src/utils/stl_util.h | 16 |
5 files changed, 19 insertions, 91 deletions
diff --git a/src/utils/info.txt b/src/utils/info.txt index ffc19c852..815ad4efc 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -27,7 +27,6 @@ exceptn.h loadstor.h mem_ops.h mlock.cpp -mutex.h parsing.cpp parsing.h rotate.h diff --git a/src/utils/mutex.h b/src/utils/mutex.h deleted file mode 100644 index a04ff83c9..000000000 --- a/src/utils/mutex.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Mutex -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_MUTEX_H__ -#define BOTAN_MUTEX_H__ - -#include <botan/exceptn.h> - -namespace Botan { - -/* -* Mutex Base Class -*/ -class BOTAN_DLL Mutex - { - public: - virtual void lock() = 0; - virtual void unlock() = 0; - virtual ~Mutex() {} - }; - -/* -* Mutex Factory -*/ -class BOTAN_DLL Mutex_Factory - { - public: - virtual Mutex* make() = 0; - virtual ~Mutex_Factory() {} - }; - -/* -* Mutex Holding Class -*/ -class BOTAN_DLL Mutex_Holder - { - public: - Mutex_Holder(Mutex* m) : mux(m) - { - if(!mux) - throw Invalid_Argument("Mutex_Holder: Argument was NULL"); - mux->lock(); - } - - ~Mutex_Holder() { mux->unlock(); } - private: - Mutex* mux; - }; - -} - -#endif diff --git a/src/utils/parsing.cpp b/src/utils/parsing.cpp index bdb9e79dc..556e2f65c 100644 --- a/src/utils/parsing.cpp +++ b/src/utils/parsing.cpp @@ -19,11 +19,11 @@ u32bit to_u32bit(const std::string& number) { u32bit n = 0; - for(std::string::const_iterator j = number.begin(); j != number.end(); ++j) + for(auto i = number.begin(); i != number.end(); ++i) { const u32bit OVERFLOW_MARK = 0xFFFFFFFF / 10; - byte digit = Charset::char2digit(*j); + byte digit = Charset::char2digit(*i); if((n > OVERFLOW_MARK) || (n == OVERFLOW_MARK && digit > 5)) throw Decoding_Error("to_u32bit: Integer overflow"); @@ -103,15 +103,15 @@ std::vector<std::string> parse_algorithm_name(const std::string& namex) elems.push_back(name.substr(0, name.find('('))); name = name.substr(name.find('(')); - for(std::string::const_iterator j = name.begin(); j != name.end(); ++j) + for(auto i = name.begin(); i != name.end(); ++i) { - char c = *j; + char c = *i; if(c == '(') ++level; if(c == ')') { - if(level == 1 && j == name.end() - 1) + if(level == 1 && i == name.end() - 1) { if(elems.size() == 1) elems.push_back(substring.substr(1)); @@ -120,7 +120,7 @@ std::vector<std::string> parse_algorithm_name(const std::string& namex) return elems; } - if(level == 0 || (level == 1 && j != name.end() - 1)) + if(level == 0 || (level == 1 && i != name.end() - 1)) throw Invalid_Algorithm_Name(namex); --level; } @@ -152,16 +152,16 @@ std::vector<std::string> split_on(const std::string& str, char delim) if(str == "") return elems; std::string substr; - for(std::string::const_iterator j = str.begin(); j != str.end(); ++j) + for(auto i = str.begin(); i != str.end(); ++i) { - if(*j == delim) + if(*i == delim) { if(substr != "") elems.push_back(substr); substr.clear(); } else - substr += *j; + substr += *i; } if(substr == "") @@ -179,9 +179,9 @@ std::vector<u32bit> parse_asn1_oid(const std::string& oid) std::string substring; std::vector<u32bit> oid_elems; - for(std::string::const_iterator j = oid.begin(); j != oid.end(); ++j) + for(auto i = oid.begin(); i != oid.end(); ++i) { - char c = *j; + char c = *i; if(c == '.') { @@ -209,8 +209,8 @@ std::vector<u32bit> parse_asn1_oid(const std::string& oid) */ bool x500_name_cmp(const std::string& name1, const std::string& name2) { - std::string::const_iterator p1 = name1.begin(); - std::string::const_iterator p2 = name2.begin(); + auto p1 = name1.begin(); + auto p2 = name2.begin(); while((p1 != name1.end()) && Charset::is_space(*p1)) ++p1; while((p2 != name2.end()) && Charset::is_space(*p2)) ++p2; @@ -255,9 +255,9 @@ u32bit string_to_ipv4(const std::string& str) u32bit ip = 0; - for(size_t j = 0; j != parts.size(); j++) + for(auto part = parts.begin(); part != parts.end(); ++part) { - u32bit octet = to_u32bit(parts[j]); + u32bit octet = to_u32bit(*part); if(octet > 255) throw Decoding_Error("Invalid IP string " + str); @@ -275,11 +275,11 @@ std::string ipv4_to_string(u32bit ip) { std::string str; - for(size_t j = 0; j != sizeof(ip); j++) + for(size_t i = 0; i != sizeof(ip); i++) { - if(j) + if(i) str += "."; - str += to_string(get_byte(j, ip)); + str += to_string(get_byte(i, ip)); } return str; diff --git a/src/utils/scan_name.cpp b/src/utils/scan_name.cpp index 3425425e2..92fded3c4 100644 --- a/src/utils/scan_name.cpp +++ b/src/utils/scan_name.cpp @@ -8,6 +8,7 @@ SCAN Name Abstraction #include <botan/scan_name.h> #include <botan/parsing.h> #include <botan/libstate.h> +#include <botan/exceptn.h> #include <stdexcept> #include <iostream> diff --git a/src/utils/stl_util.h b/src/utils/stl_util.h index 18c8b149b..fc4d4effe 100644 --- a/src/utils/stl_util.h +++ b/src/utils/stl_util.h @@ -13,22 +13,6 @@ namespace Botan { /* -* Copy-on-Predicate Algorithm -*/ -template<typename InputIterator, typename OutputIterator, typename Predicate> -OutputIterator copy_if(InputIterator current, InputIterator end, - OutputIterator dest, Predicate copy_p) - { - while(current != end) - { - if(copy_p(*current)) - *dest++ = *current; - ++current; - } - return dest; - } - -/* * Searching through a std::map */ template<typename K, typename V> |