diff options
author | Stefan Pöschel <github@basicmaster.de> | 2017-02-15 10:16:17 +0100 |
---|---|---|
committer | Stefan Pöschel <github@basicmaster.de> | 2017-02-15 10:16:17 +0100 |
commit | 966d13519a38e1cd69cb19e62c69870529bcb523 (patch) | |
tree | f6e31e8224515177681c2b1c23d02f356246b80f /src/dls.cpp | |
parent | 0a7f18136ce99e5aecc0c8baf05dfbb1c8e4d7c9 (diff) | |
download | ODR-PadEnc-966d13519a38e1cd69cb19e62c69870529bcb523.tar.gz ODR-PadEnc-966d13519a38e1cd69cb19e62c69870529bcb523.tar.bz2 ODR-PadEnc-966d13519a38e1cd69cb19e62c69870529bcb523.zip |
Small refactorings
Diffstat (limited to 'src/dls.cpp')
-rw-r--r-- | src/dls.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/dls.cpp b/src/dls.cpp index 8e946ca..08297cb 100644 --- a/src/dls.cpp +++ b/src/dls.cpp @@ -186,17 +186,16 @@ void DLSManager::parse_dl_params(std::ifstream &dls_fstream, DL_STATE &dl_state) } -void DLSManager::writeDLS(const std::string& dls_file, DABCharset charset, bool raw_dls, bool remove_dls) { +void DLSManager::writeDLS(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; } - DL_STATE dl_state; - - std::vector<std::string> dls_lines; - std::string line; // Read and convert lines one by one because the converter doesn't understand // line endings @@ -206,7 +205,7 @@ void DLSManager::writeDLS(const std::string& dls_file, DABCharset charset, bool if (line == DL_PARAMS_OPEN) { parse_dl_params(dls_fstream, dl_state); } else { - if (not raw_dls && charset == DABCharset::UTF8) { + if (not dl_params.raw_dls && dl_params.charset == DABCharset::UTF8) { dls_lines.push_back(charset_converter.convert(line)); } else { @@ -219,14 +218,14 @@ void DLSManager::writeDLS(const std::string& dls_file, DABCharset charset, bool std::stringstream ss; for (size_t i = 0; i < dls_lines.size(); i++) { if (i != 0) { - if (charset == DABCharset::UCS2_BE) + if (dl_params.charset == DABCharset::UCS2_BE) ss << '\0' << '\n'; else ss << '\n'; } // UCS-2 BE: if from file the first byte of \0\n remains, remove it - if (charset == DABCharset::UCS2_BE && dls_lines[i].size() % 2) { + if (dl_params.charset == DABCharset::UCS2_BE && dls_lines[i].size() % 2) { dls_lines[i].resize(dls_lines[i].size() - 1); } @@ -242,9 +241,6 @@ void DLSManager::writeDLS(const std::string& dls_file, DABCharset charset, bool if (dl_state.dl_plus_enabled && dl_state.dl_plus_tags.empty()) dl_state.dl_plus_tags.push_back(DL_PLUS_TAG()); - if (not raw_dls) - charset = DABCharset::COMPLETE_EBU_LATIN; - // toggle the toggle bit only on new DL state bool dl_state_is_new = dl_state != dl_state_prev; @@ -267,7 +263,7 @@ void DLSManager::writeDLS(const std::string& dls_file, DABCharset charset, bool DATA_GROUP *remove_label_dg = NULL; if (dl_state_is_new) { - if (remove_dls) + if (dl_params.remove_dls) remove_label_dg = createDynamicLabelCommand(DLS_CMD_REMOVE_LABEL); dls_toggle = !dls_toggle; // indicate changed text @@ -275,7 +271,7 @@ void DLSManager::writeDLS(const std::string& dls_file, DABCharset charset, bool dl_state_prev = dl_state; } - prepend_dl_dgs(dl_state, charset); + prepend_dl_dgs(dl_state, dl_params.raw_dls ? dl_params.charset : DABCharset::COMPLETE_EBU_LATIN); if (remove_label_dg) pad_packetizer->AddDG(remove_label_dg, true); } |