Skip to content

Commit 5848123

Browse files
author
Andrei Popescu
authored
Adapt core/utils classes to coding style. (#813)
All core/utils classes are now adapted to our coding style, except some Windows specific code from Dir.cpp. Relates-To: OLPEDGE-1854 Signed-off-by: Andrei Popescu <andrei.popescu@here.com>
1 parent 4005fcc commit 5848123

File tree

6 files changed

+222
-190
lines changed

6 files changed

+222
-190
lines changed

olp-cpp-sdk-core/include/olp/core/utils/Base64.h

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,37 +28,46 @@
2828

2929
namespace olp {
3030
namespace utils {
31+
3132
/**
32-
* @brief base64Encode encodes binary stream into base64 text
33-
* @param bytes data to be encoded
34-
* @return base64 encoded string
33+
* @brief Encodes binary stream into base64 text.
34+
*
35+
* @param bytes Data to be encoded.
36+
*
37+
* @return Base64 encoded string.
3538
*/
3639
CORE_API std::string Base64Encode(const std::vector<std::uint8_t>& bytes);
3740

3841
/**
39-
* @brief base64Encode encodes binary stream into base64 text
40-
* @param bytes data to be encoded
41-
* @return base64 encoded string
42+
* @brief Encodes binary stream into base64 text.
43+
*
44+
* @param bytes Data to be encoded.
45+
*
46+
* @return Base64 encoded string.
4247
*/
4348
CORE_API std::string Base64Encode(const std::string& bytes);
4449

4550
/**
46-
* @brief base64Encode encodes binary stream into base64 text
47-
* @param bytes data to be encoded
48-
* @param size The length of the bytes array
49-
* @return base64 encoded string
51+
* @brief Encodes binary stream into base64 text.
52+
*
53+
* @param bytes Data to be encoded.
54+
* @param size The length of the bytes array.
55+
*
56+
* @return Base64 encoded string.
5057
*/
5158
CORE_API std::string Base64Encode(const void* bytes, size_t size);
5259

5360
/**
54-
* @brief base64Decode decodes base64 into binary stream
55-
* @param[in] s base64 string to be decoded
56-
* @param[out] bytes vector containing decoded bytes
57-
* @param[in] write_null_bytes true if decoded null bytes should be written to
61+
* @brief Decodes base64 into a binary stream.
62+
*
63+
* @param[in] string Base64 string to be decoded.
64+
* @param[out] bytes Vector containing decoded bytes.
65+
* @param[in] write_null_bytes True if decoded null bytes should be written to
5866
* the output, false otherwise. Default is true.
59-
* @return \c true if decoding was successful, false otherwise
67+
*
68+
* @return \c true if decoding was successful, \c false otherwise.
6069
*/
61-
CORE_API bool Base64Decode(const std::string& s,
70+
CORE_API bool Base64Decode(const std::string& string,
6271
std::vector<std::uint8_t>& bytes,
6372
bool write_null_bytes = true);
6473

olp-cpp-sdk-core/include/olp/core/utils/Dir.h

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,36 +29,79 @@ namespace utils {
2929
class CORE_API Dir {
3030
public:
3131
/**
32-
* @brief exists checks if directory exists
33-
* @param path path of the directory
34-
* @return true if directory exists, false otherwise.
32+
* @brief Checks if directory exists.
33+
*
34+
* @param path Path of the directory.
35+
*
36+
* @return \c true if directory exists, \c false otherwise.
37+
*
38+
* @deprecated Will be removed by 10.2020. Please use Exists() instead.
3539
*/
3640
static bool exists(const std::string& path);
3741

3842
/**
39-
* @brief remove removes the directory, deleting all subfolders and files.
40-
* @param path path of the directory
43+
* @brief Checks if directory exists.
44+
*
45+
* @param path Path of the directory.
46+
*
47+
* @return true if directory exists, false otherwise.
48+
*/
49+
static bool Exists(const std::string& path);
50+
51+
/**
52+
* @brief Removes the directory, deleting all subfolders and files.
53+
*
54+
* @param path Path of the directory.
55+
*
4156
* @return true if operation is successfull, false otherwise.
57+
*
58+
* @deprecated Will be removed by 10.2020. Please use Remove() instead.
4259
*/
4360
static bool remove(const std::string& path);
4461

4562
/**
46-
* @brief create creates the directory including all required directories on
63+
* @brief Removes the directory, deleting all subfolders and files.
64+
*
65+
* @param path Path of the directory.
66+
*
67+
* @return \c true if operation is successfull, \c false otherwise.
68+
*/
69+
static bool Remove(const std::string& path);
70+
71+
/**
72+
* @brief Creates the directory including all required directories on
4773
* the path.
48-
* @param path path of the directory
49-
* @return true if operation is successfull, false otherwise.
74+
*
75+
* @param path Path of the directory.
76+
*
77+
* @return \c true if operation is successfull, \c false otherwise.
78+
*
79+
* @deprecated Will be removed by 10.2020. Please use Create() instead.
5080
*/
5181
static bool create(const std::string& path);
5282

5383
/**
54-
* @brief TempDirectory returns the platform-specific temporary path.
55-
* @return temporary directory path
84+
* @brief Creates the directory including all required directories on
85+
* the path.
86+
*
87+
* @param path Path of the directory.
88+
*
89+
* @return \c true if operation is successfull, \c false otherwise.
90+
*/
91+
static bool Create(const std::string& path);
92+
93+
/**
94+
* @brief Returns the platform-specific temporary path.
95+
*
96+
* @return The platform specific temporary directory path.
5697
*/
5798
static std::string TempDirectory();
5899

59100
/**
60-
* @brief Check whether file exists.
61-
* @param[in] file_path Path to the file.
101+
* @brief Check whether the provided file exists.
102+
*
103+
* @param file_path Path to the file.
104+
*
62105
* @return \c true if any file with the given path exists, \c false otherwise.
63106
*/
64107
static bool FileExists(const std::string& file_path);

olp-cpp-sdk-core/include/olp/core/utils/Url.h

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,62 +28,43 @@
2828

2929
namespace olp {
3030
namespace utils {
31+
3132
/**
3233
* Class used for building and parsing Urls.
3334
*/
3435
class CORE_API Url {
3536
public:
3637
/**
37-
* Performs URL decoding on a given input string by replacing
38+
* @brief Performs URL decoding on a given input string by replacing
3839
* percent-encoded characters with the actual ones.
3940
*
40-
* @param in URL encoded string
41-
* @return URL decoded result string
41+
* @param in URL encoded string.
42+
*
43+
* @return URL decoded result string.
4244
*/
4345
static std::string Decode(const std::string& in);
4446

4547
/**
46-
* Encodes a given input string by escaping non-ASCII characters.
48+
* @brief Encodes a given input string by escaping non-ASCII characters.
49+
*
50+
* @param in URL string to be encoded.
4751
*
48-
* @param in URL string to be encoded
49-
* @return URL encoded result string
52+
* @return URL encoded result string.
5053
*/
5154
static std::string Encode(const std::string& in);
5255

5356
/**
5457
* @brief Produces full URL from url base, path and query parameters.
58+
*
5559
* @param base Base of the URL.
5660
* @param path Path part of the URL.
5761
* @param query_params Multipam of query parameters.
62+
*
5863
* @return URL encoded result string.
5964
*/
6065
static std::string Construct(
6166
const std::string& base, const std::string& path,
6267
const std::multimap<std::string, std::string>& query_params);
63-
64-
/** Parses input string and fills appropriate parts of url. Output strings are
65-
* decoded */
66-
static bool Parse(std::string url, std::string& scheme, std::string& userinfo,
67-
std::string& host, std::string& port, std::string& path,
68-
std::string& query, std::string& fragment);
69-
70-
private:
71-
/** Updates internal url as string from different parts, like scheme, host,
72-
* port, etc. */
73-
void UpdateUrl();
74-
75-
template <class TQueryItemsContainer>
76-
void SetQueryItemsImpl(const TQueryItemsContainer& items);
77-
78-
std::string url_;
79-
80-
std::string scheme_;
81-
std::string userinfo_;
82-
std::string host_;
83-
std::string port_;
84-
std::string path_;
85-
std::string query_;
86-
std::string fragment_;
8768
};
8869

8970
} // namespace utils

0 commit comments

Comments
 (0)