Skip to content

Commit 02a695f

Browse files
committed
refactor: improve documentation
1 parent 1d75546 commit 02a695f

14 files changed

Lines changed: 607 additions & 306 deletions

libs/core/src/ecflow/core/Base64.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,37 @@
1616

1717
namespace ecf {
1818

19-
/**
20-
* @brief Decode a base64 encoded string.
21-
*
22-
* @param value the base64 encoded string
23-
* @return the decoded string
24-
*
25-
* @throws std::invalid_argument if the input string has size not multiple of 4
26-
* @throws std::invalid_argument if any character in the input string is invalid (not in A-Za-z0-9+/ or '=' for padding)
27-
* @throws std::invalid_argument if padding is invalid (more than 2 '=', or non-padding characters after first '=')
28-
*/
19+
///
20+
/// @brief Decode a base64 encoded string.
21+
///
22+
/// @param value the base64 encoded string
23+
/// @return the decoded string
24+
///
25+
/// @throws std::invalid_argument if the input has size not multiple of 4
26+
/// @throws std::invalid_argument if any character in the input is invalid (not in A-Za-z0-9+/ or '=' for padding)
27+
/// @throws std::invalid_argument if padding is invalid (more than 2 '=', or non-padding characters after first '=')
28+
///
2929
std::string decode_base64(std::string_view value);
3030

31-
/**
32-
* @brief Encode a string to base64.
33-
*
34-
* @param value the string to encode
35-
* @return the base64 encoded string
36-
*/
31+
///
32+
/// @brief Encode a string to base64.
33+
///
34+
/// @param value the string to encode
35+
/// @return the base64 encoded string
36+
///
3737
std::string encode_base64(std::string_view value);
3838

39-
/**
40-
* @brief Simple validation of base64 encoded string.
41-
*
42-
* Checks the following conditions:
43-
* - length has to be multiple of 4 (n.b. 0 if a valid lenght)
44-
* - valid characters are A-Za-z0-9+/
45-
* - '=' can be used for padding (0, 1, or 2 characters) at the end of string
46-
*
47-
* @param value the base64 encoded string
48-
* @return true if valid, false otherwise
49-
*/
39+
///
40+
/// @brief Simple validation of base64 encoded string.
41+
///
42+
/// Checks the following conditions:
43+
/// - length has to be multiple of 4 (n.b. 0 if a valid lenght)
44+
/// - valid characters are A-Za-z0-9+/
45+
/// - '=' can be used for padding (0, 1, or 2 characters) at the end of string
46+
///
47+
/// @param value the base64 encoded string
48+
/// @return true if valid, false otherwise
49+
///
5050
bool validate_base64(std::string_view value);
5151

5252
} // namespace ecf

libs/core/src/ecflow/core/CommandLine.hpp

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,53 @@
1515
#include <string>
1616
#include <vector>
1717

