Skip to content

Commit

Permalink
Clang format.
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidWallOfCode committed Nov 21, 2023
1 parent 3632bbc commit 6ab1f57
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
25 changes: 13 additions & 12 deletions code/include/swoc/Errata.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class Errata {
/// This defaults to zero and no filtering is done unless it is overwritten.
static Severity FILTER_SEVERITY;

static inline TextView AUTOTEXT_SEVERITY = "{}"; ///< Format for auto generated annotation with severity.
static inline TextView AUTOTEXT_CODE = "{}"; ///< Format for auto generated annotation with error code.
static inline TextView AUTOTEXT_SEVERITY = "{}"; ///< Format for auto generated annotation with severity.
static inline TextView AUTOTEXT_CODE = "{}"; ///< Format for auto generated annotation with error code.
static inline TextView AUTOTEXT_SEVERITY_CODE = "{}: {}"; ///< Format for auto generate annotation with error code and severity.

/// Mapping of severity to string.
Expand Down Expand Up @@ -200,15 +200,16 @@ class Errata {
TextView _indent_text = DEFAULT_INDENT_TEXT;
bool _glue_final_p = true; ///< Add glue after the last annotation?

std::optional<Severity> _severity; ///< Severity.
code_type _code{DEFAULT_CODE}; ///< Message code / ID
Container _notes; ///< The message stack.
swoc::MemArena _arena; ///< Annotation text storage.
std::optional<Severity> _severity; ///< Severity.
code_type _code{DEFAULT_CODE}; ///< Message code / ID
Container _notes; ///< The message stack.
swoc::MemArena _arena; ///< Annotation text storage.
};

public:
/// Used to indicate automatically generated annotation text.
static constexpr struct AutoText {} AUTO {};
static constexpr struct AutoText {
} AUTO{};

/// Default constructor - empty errata, very fast.
Errata() = default;
Expand All @@ -224,7 +225,7 @@ class Errata {
*
* No annotation is created.
*/
explicit Errata(code_type const& ec);
explicit Errata(code_type const &ec);

/** Construct with an error code and generated annotation.
*
Expand All @@ -233,7 +234,7 @@ class Errata {
* An annotation is created using the format @c AUTOTEXT_CODE with @a ec as the argument.
* @see AUTOTEXT_CODE
*/
explicit Errata(code_type const& ec, AutoText);
explicit Errata(code_type const &ec, AutoText);

/** Construct with a severity.
*
Expand Down Expand Up @@ -270,7 +271,7 @@ class Errata {
* The annotation uses the format @c AUTOTEXT_SEVERITY_CODE with arguments @a severity , @a ec
* @see AUTOTEXT_SEVERITY_CODE
*/
explicit Errata(code_type const& ec, Severity severity, AutoText auto_text);
explicit Errata(code_type const &ec, Severity severity, AutoText auto_text);

/** Constructor.
*
Expand Down Expand Up @@ -1030,7 +1031,7 @@ inline Errata::Errata(self_type &&that) noexcept {
std::swap(_data, that._data);
}

inline Errata::Errata(code_type const& ec) {
inline Errata::Errata(code_type const &ec) {
this->data()->_code = ec;
}

Expand All @@ -1044,7 +1045,7 @@ inline Errata::Errata(const code_type &ec, Severity severity) {
d->_code = ec;
}

inline Errata::Errata(code_type const& ec, AutoText) {
inline Errata::Errata(code_type const &ec, AutoText) {
this->data()->_code = ec;
this->note(AUTOTEXT_CODE, ec);
}
Expand Down
15 changes: 10 additions & 5 deletions code/include/swoc/TextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ class TextView;
*/
class CharSet {
using self_type = CharSet;

public:
constexpr CharSet(TextView const& chars);
bool operator () (u_char idx) const { return _chars[idx]; }
constexpr CharSet(TextView const &chars);
bool
operator()(u_char idx) const {
return _chars[idx];
}

protected:
std::bitset<256> _chars;
};
Expand Down Expand Up @@ -1081,8 +1086,8 @@ double svtod(TextView text, TextView *parsed = nullptr);
// simpler plain @c TextView ? Because otherwise Doxygen can't match up the declaration and
// definition and the reference documentation is messed up. Sigh.

inline constexpr CharSet::CharSet(TextView const & chars) {
for ( auto c : chars) {
inline constexpr CharSet::CharSet(TextView const &chars) {
for (auto c : chars) {
_chars[u_char(c)] = true;
}
}
Expand Down Expand Up @@ -1510,7 +1515,7 @@ TextView::trim(char c) {

inline TextView &
TextView::ltrim(CharSet const &delimiters) {
const char *spot = this->data();
const char *spot = this->data();
const char *limit = this->data_end();

while (spot < limit && delimiters(*spot)) {
Expand Down
2 changes: 1 addition & 1 deletion code/src/bw_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ bwformat(BufferWriter &w, bwf::Spec const &spec, std::error_code const &ec) {

// This provides convenient safe access to the errno short name array.
static const swoc::bwf::Format number_fmt{"[{}]"_sv}; // numeric value format.
if (spec.has_numeric_type()) { // if numeric type, print just the numeric part.
if (spec.has_numeric_type()) { // if numeric type, print just the numeric part.
bwformat(w, spec, ec.value());
} else {
if ((&ec.category() == G_CAT || &ec.category() == S_CAT) && swoc::ERRNO_RANGE.contains(ec.value())) {
Expand Down
27 changes: 10 additions & 17 deletions unit_tests/test_Errata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ std::array<swoc::TextView, 5> Severity_Names{
{"Debug", "Diag", "Info", "Warn", "Error"}
};

enum class ECode {
ALPHA = 1,
BRAVO,
CHARLIE
};
enum class ECode { ALPHA = 1, BRAVO, CHARLIE };

struct e_category : std::error_category {
const char *name() const noexcept override;
Expand All @@ -44,27 +40,24 @@ struct e_category : std::error_category {
e_category e_cat;

const char *
e_category::name() const noexcept
{
e_category::name() const noexcept {
return "libswoc";
}

std::string
e_category::message(int ev) const
{
static swoc::Lexicon<ECode> lexicon {
{
{ ECode::ALPHA , "Alpha" },
{ ECode::BRAVO, "Bravo"},
{ ECode::CHARLIE, "Charlie"}
}
, "Code out of range"
e_category::message(int ev) const {
static swoc::Lexicon<ECode> lexicon{
{{ECode::ALPHA, "Alpha"}, {ECode::BRAVO, "Bravo"}, {ECode::CHARLIE, "Charlie"}},
"Code out of range"
};

return std::string(lexicon[ECode(ev)]);
}

inline std::error_code ecode(ECode c) { return { int(c) , e_cat }; }
inline std::error_code
ecode(ECode c) {
return {int(c), e_cat};
}

std::string ErrataSinkText;

Expand Down

0 comments on commit 6ab1f57

Please sign in to comment.