aboutsummaryrefslogtreecommitdiffstats
path: root/src/dls.cpp
diff options
context:
space:
mode:
authorStefan Pöschel <spoeschel@irt.de>2019-07-22 17:11:35 +0200
committerStefan Pöschel <github@basicmaster.de>2019-07-23 11:32:14 +0200
commit1c2f96f13e6e5abbf114af0192dbdd53de3c9a25 (patch)
treeea6cb71ab773b84733add0acffc9d43e4d3ff0dc /src/dls.cpp
parent53084277c31ca73f1556b6932a74700f0ddcf1cc (diff)
downloadODR-PadEnc-1c2f96f13e6e5abbf114af0192dbdd53de3c9a25.tar.gz
ODR-PadEnc-1c2f96f13e6e5abbf114af0192dbdd53de3c9a25.tar.bz2
ODR-PadEnc-1c2f96f13e6e5abbf114af0192dbdd53de3c9a25.zip
DLS: move label parsing to separate function
Diffstat (limited to 'src/dls.cpp')
-rw-r--r--src/dls.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dls.cpp b/src/dls.cpp
index f55c141..4e106e0 100644
--- a/src/dls.cpp
+++ b/src/dls.cpp
@@ -189,14 +189,13 @@ void DLSEncoder::parse_dl_params(std::ifstream &dls_fstream, DL_STATE &dl_state)
}
-void DLSEncoder::encodeLabel(const std::string& dls_file, const DL_PARAMS& dl_params) {
- DL_STATE dl_state;
+bool DLSEncoder::parseLabel(const std::string& dls_file, const DL_PARAMS& dl_params, DL_STATE& dl_state) {
std::vector<std::string> dls_lines;
std::ifstream dls_fstream(dls_file);
if (!dls_fstream.is_open()) {
std::cerr << "Could not open " << dls_file << std::endl;
- return;
+ return false;
}
std::string line;
@@ -241,12 +240,19 @@ void DLSEncoder::encodeLabel(const std::string& dls_file, const DL_PARAMS& dl_pa
dl_state.dl_text.resize(MAXDLS);
}
+ return true;
+}
+
+
+void DLSEncoder::encodeLabel(const std::string& dls_file, const DL_PARAMS& dl_params) {
+ DL_STATE dl_state;
+ if (!parseLabel(dls_file, dl_params, dl_state))
+ return;
// if DL Plus enabled, but no DL Plus tags were added, add the required DUMMY tag
if (dl_state.dl_plus_enabled && dl_state.dl_plus_tags.empty())
dl_state.dl_plus_tags.emplace_back();
-
// toggle the toggle bit only on new DL state
bool dl_state_is_new = dl_state != dl_state_prev;
if (verbose) {