aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dls.cpp14
-rw-r--r--src/dls.h2
2 files changed, 12 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) {
diff --git a/src/dls.h b/src/dls.h
index 3b7387d..0142565 100644
--- a/src/dls.h
+++ b/src/dls.h
@@ -148,6 +148,8 @@ private:
CharsetConverter charset_converter;
bool dls_toggle;
DL_STATE dl_state_prev;
+
+ bool parseLabel(const std::string& dls_file, const DL_PARAMS& dl_params, DL_STATE& dl_state);
public:
static const int APPTYPE_START;
static const int APPTYPE_CONT;