@@ -58,7 +58,7 @@ namespace fs = std::filesystem;
5858
5959#endif
6060
61- namespace Exiv2 {
61+ namespace {
6262constexpr std::array ENVARDEF{
6363 " /exiv2.php" ,
6464 " 40" ,
@@ -68,6 +68,25 @@ constexpr std::array ENVARKEY{
6868 " EXIV2_TIMEOUT" ,
6969}; // / @brief request keys for http exiv2 handler and time-out
7070
71+ // / @brief Convert an integer value to its hex character.
72+ char to_hex (char code) {
73+ static const char hex[] = " 0123456789abcdef" ;
74+ return hex[code & 15 ];
75+ }
76+
77+ // / @brief Convert a hex character to its integer value.
78+ char from_hex (char ch) {
79+ return 0xF & (isdigit (ch) ? ch - ' 0' : static_cast <char >(tolower (ch)) - ' a' + 10 );
80+ }
81+
82+ constexpr char base64_encode[] = {
83+ ' A' , ' B' , ' C' , ' D' , ' E' , ' F' , ' G' , ' H' , ' I' , ' J' , ' K' , ' L' , ' M' , ' N' , ' O' , ' P' , ' Q' , ' R' , ' S' , ' T' , ' U' , ' V' ,
84+ ' W' , ' X' , ' Y' , ' Z' , ' a' , ' b' , ' c' , ' d' , ' e' , ' f' , ' g' , ' h' , ' i' , ' j' , ' k' , ' l' , ' m' , ' n' , ' o' , ' p' , ' q' , ' r' ,
85+ ' s' , ' t' , ' u' , ' v' , ' w' , ' x' , ' y' , ' z' , ' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' , ' +' , ' /' ,
86+ };
87+ } // namespace
88+
89+ namespace Exiv2 {
7190// *****************************************************************************
7291// free functions
7392std::string getEnv (int env_var) {
@@ -78,17 +97,6 @@ std::string getEnv(int env_var) {
7897 return getenv (ENVARKEY[env_var]) ? getenv (ENVARKEY[env_var]) : ENVARDEF[env_var];
7998}
8099
81- // / @brief Convert an integer value to its hex character.
82- static char to_hex (char code) {
83- static const char hex[] = " 0123456789abcdef" ;
84- return hex[code & 15 ];
85- }
86-
87- // / @brief Convert a hex character to its integer value.
88- static char from_hex (char ch) {
89- return 0xF & (isdigit (ch) ? ch - ' 0' : static_cast <char >(tolower (ch)) - ' a' + 10 );
90- }
91-
92100std::string urlencode (const std::string& str) {
93101 std::string encoded;
94102 encoded.reserve (str.size () * 3 );
@@ -128,11 +136,6 @@ void urldecode(std::string& str) {
128136}
129137
130138// https://stackoverflow.com/questions/342409/how-do-i-base64-encode-decode-in-c
131- static constexpr char base64_encode[] = {
132- ' A' , ' B' , ' C' , ' D' , ' E' , ' F' , ' G' , ' H' , ' I' , ' J' , ' K' , ' L' , ' M' , ' N' , ' O' , ' P' , ' Q' , ' R' , ' S' , ' T' , ' U' , ' V' ,
133- ' W' , ' X' , ' Y' , ' Z' , ' a' , ' b' , ' c' , ' d' , ' e' , ' f' , ' g' , ' h' , ' i' , ' j' , ' k' , ' l' , ' m' , ' n' , ' o' , ' p' , ' q' , ' r' ,
134- ' s' , ' t' , ' u' , ' v' , ' w' , ' x' , ' y' , ' z' , ' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' , ' +' , ' /' };
135-
136139int base64encode (const void * data_buf, size_t dataLength, char * result, size_t resultSize) {
137140 auto encoding_table = base64_encode;
138141
0 commit comments