Skip to content

Commit

Permalink
clang-format: explicitly set PointerAlignment
Browse files Browse the repository at this point in the history
Otherwise it keeps changing due to DerivePointerAlignment.
  • Loading branch information
windytan committed Jul 19, 2024
1 parent c91289e commit a4b27bb
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 81 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
IncludeBlocks: Preserve
DerivePointerAlignment: false
PointerAlignment: Left
134 changes: 64 additions & 70 deletions src/groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,101 +35,95 @@
namespace redsea {

// A scoped enum couldn't readily be used for indexing
enum eBlockNumber {
BLOCK1, BLOCK2, BLOCK3, BLOCK4
};
enum eBlockNumber { BLOCK1, BLOCK2, BLOCK3, BLOCK4 };

enum class Offset {
A, B, C, Cprime, D, invalid
};
enum class Offset { A, B, C, Cprime, D, invalid };

class Block {
public:
uint32_t raw { 0 };
uint16_t data { 0 };
bool is_received { false };
bool had_errors { false };
Offset offset { Offset::invalid };
uint32_t raw{0};
uint16_t data{0};
bool is_received{false};
bool had_errors{false};
Offset offset{Offset::invalid};
};

class GroupType {
public:
enum class Version {
A, B
};
enum class Version { A, B };

GroupType() = default;
explicit GroupType(uint16_t type_code);

std::string str() const;

uint16_t number { 0x00 };
Version version { Version::A };
uint16_t number{0x00};
Version version{Version::A};
};

bool operator<(const GroupType& type1, const GroupType& type2);

class ProgramServiceName {
public:
ProgramServiceName() = default;
void update(size_t pos, uint8_t byte1, uint8_t byte2) {
text.set(pos, byte1, byte2);
}
public:
ProgramServiceName() = default;
void update(size_t pos, uint8_t byte1, uint8_t byte2) {
text.set(pos, byte1, byte2);
}

RDSString text{8};
RDSString text{8};
};

class LongPS {
public:
LongPS() {
public:
LongPS() {
text.setEncoding(RDSString::Encoding::UTF8);
}
void update(size_t pos, uint8_t byte1, uint8_t byte2) {
text.set(pos, byte1, byte2);
}
}
void update(size_t pos, uint8_t byte1, uint8_t byte2) {
text.set(pos, byte1, byte2);
}

RDSString text{32};
RDSString text{32};
};

class RadioText {
public:
RadioText() = default;
bool isABChanged(int new_ab) {
const bool is = (ab != new_ab);
ab = new_ab;
ab = new_ab;
return is;
}
void update(size_t pos, uint8_t byte1, uint8_t byte2) {
text.set(pos, byte1, byte2);
}

struct Plus {
bool exists {};
bool cb {};
uint16_t scb {};
uint16_t template_num {};
bool toggle {};
bool item_running {};
bool exists{};
bool cb{};
uint16_t scb{};
uint16_t template_num{};
bool toggle{};
bool item_running{};

struct Tag {
uint16_t content_type {};
uint16_t start {};
uint16_t length {};
uint16_t content_type{};
uint16_t start{};
uint16_t length{};
};
};

RDSString text{64};
Plus plus;
RDSString text{64};
Plus plus;
std::string previous_potentially_complete_message;
int ab{};
int ab{};
};

class PTYName {
public:
PTYName() : text(8) {}
bool isABChanged(int new_ab) {
bool is = (ab != new_ab);
ab = new_ab;
ab = new_ab;
return is;
}
void update(size_t pos, uint8_t char1, uint8_t char2, uint8_t char3, uint8_t char4) {
Expand All @@ -138,17 +132,17 @@ class PTYName {
}

RDSString text;
int ab { 0 };
int ab{0};
};

class Pager {
public:
int pac { 0 };
int opc { 0 };
int paging_code { 0 };
int ecc { 0 };
int ccf { 0 };
int interval { 0 };
int pac{0};
int opc{0};
int paging_code{0};
int ecc{0};
int ccf{0};
int interval{0};
void decode1ABlock4(uint16_t block4);
};

Expand Down Expand Up @@ -181,15 +175,15 @@ class Group {
void setAverageBLER(float bler);

private:
GroupType type_ {};
GroupType type_{};
std::array<Block, 4> blocks_;
std::chrono::time_point<std::chrono::system_clock> time_received_;
float bler_ { 0.f };
bool has_type_ { false };
bool has_c_prime_ { false };
bool has_bler_ { false };
bool has_time_ { false };
bool no_offsets_ { false };
float bler_{0.f};
bool has_type_{false};
bool has_c_prime_{false};
bool has_bler_{false};
bool has_time_{false};
bool no_offsets_{false};
};

class Station {
Expand Down Expand Up @@ -219,28 +213,28 @@ class Station {
void parseEnhancedRT(const Group& group);
void parseDAB(const Group& group);

uint16_t pi_ { 0x0000 };
bool has_pi_ { false };
uint16_t pi_{0x0000};
bool has_pi_{false};
Options options_;
int which_channel_ { 0 };
int which_channel_{0};
ProgramServiceName ps_;
LongPS long_ps_;
RadioText radiotext_;
RadioText ert_;
PTYName ptyname_;
RDSString full_tdc_ { 32 * 4 };
uint16_t pin_ { 0 };
uint16_t ecc_ { 0 };
uint16_t cc_ { 0 };
int tmc_id_ { 0 };
bool linkage_la_ { 0 };
std::string clock_time_ { "" };
bool has_country_ { false };
RDSString full_tdc_{32 * 4};
uint16_t pin_{0};
uint16_t ecc_{0};
uint16_t cc_{0};
int tmc_id_{0};
bool linkage_la_{0};
std::string clock_time_{""};
bool has_country_{false};
std::map<GroupType, uint16_t> oda_app_for_group_;
bool ert_uses_chartable_e3_ { false };
bool ert_uses_chartable_e3_{false};
std::map<uint16_t, RDSString> eon_ps_names_;
std::map<uint16_t, AltFreqList> eon_alt_freqs_;
bool last_group_had_pi_ { false };
bool last_group_had_pi_{false};
AltFreqList alt_freq_list_;
Pager pager_;

Expand Down
12 changes: 4 additions & 8 deletions src/rdsstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ namespace redsea {
// An RDSString can be RadioText, Program Service name, or Enhanced RadioText.
class RDSString {
public:
enum class Encoding {
Basic, UCS2, UTF8
};
enum class Direction {
LTR, RTL
};
enum class Encoding { Basic, UCS2, UTF8 };
enum class Direction { LTR, RTL };

explicit RDSString(size_t len = 8);
void set(size_t pos, uint8_t byte);
Expand All @@ -57,8 +53,8 @@ class RDSString {
std::vector<uint8_t> data_;
// Raw bytes.
std::vector<uint8_t> last_complete_data_;
size_t prev_pos_ {};
size_t sequential_length_ {};
size_t prev_pos_{};
size_t sequential_length_{};
// Decoded string.
std::string last_complete_string_{};
};
Expand Down
6 changes: 3 additions & 3 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ std::string getTimePointString(const std::chrono::time_point<std::chrono::system
return std::string(buffer);
}

std::string join(const std::vector<std::string> &strings, const std::string &d) {
std::string join(const std::vector<std::string>& strings, const std::string& d) {
std::string result("");
for (size_t i = 0; i < strings.size(); i++) {
result += strings[i];
Expand Down Expand Up @@ -131,11 +131,11 @@ std::string CarrierFrequency::str() const {
return ss.str();
}

bool operator==(const CarrierFrequency &f1, const CarrierFrequency &f2) {
bool operator==(const CarrierFrequency& f1, const CarrierFrequency& f2) {
return (f1.code_ == f2.code_);
}

bool operator<(const CarrierFrequency &f1, const CarrierFrequency &f2) {
bool operator<(const CarrierFrequency& f1, const CarrierFrequency& f2) {
return (f1.kHz() < f2.kHz());
}

Expand Down

0 comments on commit a4b27bb

Please sign in to comment.