Exiv2
futils.hpp
1// ***************************************************************** -*- C++ -*-
2/*
3 * Copyright (C) 2004-2021 Exiv2 authors
4 * This program is part of the Exiv2 distribution.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19 */
20#ifndef FUTILS_HPP_
21#define FUTILS_HPP_
22
23#include "exiv2lib_export.h"
24#include "config.h"
25
26#include <string>
27
28// namespace extensions
29namespace Exiv2
30{
32 enum EnVar
33 {
34 envHTTPPOST = 0,
35 envTIMEOUT = 1
36 };
39 {
40 pFile = 0,
41 pHttp,
42 pFtp,
43 pHttps,
44 pSftp,
45 pFileUri,
46 pDataUri,
47 pStdin
48 };
49 // *********************************************************************
50 // free functions
57 EXIV2API std::string getEnv(int env_var);
58
66 EXIV2API std::string urlencode(const char* str);
67
77 EXIV2API char* urldecode(const char* str);
78
83 EXIV2API void urldecode(std::string& str);
84
96 EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize);
97
107 EXIV2API long base64decode(const char* in, char* out, size_t out_size);
108
114 EXIV2API Protocol fileProtocol(const std::string& path);
115
116#ifdef EXV_UNICODE_PATH
121 EXIV2API Protocol fileProtocol(const std::wstring& wpath);
122#endif
123
136 EXIV2API bool fileExists(const std::string& path, bool ct = false);
137
138#ifdef EXV_UNICODE_PATH
144 EXIV2API bool fileExists(const std::wstring& wpath, bool ct = false);
145#endif
146
153 EXIV2API std::string pathOfFileUrl(const std::string& url);
154
155#ifdef EXV_UNICODE_PATH
160 EXIV2API std::wstring pathOfFileUrl(const std::wstring& wurl);
161#endif
162
167 EXIV2API std::string strError();
168
170 EXIV2API std::string getProcessPath();
171
180 class Uri
181 {
182 public:
183 // DATA
184 std::string QueryString;
185 std::string Path;
186 std::string Protocol;
187 std::string Host;
188 std::string Port;
189 std::string Username;
190 std::string Password;
191
193 static Uri EXIV2API Parse(const std::string& uri);
194
196 static void EXIV2API Decode(Uri& uri);
197 };
198
199} // namespace Exiv2
200
201#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:181
std::string Host
URL host.
Definition: futils.hpp:187
static void EXIV2API Decode(Uri &uri)
Decode the url components.
Definition: futils.cpp:358
std::string Port
URL port.
Definition: futils.hpp:188
std::string Password
URL password.
Definition: futils.hpp:190
static Uri EXIV2API Parse(const std::string &uri)
Parse the input URL to the protocol, host, path, username, password.
Definition: futils.cpp:367
std::string Path
URL file path.
Definition: futils.hpp:185
std::string Username
URL username.
Definition: futils.hpp:189
std::string Protocol
URL protocol.
Definition: futils.hpp:186
std::string QueryString
URL query string.
Definition: futils.hpp:184
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
EXIV2API std::string urlencode(const char *str)
Encode the input url.
Definition: futils.cpp:104
Protocol
the collection of protocols.
Definition: futils.hpp:39
EnVar
the name of environmental variables.
Definition: futils.hpp:33
EXIV2API long base64decode(const char *in, char *out, size_t out_size)
Decode base64 data and put the resulting string in out.
Definition: futils.cpp:187
EXIV2API std::string getEnv(int env_var)
Return the value of environmental variable.
Definition: futils.cpp:84
EXIV2API bool fileExists(const std::string &path, bool ct=false)
Test if a file exists.
Definition: futils.cpp:283
EXIV2API char * urldecode(const char *str)
Decode the input url.
Definition: futils.cpp:125
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:158
EXIV2API std::string pathOfFileUrl(const std::string &url)
Get the path of file URL.
Definition: futils.cpp:313
EXIV2API Protocol fileProtocol(const std::string &path)
Return the protocol of the path.
Definition: futils.cpp:227
EXIV2API std::string getProcessPath()
Return the path of the current process.
Definition: futils.cpp:446
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:328