Format futils.h for better readability (also pass clang-format to it)

v0.27.3
Luis Diaz Mas 7 years ago committed by Luis Díaz Más
parent c82d875707
commit 22d9ab82a7

@ -32,15 +32,30 @@
#include <string> #include <string>
// namespace extensions // namespace extensions
namespace Exiv2 { namespace Exiv2
{
//! the name of environmental variables. //! the name of environmental variables.
enum EnVar { envHTTPPOST = 0, envTIMEOUT = 1}; enum EnVar
{
envHTTPPOST = 0,
envTIMEOUT = 1
};
//! the collection of protocols. //! the collection of protocols.
enum Protocol { pFile = 0, pHttp, pFtp, pHttps, pSftp, pSsh, pFileUri, pDataUri, pStdin}; enum Protocol
// ********************************************************************* {
// free functions pFile = 0,
pHttp,
pFtp,
pHttps,
pSftp,
pSsh,
pFileUri,
pDataUri,
pStdin
};
// *********************************************************************
// free functions
/*! /*!
@brief Return the value of environmental variable. @brief Return the value of environmental variable.
@param var The name of environmental variable. @param var The name of environmental variable.
@ -48,25 +63,29 @@ namespace Exiv2 {
@throws std::out_of_range when an unexpected EnVar is given as input. @throws std::out_of_range when an unexpected EnVar is given as input.
*/ */
EXIV2API std::string getEnv(EnVar var); EXIV2API std::string getEnv(EnVar var);
/*! /*!
@brief Convert an integer value to its hex character. @brief Convert an integer value to its hex character.
@param code The integer value. @param code The integer value.
@return the input's hex character. @return the input's hex character.
*/ */
EXIV2API char to_hex(char code); EXIV2API char to_hex(char code);
/*! /*!
@brief Convert a hex character to its integer value. @brief Convert a hex character to its integer value.
@param ch The hex character. @param ch The hex character.
@return the input's integer value. @return the input's integer value.
*/ */
EXIV2API char from_hex(char ch); EXIV2API char from_hex(char ch);
/*! /*!
@brief Encode the input url. @brief Encode the input url.
@param str The url needs encoding. @param str The url needs encoding.
@return the url-encoded version of str. @return the url-encoded version of str.
@note Source: http://www.geekhideout.com/urlcode.shtml @note Source: http://www.geekhideout.com/urlcode.shtml
*/ */
EXIV2API std::string urlencode(const char *str); EXIV2API std::string urlencode(const char* str);
/*! /*!
@brief Decode the input url. @brief Decode the input url.
@param str The url needs decoding. @param str The url needs decoding.
@ -76,21 +95,25 @@ namespace Exiv2 {
Source: http://www.geekhideout.com/urlcode.shtml Source: http://www.geekhideout.com/urlcode.shtml
*/ */
EXIV2API char* urldecode(const char* str); EXIV2API char* urldecode(const char* str);
/*! /*!
@brief Like urlencode(char* str) but accept the input url in the std::string and modify it. @brief Like urlencode(char* str) but accept the input url in the std::string and modify it.
*/ */
EXIV2API void urldecode(std::string& str); EXIV2API void urldecode(std::string& str);
/*! /*!
@brief Encode in base64 the data in data_buf and put the resulting string in result. @brief Encode in base64 the data in data_buf and put the resulting string in result.
@param data_buf The data need to encode @param data_buf The data need to encode
@param dataLength Size in bytes of the in buffer @param dataLength Size in bytes of the in buffer
@param result The container for the result, NULL if it fails @param result The container for the result, NULL if it fails
@param resultSize Size in bytes of the out string, it should be at least ((dataLength + 2) / 3) * 4 + 1 @param resultSize Size in bytes of the out string, it should be at least
((dataLength + 2) / 3) * 4 + 1
@return 1 indicate success @return 1 indicate success
@note Source: http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64 @note Source: http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
*/ */
EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize); EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize);
/*! /*!
@brief Decode base64 data and put the resulting string in out. @brief Decode base64 data and put the resulting string in out.
@param in The data need to decode. @param in The data need to decode.
@ -100,13 +123,15 @@ namespace Exiv2 {
@note Source: https://github.com/davidgaleano/libwebsockets/blob/master/lib/base64-decode.c @note Source: https://github.com/davidgaleano/libwebsockets/blob/master/lib/base64-decode.c
*/ */
EXIV2API long base64decode(const char *in, char *out, size_t out_size); EXIV2API long base64decode(const char* in, char* out, size_t out_size);
/*! /*!
@brief Return the protocol of the path. @brief Return the protocol of the path.
@param path The path of file to extract the protocol. @param path The path of file to extract the protocol.
@return the protocol of the path. @return the protocol of the path.
*/ */
EXIV2API Protocol fileProtocol(const std::string& path); EXIV2API Protocol fileProtocol(const std::string& path);
#ifdef EXV_UNICODE_PATH #ifdef EXV_UNICODE_PATH
/*! /*!
@brief Like fileProtocol() but accept a unicode path in an std::wstring. @brief Like fileProtocol() but accept a unicode path in an std::wstring.
@ -114,6 +139,7 @@ namespace Exiv2 {
*/ */
EXIV2API Protocol fileProtocol(const std::wstring& wpath); EXIV2API Protocol fileProtocol(const std::wstring& wpath);
#endif #endif
/*! /*!
@brief Test if a file exists. @brief Test if a file exists.
@ -126,15 +152,17 @@ namespace Exiv2 {
and its type, see stat(2). <b>errno</b> is left unchanged and its type, see stat(2). <b>errno</b> is left unchanged
in case of an error. in case of an error.
*/ */
EXIV2API bool fileExists(const std::string& path, bool ct =false); EXIV2API bool fileExists(const std::string& path, bool ct = false);
#ifdef EXV_UNICODE_PATH #ifdef EXV_UNICODE_PATH
/*! /*!
@brief Like fileExists(const std::string& path, bool ct =false) but @brief Like fileExists(const std::string& path, bool ct =false) but
accepts a unicode path in an std::wstring. accepts a unicode path in an std::wstring.
@note This function is only available on Windows. @note This function is only available on Windows.
*/ */
EXIV2API bool fileExists(const std::wstring& wpath, bool ct =false); EXIV2API bool fileExists(const std::wstring& wpath, bool ct = false);
#endif #endif
/*! /*!
@brief Get the path of file URL. @brief Get the path of file URL.
@ -142,6 +170,7 @@ namespace Exiv2 {
@return the path of file URL. @return the path of file URL.
*/ */
EXIV2API std::string pathOfFileUrl(const std::string& url); EXIV2API std::string pathOfFileUrl(const std::string& url);
#ifdef EXV_UNICODE_PATH #ifdef EXV_UNICODE_PATH
/*! /*!
@brief Like pathOfFileUrl(const std::string& url) but accepts a unicode path in an std::wstring. @brief Like pathOfFileUrl(const std::string& url) but accepts a unicode path in an std::wstring.
@ -149,6 +178,7 @@ namespace Exiv2 {
*/ */
EXIV2API std::wstring pathOfFileUrl(const std::wstring& wurl); EXIV2API std::wstring pathOfFileUrl(const std::wstring& wurl);
#endif #endif
/*! /*!
@brief Return a system error message and the error code (errno). @brief Return a system error message and the error code (errno).
See %strerror(3). See %strerror(3).
@ -160,6 +190,8 @@ namespace Exiv2 {
URL to get the protocol, host, path, port, querystring, username, password. URL to get the protocol, host, path, port, querystring, username, password.
Source: http://stackoverflow.com/questions/2616011/easy-way-to-parse-a-url-in-c-cross-platform Source: http://stackoverflow.com/questions/2616011/easy-way-to-parse-a-url-in-c-cross-platform
@todo This class can probably be hidden from the API
*/ */
class Uri class Uri
{ {
@ -173,15 +205,11 @@ namespace Exiv2 {
std::string Username; //!< URL username std::string Username; //!< URL username
std::string Password; //!< URL password std::string Password; //!< URL password
/*! /// @brief Parse the input URL to the protocol, host, path, username, password
@brief Parse the input URL to the protocol, host, path, username, password static Uri EXIV2API Parse(const std::string& uri);
*/
static Uri EXIV2API Parse(const std::string &uri);
/*! /// @brief Decode the url components.
@brief Decode the url components.
*/
static void EXIV2API Decode(Uri& uri); static void EXIV2API Decode(Uri& uri);
}; // class Uri };
} // namespace Exiv2 } // namespace Exiv2
Loading…
Cancel
Save