diff --git a/sprout/checksum/md5.hpp b/sprout/checksum/md5.hpp index 4c58364b..54519f60 100644 --- a/sprout/checksum/md5.hpp +++ b/sprout/checksum/md5.hpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include #include @@ -481,6 +483,74 @@ namespace sprout { return checksum(); } }; + + // + // make_md5 + // + template + inline SPROUT_CONSTEXPR sprout::md5::value_type + make_md5(ForwardIterator first, ForwardIterator last) { + return sprout::md5().c_process_block(first, last)(); + } + template + inline SPROUT_CONSTEXPR sprout::md5::value_type + make_md5(sprout::basic_string const& s) { + return sprout::md5().c_process_range(s)(); + } + inline SPROUT_CONSTEXPR sprout::md5::value_type + make_md5(char const* s) { + return sprout::md5().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::md5::value_type + make_md5(wchar_t const* s) { + return sprout::md5().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::md5::value_type + make_md5(char16_t const* s) { + return sprout::md5().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::md5::value_type + make_md5(char32_t const* s) { + return sprout::md5().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#endif } // namespace sprout +#if SPROUT_USE_USER_DEFINED_LITERALS + +namespace sprout { + namespace literals { + namespace checksum { + // + // _md5 + // + inline SPROUT_CONSTEXPR sprout::md5::value_type + operator"" _md5(char const* s, std::size_t size) { + return sprout::md5().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::md5::value_type + operator"" _md5(wchar_t const* s, std::size_t size) { + return sprout::md5().c_process_bytes(s, size)(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::md5::value_type + operator"" _md5(char16_t const* s, std::size_t size) { + return sprout::md5().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::md5::value_type + operator"" _md5(char32_t const* s, std::size_t size) { + return sprout::md5().c_process_bytes(s, size)(); + } +#endif + } // namespace checksum + + using sprout::literals::checksum::operator"" _md5; + } // namespace literals + + using sprout::literals::checksum::operator"" _md5; +} // namespace sprout + +#endif // #if SPROUT_USE_USER_DEFINED_LITERALS + #endif // #ifndef SPROUT_CHECKSUM_MD5_HPP diff --git a/sprout/checksum/sha1.hpp b/sprout/checksum/sha1.hpp index 9f8f4778..76fa81b6 100644 --- a/sprout/checksum/sha1.hpp +++ b/sprout/checksum/sha1.hpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include #include @@ -523,6 +525,74 @@ namespace sprout { return checksum(); } }; + + // + // make_sha1 + // + template + inline SPROUT_CONSTEXPR sprout::sha1::value_type + make_sha1(ForwardIterator first, ForwardIterator last) { + return sprout::sha1().c_process_block(first, last)(); + } + template + inline SPROUT_CONSTEXPR sprout::sha1::value_type + make_sha1(sprout::basic_string const& s) { + return sprout::sha1().c_process_range(s)(); + } + inline SPROUT_CONSTEXPR sprout::sha1::value_type + make_sha1(char const* s) { + return sprout::sha1().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sha1::value_type + make_sha1(wchar_t const* s) { + return sprout::sha1().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sha1::value_type + make_sha1(char16_t const* s) { + return sprout::sha1().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sha1::value_type + make_sha1(char32_t const* s) { + return sprout::sha1().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#endif } // namespace sprout +#if SPROUT_USE_USER_DEFINED_LITERALS + +namespace sprout { + namespace literals { + namespace checksum { + // + // _sha1 + // + inline SPROUT_CONSTEXPR sprout::sha1::value_type + operator"" _sha1(char const* s, std::size_t size) { + return sprout::sha1().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sha1::value_type + operator"" _sha1(wchar_t const* s, std::size_t size) { + return sprout::sha1().c_process_bytes(s, size)(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sha1::value_type + operator"" _sha1(char16_t const* s, std::size_t size) { + return sprout::sha1().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sha1::value_type + operator"" _sha1(char32_t const* s, std::size_t size) { + return sprout::sha1().c_process_bytes(s, size)(); + } +#endif + } // namespace checksum + + using sprout::literals::checksum::operator"" _sha1; + } // namespace literals + + using sprout::literals::checksum::operator"" _sha1; +} // namespace sprout + +#endif // #if SPROUT_USE_USER_DEFINED_LITERALS + #endif // #ifndef SPROUT_CHECKSUM_SHA1_HPP diff --git a/sprout/checksum/sum.hpp b/sprout/checksum/sum.hpp index f79b5524..2268ff68 100644 --- a/sprout/checksum/sum.hpp +++ b/sprout/checksum/sum.hpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -49,7 +51,9 @@ namespace sprout { ); } public: - SPROUT_CONSTEXPR sum_basic() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL + SPROUT_CONSTEXPR sum_basic() + : sum_() + {} sum_basic(sum_basic const&) = default; explicit SPROUT_CONSTEXPR sum_basic(sum_type sum) : sum_(sum) @@ -121,6 +125,182 @@ namespace sprout { typedef sprout::sum_basic<8> sum8; typedef sprout::sum_basic<16> sum16; typedef sprout::sum_basic<32> sum32; + + // + // make_sum8 + // + template + inline SPROUT_CONSTEXPR sprout::sum8::value_type + make_sum8(ForwardIterator first, ForwardIterator last) { + return sprout::sum8().c_process_block(first, last)(); + } + template + inline SPROUT_CONSTEXPR sprout::sum8::value_type + make_sum8(sprout::basic_string const& s) { + return sprout::sum8().c_process_range(s)(); + } + inline SPROUT_CONSTEXPR sprout::sum8::value_type + make_sum8(char const* s) { + return sprout::sum8().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sum8::value_type + make_sum8(wchar_t const* s) { + return sprout::sum8().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sum8::value_type + make_sum8(char16_t const* s) { + return sprout::sum8().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sum8::value_type + make_sum8(char32_t const* s) { + return sprout::sum8().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#endif + // + // make_sum16 + // + template + inline SPROUT_CONSTEXPR sprout::sum16::value_type + make_sum16(ForwardIterator first, ForwardIterator last) { + return sprout::sum16().c_process_block(first, last)(); + } + template + inline SPROUT_CONSTEXPR sprout::sum16::value_type + make_sum16(sprout::basic_string const& s) { + return sprout::sum16().c_process_range(s)(); + } + inline SPROUT_CONSTEXPR sprout::sum16::value_type + make_sum16(char const* s) { + return sprout::sum16().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sum16::value_type + make_sum16(wchar_t const* s) { + return sprout::sum16().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sum16::value_type + make_sum16(char16_t const* s) { + return sprout::sum16().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sum16::value_type + make_sum16(char32_t const* s) { + return sprout::sum16().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#endif + // + // make_sum32 + // + template + inline SPROUT_CONSTEXPR sprout::sum32::value_type + make_sum32(ForwardIterator first, ForwardIterator last) { + return sprout::sum32().c_process_block(first, last)(); + } + template + inline SPROUT_CONSTEXPR sprout::sum32::value_type + make_sum32(sprout::basic_string const& s) { + return sprout::sum32().c_process_range(s)(); + } + inline SPROUT_CONSTEXPR sprout::sum32::value_type + make_sum32(char const* s) { + return sprout::sum32().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sum32::value_type + make_sum32(wchar_t const* s) { + return sprout::sum32().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sum32::value_type + make_sum32(char16_t const* s) { + return sprout::sum32().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::sum32::value_type + make_sum32(char32_t const* s) { + return sprout::sum32().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#endif } // namespace sprout +#if SPROUT_USE_USER_DEFINED_LITERALS + +namespace sprout { + namespace literals { + namespace checksum { + // + // _sum8 + // + inline SPROUT_CONSTEXPR sprout::sum8::value_type + operator"" _sum8(char const* s, std::size_t size) { + return sprout::sum8().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sum8::value_type + operator"" _sum8(wchar_t const* s, std::size_t size) { + return sprout::sum8().c_process_bytes(s, size)(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sum8::value_type + operator"" _sum8(char16_t const* s, std::size_t size) { + return sprout::sum8().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sum8::value_type + operator"" _sum8(char32_t const* s, std::size_t size) { + return sprout::sum8().c_process_bytes(s, size)(); + } +#endif + // + // _sum16 + // + inline SPROUT_CONSTEXPR sprout::sum16::value_type + operator"" _sum16(char const* s, std::size_t size) { + return sprout::sum16().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sum16::value_type + operator"" _sum16(wchar_t const* s, std::size_t size) { + return sprout::sum16().c_process_bytes(s, size)(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sum16::value_type + operator"" _sum16(char16_t const* s, std::size_t size) { + return sprout::sum16().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sum16::value_type + operator"" _sum16(char32_t const* s, std::size_t size) { + return sprout::sum16().c_process_bytes(s, size)(); + } +#endif + // + // _sum32 + // + inline SPROUT_CONSTEXPR sprout::sum32::value_type + operator"" _sum32(char const* s, std::size_t size) { + return sprout::sum32().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sum32::value_type + operator"" _sum32(wchar_t const* s, std::size_t size) { + return sprout::sum32().c_process_bytes(s, size)(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::sum32::value_type + operator"" _sum32(char16_t const* s, std::size_t size) { + return sprout::sum32().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::sum32::value_type + operator"" _sum32(char32_t const* s, std::size_t size) { + return sprout::sum32().c_process_bytes(s, size)(); + } +#endif + } // namespace checksum + + using sprout::literals::checksum::operator"" _sum8; + using sprout::literals::checksum::operator"" _sum16; + using sprout::literals::checksum::operator"" _sum32; + } // namespace literals + + using sprout::literals::checksum::operator"" _sum8; + using sprout::literals::checksum::operator"" _sum16; + using sprout::literals::checksum::operator"" _sum32; +} // namespace sprout + +#endif // #if SPROUT_USE_USER_DEFINED_LITERALS + #endif // #ifndef SPROUT_CHECKSUM_SUM_HPP diff --git a/sprout/checksum/xor.hpp b/sprout/checksum/xor.hpp index 9b3c49a8..07d1f22e 100644 --- a/sprout/checksum/xor.hpp +++ b/sprout/checksum/xor.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -39,6 +41,9 @@ namespace sprout { ); } public: + SPROUT_CONSTEXPR xor8() + : sum_() + {} xor8(xor8 const&) = default; explicit SPROUT_CONSTEXPR xor8(sum_type sum) : sum_(sum) @@ -101,6 +106,74 @@ namespace sprout { return checksum(); } }; + + // + // make_xor8 + // + template + inline SPROUT_CONSTEXPR sprout::xor8::value_type + make_xor8(ForwardIterator first, ForwardIterator last) { + return sprout::xor8().c_process_block(first, last)(); + } + template + inline SPROUT_CONSTEXPR sprout::xor8::value_type + make_xor8(sprout::basic_string const& s) { + return sprout::xor8().c_process_range(s)(); + } + inline SPROUT_CONSTEXPR sprout::xor8::value_type + make_xor8(char const* s) { + return sprout::xor8().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::xor8::value_type + make_xor8(wchar_t const* s) { + return sprout::xor8().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::xor8::value_type + make_xor8(char16_t const* s) { + return sprout::xor8().c_process_bytes(s, sprout::char_traits::length(s))(); + } + inline SPROUT_CONSTEXPR sprout::xor8::value_type + make_xor8(char32_t const* s) { + return sprout::xor8().c_process_bytes(s, sprout::char_traits::length(s))(); + } +#endif } // namespace sprout +#if SPROUT_USE_USER_DEFINED_LITERALS + +namespace sprout { + namespace literals { + namespace checksum { + // + // _xor8 + // + inline SPROUT_CONSTEXPR sprout::xor8::value_type + operator"" _xor8(char const* s, std::size_t size) { + return sprout::xor8().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::xor8::value_type + operator"" _xor8(wchar_t const* s, std::size_t size) { + return sprout::xor8().c_process_bytes(s, size)(); + } +#if SPROUT_USE_UNICODE_LITERALS + inline SPROUT_CONSTEXPR sprout::xor8::value_type + operator"" _xor8(char16_t const* s, std::size_t size) { + return sprout::xor8().c_process_bytes(s, size)(); + } + inline SPROUT_CONSTEXPR sprout::xor8::value_type + operator"" _xor8(char32_t const* s, std::size_t size) { + return sprout::xor8().c_process_bytes(s, size)(); + } +#endif + } // namespace checksum + + using sprout::literals::checksum::operator"" _xor8; + } // namespace literals + + using sprout::literals::checksum::operator"" _xor8; +} // namespace sprout + +#endif // #if SPROUT_USE_USER_DEFINED_LITERALS + #endif // #ifndef SPROUT_CHECKSUM_XOR_HPP