futils.hpp
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#ifndef FUTILS_HPP_
#define FUTILS_HPP_
#include "exiv2lib_export.h"
#include "config.h"
#include <string>
// namespace extensions
namespace Exiv2
{
enum EnVar
{
envHTTPPOST = 0,
envTIMEOUT = 1
};
enum Protocol
{
pFile = 0,
pHttp,
pFtp,
pHttps,
pSftp,
pSsh,
pFileUri,
pDataUri,
pStdin
};
// *********************************************************************
// free functions
EXIV2API std::string getEnv(int env_var);
EXIV2API std::string urlencode(const char* str);
EXIV2API char* urldecode(const char* str);
EXIV2API void urldecode(std::string& str);
EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize);
EXIV2API long base64decode(const char* in, char* out, size_t out_size);
EXIV2API Protocol fileProtocol(const std::string& path);
#ifdef EXV_UNICODE_PATH
EXIV2API Protocol fileProtocol(const std::wstring& wpath);
#endif
EXIV2API bool fileExists(const std::string& path, bool ct = false);
#ifdef EXV_UNICODE_PATH
EXIV2API bool fileExists(const std::wstring& wpath, bool ct = false);
#endif
EXIV2API std::string pathOfFileUrl(const std::string& url);
#ifdef EXV_UNICODE_PATH
EXIV2API std::wstring pathOfFileUrl(const std::wstring& wurl);
#endif
EXIV2API std::string strError();
EXIV2API std::string getProcessPath();
class Uri
{
public:
// DATA
std::string QueryString;
std::string Path;
std::string Protocol;
std::string Host;
std::string Port;
std::string Username;
std::string Password;
static Uri EXIV2API Parse(const std::string& uri);
static void EXIV2API Decode(Uri& uri);
};
} // namespace Exiv2
#endif // #ifndef FUTILS_HPP_
Exiv2::Uri
A container for URL components. It also provides the method to parse a URL to get the protocol,...
Definition: futils.hpp:182
Exiv2::Uri::Host
std::string Host
URL host.
Definition: futils.hpp:188
Exiv2::Uri::Decode
static void EXIV2API Decode(Uri &uri)
Decode the url components.
Definition: futils.cpp:346
Exiv2::Uri::Port
std::string Port
URL port.
Definition: futils.hpp:189
Exiv2::Uri::Password
std::string Password
URL password.
Definition: futils.hpp:191
Exiv2::Uri::Parse
static Uri EXIV2API Parse(const std::string &uri)
Parse the input URL to the protocol, host, path, username, password.
Definition: futils.cpp:355
Exiv2::Uri::Path
std::string Path
URL file path.
Definition: futils.hpp:186
Exiv2::Uri::Username
std::string Username
URL username.
Definition: futils.hpp:190
Exiv2::Uri::Protocol
std::string Protocol
URL protocol.
Definition: futils.hpp:187
Exiv2::Uri::QueryString
std::string QueryString
URL query string.
Definition: futils.hpp:185
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::urlencode
EXIV2API std::string urlencode(const char *str)
Encode the input url.
Definition: futils.cpp:94
Exiv2::Protocol
Protocol
the collection of protocols.
Definition: futils.hpp:39
Exiv2::EnVar
EnVar
the name of environmental variables.
Definition: futils.hpp:33
Exiv2::base64decode
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:181
Exiv2::getEnv
EXIV2API std::string getEnv(int env_var)
Return the value of environmental variable.
Definition: futils.cpp:74
Exiv2::fileExists
EXIV2API bool fileExists(const std::string &path, bool ct=false)
Test if a file exists.
Definition: futils.cpp:271
Exiv2::urldecode
EXIV2API char * urldecode(const char *str)
Decode the input url.
Definition: futils.cpp:115
Exiv2::base64encode
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:152
Exiv2::pathOfFileUrl
EXIV2API std::string pathOfFileUrl(const std::string &url)
Get the path of file URL.
Definition: futils.cpp:301
Exiv2::fileProtocol
EXIV2API Protocol fileProtocol(const std::string &path)
Return the protocol of the path.
Definition: futils.cpp:221
Exiv2::getProcessPath
EXIV2API std::string getProcessPath()
Return the path of the current process.
Definition: futils.cpp:434
Exiv2::strError
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:316