Exiv2
futils.hpp
Go to the documentation of this file.
1 // ********************************************************* -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2018 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  */
28 #ifndef FUTILS_HPP_
29 #define FUTILS_HPP_
30 
31 #include "exiv2lib_export.h"
32 #include "config.h"
33 
34 #include <string>
35 
36 // namespace extensions
37 namespace Exiv2
38 {
40  enum EnVar
41  {
42  envHTTPPOST = 0,
43  envTIMEOUT = 1
44  };
46  enum Protocol
47  {
48  pFile = 0,
49  pHttp,
50  pFtp,
51  pHttps,
52  pSftp,
53  pSsh,
54  pFileUri,
55  pDataUri,
56  pStdin
57  };
58  // *********************************************************************
59  // free functions
66  EXIV2API std::string getEnv(int env_var);
67 
75  EXIV2API std::string urlencode(const char* str);
76 
86  EXIV2API char* urldecode(const char* str);
87 
92  EXIV2API void urldecode(std::string& str);
93 
105  EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize);
106 
116  EXIV2API long base64decode(const char* in, char* out, size_t out_size);
117 
123  EXIV2API Protocol fileProtocol(const std::string& path);
124 
125 #ifdef EXV_UNICODE_PATH
126 
130  EXIV2API Protocol fileProtocol(const std::wstring& wpath);
131 #endif
132 
145  EXIV2API bool fileExists(const std::string& path, bool ct = false);
146 
147 #ifdef EXV_UNICODE_PATH
148 
153  EXIV2API bool fileExists(const std::wstring& wpath, bool ct = false);
154 #endif
155 
162  EXIV2API std::string pathOfFileUrl(const std::string& url);
163 
164 #ifdef EXV_UNICODE_PATH
165 
169  EXIV2API std::wstring pathOfFileUrl(const std::wstring& wurl);
170 #endif
171 
176  EXIV2API std::string strError();
177 
179  EXIV2API std::string getProcessPath();
180 
189  class Uri
190  {
191  public:
192  // DATA
200 
202  static Uri EXIV2API Parse(const std::string& uri);
203 
205  static void EXIV2API Decode(Uri& uri);
206  };
207 
208 } // namespace Exiv2
209 
210 #endif // #ifndef FUTILS_HPP_
std::string Username
URL username.
Definition: futils.hpp:198
EXIV2API char * urldecode(const char *str)
Decode the input url.
Definition: futils.cpp:111
std::string Port
URL port.
Definition: futils.hpp:197
EXIV2API bool fileExists(const std::string &path, bool ct=false)
Test if a file exists.
Definition: futils.cpp:307
static Uri EXIV2API Parse(const std::string &uri)
Parse the input URL to the protocol, host, path, username, password.
Definition: futils.cpp:391
Protocol
the collection of protocols.
Definition: futils.hpp:46
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:138
std::string Path
URL file path.
Definition: futils.hpp:194
EnVar
the name of environmental variables.
Definition: futils.hpp:40
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:352
std::string QueryString
URL query string.
Definition: futils.hpp:193
IPTC string type.
Definition: types.hpp:147
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:212
std::string Password
URL password.
Definition: futils.hpp:199
EXIV2API Protocol fileProtocol(const std::string &path)
Return the protocol of the path.
Definition: futils.cpp:257
EXIV2API std::string urlencode(const char *str)
Encode the input url.
Definition: futils.cpp:90
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
A container for URL components. It also provides the method to parse a URL to get the protocol...
Definition: futils.hpp:189
std::string Protocol
URL protocol.
Definition: futils.hpp:195
std::string Host
URL host.
Definition: futils.hpp:196
EXIV2API std::string getEnv(int env_var)
Return the value of environmental variable.
Definition: futils.cpp:70
EXIV2API std::string getProcessPath()
Return the path of the current process.
Definition: futils.cpp:470
static void EXIV2API Decode(Uri &uri)
Decode the url components.
Definition: futils.cpp:382
EXIV2API std::string pathOfFileUrl(const std::string &url)
Get the path of file URL.
Definition: futils.cpp:337