Mercurial > libbase64
diff base64.hpp @ 17:0b524d7b7669
Use C++17 std::string_view
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 28 Jun 2018 22:05:49 +0200 |
parents | 10729ad33e95 |
children | bdc4fde21426 |
line wrap: on
line diff
--- a/base64.hpp Thu May 24 10:55:47 2018 +0200 +++ b/base64.hpp Thu Jun 28 22:05:49 2018 +0200 @@ -58,6 +58,7 @@ #include <cctype> #include <stdexcept> #include <string> +#include <string_view> /** * \brief main %base64 namespace. @@ -96,7 +97,7 @@ */ inline char lookup(unsigned char value) noexcept { - static const char* table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + static std::string_view table("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); assert(value < 64); @@ -213,7 +214,7 @@ * \param input the input string * \return the %base64 formatted string */ -inline std::string encode(const std::string& input) +inline std::string encode(std::string_view input) { std::string result; @@ -229,7 +230,7 @@ * \return the original string * \throw std::invalid_argument on bad %base64 string */ -inline std::string decode(const std::string& input) +inline std::string decode(std::string_view input) { std::string result;