Skip to content

Commit b9cf3ad

Browse files
committed
cleanup src/utils/charsets.* to match codestyle
This cleans up the two files src/utils/charsets.cpp and src/utils/charsets.h to correspond to our clang format, and the code is added to a namespace to be cleaner on the outside, public is the namespace "charsets" in the cpp then a pseudo namespace for private functions so that it is not known to the outside world.
1 parent 3fc2113 commit b9cf3ad

7 files changed

+192
-203
lines changed

src/dsp_dab/dab-constants.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,24 @@ string DabLabel::utf8_label() const
135135

136136
string DabLabel::fig1_label_utf8() const
137137
{
138-
return toUtf8StringUsingCharset(fig1_label.c_str(), charset);
138+
return charsets::toUtf8(fig1_label.c_str(), charset);
139139
}
140140

141141
string DabLabel::fig1_shortlabel_utf8() const
142142
{
143143
const string shortlabel = flag_to_shortlabel(fig1_label, fig1_flag);
144-
return toUtf8StringUsingCharset(shortlabel.c_str(), charset);
144+
return charsets::toUtf8(shortlabel.c_str(), charset);
145145
}
146146

147147
void DabLabel::setCharset(uint8_t charset_id)
148148
{
149-
charset = static_cast<CharacterSet>(charset_id);
149+
charset = static_cast<charsets::CharacterSet>(charset_id);
150150
}
151151

152152
string DabLabel::fig2_label() const
153153
{
154+
using charsets::CharacterSet;
155+
154156
vector<uint8_t> segments_cat;
155157
for (size_t i = 0; i < segment_count; i++) {
156158
if (segments.count(i) == 0) {
@@ -169,8 +171,7 @@ string DabLabel::fig2_label() const
169171
case CharacterSet::UnicodeUtf8:
170172
return string(segments_cat.begin(), segments_cat.end());
171173
case CharacterSet::UnicodeUcs2:
172-
return toUtf8StringUsingCharset(
173-
segments_cat.data(), CharacterSet::UnicodeUcs2, segments_cat.size());
174+
return charsets::toUtf8(segments_cat.data(), CharacterSet::UnicodeUcs2, segments_cat.size());
174175
case CharacterSet::Undefined:
175176
return "";
176177
}

src/dsp_dab/dab-constants.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class DABParams {
137137
struct DabLabel {
138138
// Label from FIG 1
139139
/* FIG 1 labels are usually in EBU Latin encoded */
140-
CharacterSet charset = CharacterSet::EbuLatin;
140+
charsets::CharacterSet charset = charsets::CharacterSet::EbuLatin;
141141
std::string fig1_label; // encoded according to charset
142142
uint16_t fig1_flag = 0x0000; // describes the short label
143143

@@ -153,7 +153,7 @@ struct DabLabel {
153153

154154
std::map<int, std::vector<uint8_t> > segments;
155155
size_t segment_count = 0; // number if actual segments (not segment count as in spec)
156-
CharacterSet extended_label_charset = CharacterSet::Undefined;
156+
charsets::CharacterSet extended_label_charset = charsets::CharacterSet::Undefined;
157157
uint8_t toggle_flag = 0;
158158
bool fig2_rfu = false; // draftETSI TS 103 176 v2.2.1 gives this a new meaning
159159

src/dsp_dab/decoder_adapter.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,14 @@ void DecoderAdapter::FECInfo(int total_corr_count, bool uncorr_errors)
142142

143143
void DecoderAdapter::PADChangeDynamicLabel(const DL_STATE &dl)
144144
{
145+
using charsets::CharacterSet;
146+
145147
if (dl.raw.empty()) {
146148
myInterface.onNewDynamicLabel("");
147149
}
148150
else {
149151
myInterface.onNewDynamicLabel(
150-
toUtf8StringUsingCharset(
152+
charsets::toUtf8(
151153
dl.raw.data(),
152154
(CharacterSet)dl.charset,
153155
dl.raw.size()));

src/dsp_dab/fib-processor.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,8 @@ static void handle_ext_label_data_field(const uint8_t *f, uint8_t len_bytes,
917917
uint8_t toggle_flag, uint8_t segment_index, uint8_t rfu,
918918
DabLabel& label)
919919
{
920+
using charsets::CharacterSet;
921+
920922
if (label.toggle_flag != toggle_flag) {
921923
label.segments.clear();
922924
label.extended_label_charset = CharacterSet::Undefined;

src/dsp_dab/mot_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ bool MOTObject::ParseCheckHeader(MOT_FILE& target_file) {
156156
if(data_len == 0)
157157
return false;
158158
//file.content_name = CharsetTools::ConvertTextToUTF8(&data[offset + 1], data_len - 1, data[offset] >> 4, true, &file.content_name_charset);
159-
file.content_name = toUtf8StringUsingCharset ( (const char *)&data[offset + 1], (CharacterSet) (data[offset] >> 4), data_len - 1);
159+
file.content_name = charsets::toUtf8( (const char *)&data[offset + 1], (charsets::CharacterSet) (data[offset] >> 4), data_len - 1);
160160
new_content_name = file.content_name;
161161
// fprintf(stderr, "ContentName: '%s'\n", file.content_name.c_str());
162162
break;

0 commit comments

Comments
 (0)