18-
/**
19-
* CommandLine is a thin wrapper/container for the contents of an ecFlow client command line.
20-
*
21-
* Note: This class is related to class ArgvCreator, which takes the vector of the command
22-
* line tokens and converts them into argc+argv.
23-
*/
18+
///
19+
/// @brief CommandLine is a thin wrapper/container for the contents of an ecFlow client command line.
20+
///
21+
/// Note: This class is related to class ArgvCreator, which takes the vector of the command
22+
/// line tokens and converts them into argc+argv.
23+
///
2424
class CommandLine {
2525
public:
2626
using cl_t = std::string;
2727
using tokens_t = std::vector<std::string>;
2828
using size_t = tokens_t::size_type;
2929

3030
public:
31-
/**
32-
* Create a Command Line instance based on argc + argv
33-
*
34-
* @param argc the number of tokens in the command line
35-
* @param argv the tokens in the command line
36-
*/
31+
///
32+
/// @brief Create a Command Line instance based on argc + argv
33+
///
34+
/// @param argc the number of tokens in the command line
35+
/// @param argv the tokens in the command line
36+
///
3737
CommandLine(int argc, char** argv);
3838
CommandLine(int argc, const char** argv);
3939

40-
/**
41-
* Create a Command Line instance based on a sequence of characters,
42-
* considering that it might include single/double quotes.
43-
*
44-
* @param cl the command line as a sequence of characters
45-
*/
40+
///
41+
/// @brief Create a Command Line instance based on a sequence of characters,
42+
/// considering that it might include single/double quotes.
43+
///
44+
/// @param cl the command line as a sequence of characters
45+
/// @throws std::runtime_error if the command line contains an invalid escape sequence
46+
/// or unmatched quotation marks
47+
///
4648
explicit CommandLine(const cl_t& cl);
4749

48-
/**
49-
* Create a Command Line instance based on a sequence of tokens.
50-
*
51-
* @param tokens the command line as a sequence of tokens
52-
*/
50+
///
51+
/// @brief Create a Command Line instance based on a sequence of tokens.
52+
///
53+
/// @param tokens the command line as a sequence of tokens
54+
///
5355
explicit CommandLine(tokens_t tokens);
5456

55-
/**
56-
* Create a Command Line instance based on multiple tokens.
57-
* Tokens can be either strings or collections of strings. In the latter case, the collection of strings are
58-
* added to the command line element-by-element.
59-
*
60-
* @param tokens the command line as multiple tokens
61-
*/
57+
///
58+
/// @brief Create a Command Line instance based on multiple tokens.
59+
/// Tokens can be either strings or collections of strings. In the latter case, the collection of strings are
60+
/// added to the command line element-by-element.
61+
///
62+
/// @param tokens the command line as multiple tokens
63+
/// @return a CommandLine instance composed of the provided tokens
64+
///
6265
template <typename... TOKENS>
6366
static CommandLine make_command_line(TOKENS... tokens) {
6467
auto push = Overload{
@@ -72,28 +75,34 @@ class CommandLine {
7275
return CommandLine(ts);
7376
}
7477

75-
/**
76-
* Access the original content of the command line.
77-
*/
78+
///
79+
/// @brief Access the original content of the command line.
80+
///
81+
/// @return the command line as a single string, with tokens separated by spaces
82+
///
7883
[[nodiscard]] cl_t original() const;
7984

80-
/**
81-
* Access the number of tokens composing the command line.
82-
*
83-
* @return the number of tokens
84-
*/
85+
///
86+
/// @brief Access the number of tokens composing the command line.
87+
///
88+
/// @return the number of tokens
89+
///
8590
[[nodiscard]] size_t size() const;
8691

87-
/**
88-
* Access the sequence of tokens composing the command line.
89-
*
90-
* @return the command line tokens
91-
*/
92+
///
93+
/// @brief Access the sequence of tokens composing the command line.
94+
///
95+
/// @return the command line tokens
96+
///
9297
[[nodiscard]] const tokens_t& tokens() const;
9398

94-
/**
95-
* Pretty print the command line
96-
*/
99+
///
100+
/// @brief Pretty print the command line
101+
///
102+
/// @param os the output stream to write to
103+
/// @param cl the command line to print
104+
/// @return the output stream @p os
105+
///
97106
friend std::ostream& operator<<(std::ostream& os, const CommandLine& cl);
98107

99108
private:

libs/core/src/ecflow/core/Enumerate.hpp

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,44 @@ namespace ecf {
2424

2525
namespace detail {
2626

27-
/**
28-
* EnumTraits defines the mapping between a set of enum values and their designation.
29-
*
30-
* EnumTraits must define:
31-
* - the mapping `map`, provided as a std::array composed of a std::pair<E, const char *> for each enum value
32-
* - the `size`, holding the number os entries in `map`
33-
*
34-
* @tparam E
35-
*/
36-
27+
///
28+
/// @brief EnumTraits defines the mapping between a set of enum values and their designation.
29+
///
30+
/// EnumTraits must define:
31+
/// - the mapping `map`, provided as a std::array composed of a std::pair<E, const char *> for each enum value
32+
/// - the `size`, holding the number of entries in `map`
33+
///
34+
/// @tparam E the enum type for which the traits are defined
35+
///
3736
template <typename E>
3837
struct EnumTraits
3938
{
4039
};
4140

4241
} // namespace detail
4342

43+
///
44+
/// @brief Enumerate provides bidirectional mapping between enum values and their string designations.
45+
///
46+
/// @tparam E the enum type to map
47+
/// @tparam TRAITS the traits type providing the mapping; defaults to detail::EnumTraits<E>
48+
///
4449
template <typename E, typename TRAITS = detail::EnumTraits<E>>
4550
struct Enumerate
4651
{
4752
public:
4853
using enum_t = E;
4954
using string_t = std::string_view;
5055

51-
/**
52-
* Convert the given enum value to its designation
53-
*
54-
* This is an "unsafe" operation, as it assumes that the given enum value exists in the mapping.
55-
* If the enum value does not exist, an assertion failure is raised.
56-
*
57-
* @param e the enum value
58-
* @return the associated designation
59-
*/
56+
///
57+
/// @brief Convert the given enum value to its designation.
58+
///
59+
/// This is an "unsafe" operation, as it assumes that the given enum value exists in the mapping.
60+
/// If the enum value does not exist, an assertion failure is raised.
61+
///
62+
/// @param e the enum value
63+
/// @return the associated designation
64+
///
6065
static constexpr string_t as_string(enum_t e) noexcept {
6166
auto found = std::find_if(
6267
std::begin(TRAITS::map), std::end(TRAITS::map), [&](const auto& item) { return item.first == e; });
@@ -66,12 +71,12 @@ struct Enumerate
6671
return found->second;
6772
}
6873

69-
/**
70-
* Convert the given enum value to its designation
71-
*
72-
* @param e the enum value
73-
* @return the associated designation, in case it exists; an empty optional, otherwise
74-
*/
74+
///
75+
/// @brief Convert the given enum value to its designation.
76+
///
77+
/// @param e the enum value
78+
/// @return the associated designation, in case it exists; an empty optional, otherwise
79+
///
7580
static constexpr std::optional<string_t> to_string(enum_t e) noexcept {
7681
if (auto found = std::find_if(
7782
std::begin(TRAITS::map), std::end(TRAITS::map), [&](const auto& item) { return item.first == e; });
@@ -82,12 +87,12 @@ struct Enumerate
8287
return std::nullopt;
8388
}
8489

85-
/**
86-
* Convert the given designation to the related enum value
87-
*
88-
* @param s the designation
89-
* @return the enum value, in case it exists; an empty optional, otherwise
90-
*/
90+
///
91+
/// @brief Convert the given designation to the related enum value.
92+
///
93+
/// @param s the designation
94+
/// @return the enum value, in case it exists; an empty optional, otherwise
95+
///
9196
static constexpr std::optional<E> to_enum(string_t s) noexcept {
9297
if (auto found = std::find_if(
9398
std::begin(TRAITS::map), std::end(TRAITS::map), [&](const auto& item) { return item.second == s; });
@@ -98,26 +103,28 @@ struct Enumerate
98103
return std::nullopt;
99104
}
100105

101-
/**
102-
* Checks if the given designation is valid (i.e. has a related enum value)
103-
*
104-
* @param s the designation
105-
* @return true, if valid; false, otherwise
106-
*/
106+
///
107+
/// @brief Check if the given designation is valid (i.e. has a related enum value).
108+
///
109+
/// @param s the designation
110+
/// @return true, if valid; false, otherwise
111+
///
107112
static constexpr bool is_valid(string_t s) {
108113
auto found = std::find_if(
109114
std::begin(TRAITS::map), std::end(TRAITS::map), [&](const auto& item) { return item.second == s; });
110115
return found != std::end(TRAITS::map);
111116
}
112117

113-
/**
114-
* The number of mapped enum values
115-
*/
118+
///
119+
/// @brief The number of mapped enum values.
120+
///
116121
static const size_t size = TRAITS::size;
117122

118-
/**
119-
* The vector of mapped enum values
120-
*/
123+
///
124+
/// @brief Collect all mapped enum values.
125+
///
126+
/// @return a vector containing all mapped enum values
127+
///
121128
static auto enums() {
122129
std::vector<E> result;
123130
result.reserve(TRAITS::size);
@@ -128,9 +135,11 @@ struct Enumerate
128135
return result;
129136
}
130137

131-
/**
132-
* The vector of mapped designations
133-
*/
138+
///
139+
/// @brief Collect all mapped designations.
140+
///
141+
/// @return a vector containing all mapped designations
142+
///
134143
static auto designations() {
135144
std::vector<std::string> result;
136145
result.reserve(TRAITS::size);

0 commit comments

Comments
 (0)