diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 317acca..f3ec5bc 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -15,14 +15,14 @@ RUN apk add --no-cache --virtual .build-tools git g++ build-base linux-headers c cc -c -O3 -o duk_module_node.o -I. ../extras/module-node/duk_module_node.c && \ ar cr libduktape.a duktape.o && \ ar cr libduktape_module.a duk_module_node.o && \ - install -m0644 *.a /usr/lib && \ + install -m0644 ./*.a /usr/lib && \ install -m0644 duk*.h /usr/include && \ install -m0644 ../extras/module-node/duk_module_node.h /usr/include && \ cd ../../../.. && \ rm -rf duktape /usr/lib/python2.7 && \ git clone https://github.com/tindy2013/subconverter --depth=1 && \ cd subconverter && \ - cmake . && \ + cmake -DCMAKE_BUILD_TYPE=Release . && \ make -j4 && \ mv subconverter base/ && \ mv base ../ && \ diff --git a/scripts/build.alpine.release.sh b/scripts/build.alpine.release.sh index 8bdcc83..875c617 100644 --- a/scripts/build.alpine.release.sh +++ b/scripts/build.alpine.release.sh @@ -33,7 +33,7 @@ install -m0644 ../extras/module-node/duk_module_node.h /usr/include cd ../../../.. export PKG_CONFIG_PATH=/usr/lib64/pkgconfig -cmake . +cmake -DCMAKE_BUILD_TYPE=Release . make -j2 rm subconverter g++ -o base/subconverter $(find CMakeFiles/subconverter.dir/src/ -name "*.o") -static -lpcre2-8 -levent -lyaml-cpp -L/usr/lib64 -lcurl -lmbedtls -lmbedcrypto -lmbedx509 -lz -lduktape -lduktape_module -O3 -s diff --git a/scripts/build.macos.release.sh b/scripts/build.macos.release.sh index c05bc59..06f0e6e 100644 --- a/scripts/build.macos.release.sh +++ b/scripts/build.macos.release.sh @@ -32,14 +32,11 @@ install -m0644 ./duk*.h /usr/local/include install -m0644 ../extras/module-node/duk_module_node.h /usr/local/include cd ../../../.. -cp curl/lib/libcurl.a . -cp yaml-cpp/libyaml-cpp.a . -cp duktape/dist/source/src/*.a . cp /usr/local/lib/libevent.a . cp /usr/local/opt/zlib/lib/libz.a . cp /usr/local/lib/libpcre2-8.a . -cmake . +cmake -DCMAKE_BUILD_TYPE=Release . make -j8 rm subconverter c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter -framework CoreFoundation -framework Security $(find CMakeFiles/subconverter.dir/src/ -name "*.o") $(find . -name "*.a") -O3 diff --git a/src/ini_reader.h b/src/ini_reader.h index b37b3c6..df7b019 100644 --- a/src/ini_reader.h +++ b/src/ini_reader.h @@ -38,7 +38,7 @@ private: std::string current_section; ini_data_struct ini_content; string_array exclude_sections, include_sections, direct_save_sections; - string_array read_sections, section_order; + string_array section_order; std::string cached_section; ini_data_struct::iterator cached_section_content; @@ -113,7 +113,7 @@ public: bool allow_dup_section_titles = false; /** - * @brief Keep an empty section while parsing + * @brief Keep an empty section while parsing. */ bool keep_empty_section = true; @@ -145,7 +145,6 @@ public: current_section = src.current_section; exclude_sections = src.exclude_sections; include_sections = src.include_sections; - read_sections = src.read_sections; section_order = src.section_order; isolated_items_section = src.isolated_items_section; //copy preferences @@ -153,6 +152,7 @@ public: store_any_line = src.store_any_line; store_isolated_line = src.store_isolated_line; allow_dup_section_titles = src.allow_dup_section_titles; + keep_empty_section = src.keep_empty_section; return *this; } @@ -215,6 +215,7 @@ public: bool inExcludedSection = false, inDirectSaveSection = false; std::string strLine, thisSection, curSection, itemName, itemVal; string_multimap itemGroup, existItemGroup; + string_array read_sections; std::stringstream strStrm; char delimiter = getLineBreak(content); @@ -805,6 +806,9 @@ public: return current_section.size() ? SetArray(current_section, itemName, separator, Array) : -1; } + /** + * @brief Rename an existing section. + */ int RenameSection(const std::string &oldName, const std::string &newName) { if(!SectionExist(oldName) || SectionExist(newName)) @@ -880,7 +884,6 @@ public: cached_section_content = ini_content.end(); cached_section.erase(); } - //section_order.erase(std::find(section_order.begin(), section_order.end(), section)); } /** @@ -892,6 +895,31 @@ public: EraseSection(current_section); } + /** + * @brief Remove a section from INI. + */ + void RemoveSection(const std::string §ion) + { + if(ini_content.find(section) == ini_content.end()) + return; + ini_content.erase(section); + if(cached_section == section) + { + cached_section.clear(); + cached_section_content = ini_content.end(); + } + section_order.erase(std::find(section_order.begin(), section_order.end(), section)); + } + + /** + * @brief Remove current section from INI. + */ + void RemoveSection() + { + if(current_section.size()) + RemoveSection(current_section); + } + /** * @brief Export the whole INI data structure into a string. */