Exiv2
Loading...
Searching...
No Matches
futils.hpp
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef FUTILS_HPP_
4#define FUTILS_HPP_
5
6#include "config.h"
7#include "exiv2lib_export.h"
8
9#include <string>
10
11// namespace extensions
12namespace Exiv2 {
14enum EnVar { envHTTPPOST = 0, envTIMEOUT = 1 };
16enum Protocol { pFile = 0, pHttp, pFtp, pHttps, pSftp, pFileUri, pDataUri, pStdin };
17// *********************************************************************
18// free functions
25EXIV2API std::string getEnv(int env_var);
26
34EXIV2API std::string urlencode(const std::string& str);
35
40EXIV2API void urldecode(std::string& str);
41
53EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize);
54
64EXIV2API size_t base64decode(const char* in, char* out, size_t out_size);
65
71EXIV2API Protocol fileProtocol(const std::string& path);
72
84EXIV2API bool fileExists(const std::string& path);
85
90EXIV2API std::string strError();
91
93EXIV2API std::string getProcessPath();
94
103class Uri {
104 public:
105 // DATA
106 std::string QueryString;
107 std::string Path;
108 std::string Protocol;
109 std::string Host;
110 std::string Port;
111 std::string Username;
112 std::string Password;
113
115 static Uri EXIV2API Parse(const std::string& uri);
116
118 static void EXIV2API Decode(Uri& uri);
119};
120
121} // namespace Exiv2
122
123#endif // #ifndef FUTILS_HPP_
A container for URL components. It also provides the method to parse a URL to get the protocol,...
Definition futils.hpp:103
std::string Host
URL host.
Definition futils.hpp:109
static void EXIV2API Decode(Uri &uri)
Decode the url components.
Definition futils.cpp:269
std::string Port
URL port.
Definition futils.hpp:110
std::string Password
URL password.
Definition futils.hpp:112
static Uri EXIV2API Parse(const std::string &uri)
Parse the input URL to the protocol, host, path, username, password.
Definition futils.cpp:277
std::string Path
URL file path.
Definition futils.hpp:107
std::string Username
URL username.
Definition futils.hpp:111
std::string Protocol
URL protocol.
Definition futils.hpp:108
std::string QueryString
URL query string.
Definition futils.hpp:106
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
EXIV2API std::string urlencode(const std::string &str)
Encode the input url.
Definition futils.cpp:96
Protocol
the collection of protocols.
Definition futils.hpp:16
EXIV2API size_t base64decode(const char *in, char *out, size_t out_size)
Decode base64 data and put the resulting string in out.
Definition futils.cpp:168
EnVar
the name of environmental variables.
Definition futils.hpp:14
EXIV2API bool fileExists(const std::string &path)
Test if a file exists.
Definition futils.cpp:232
EXIV2API std::string getEnv(int env_var)
Return the value of environmental variable.
Definition futils.cpp:77
EXIV2API int base64encode(const void *data_buf, size_t dataLength, char *result, size_t resultSize)
Encode in base64 the data in data_buf and put the resulting string in result.
Definition futils.cpp:140
EXIV2API void urldecode(std::string &str)
Like urlencode(char* str) but accept the input url in the std::string and modify it.
Definition futils.cpp:114
EXIV2API Protocol fileProtocol(const std::string &path)
Return the protocol of the path.
Definition futils.cpp:210
EXIV2API std::string getProcessPath()
Return the path of the current process.
Definition futils.cpp:354
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition futils.cpp:243