Skip to content

Commit

Permalink
style: second chunk of part 3 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 committed Oct 31, 2023
1 parent 6210601 commit 2a3ec75
Show file tree
Hide file tree
Showing 7 changed files with 845 additions and 269 deletions.
87 changes: 60 additions & 27 deletions include/dpp/misc-enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,65 @@

namespace dpp {

/** @brief Supported image types for profile pictures and CDN endpoints */
enum image_type {
/// image/png
i_png,
/// image/jpeg
i_jpg,
/// image/gif
i_gif,
/// WebP
i_webp,
};

/** @brief Log levels */
enum loglevel {
/// Trace
ll_trace = 0,
/// Debug
ll_debug,
/// Information
ll_info,
/// Warning
ll_warning,
/// Error
ll_error,
/// Critical
ll_critical
};
/**
* @brief Supported image types for profile pictures and CDN endpoints
*/
enum image_type {
/**
* @brief image/png
*/
i_png,

/**
* @brief image/jpeg.
*/
i_jpg,

/**
* @brief image/gif.
*/
i_gif,

/**
* @brief Webp.
*/
/// WebP
i_webp,
};

/**
* @brief Log levels
*/
enum loglevel {
/**
* @brief Trace
*/
ll_trace = 0,

/**
* @brief Debug
*/
ll_debug,

/**
* @brief Information
*/
ll_info,

/**
* @brief Warning
*/
ll_warning,

/**
* @brief Error
*/
ll_error,

/**
* @brief Critical
*/
ll_critical
};

} // namespace dpp
36 changes: 18 additions & 18 deletions include/dpp/once.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@

namespace dpp {

/**
* @brief Run some code within an if() statement only once.
*
* Use this template like this:
*
* ```
* if (dpp::run_once<struct any_unique_name_you_like_here>()) {
* // Your code here
* }
* ```
*
* @tparam T any unique 'tag' identifier name
* @return auto a true/false return to say if we should execute or not
*/
template <typename T> auto run_once() {
static auto called = false;
return !std::exchange(called, true);
};
/**
* @brief Run some code within an if() statement only once.
*
* Use this template like this:
*
* ```
* if (dpp::run_once<struct any_unique_name_you_like_here>()) {
* // Your code here
* }
* ```
*
* @tparam T any unique 'tag' identifier name
* @return auto a true/false return to say if we should execute or not
*/
template <typename T> auto run_once() {
static auto called = false;
return !std::exchange(called, true);
};

} // namespace dpp
Loading

0 comments on commit 2a3ec75

Please sign in to comment.