From d7595c483a9a7b480841bb9e8588e7a566bbb82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Wed, 21 Mar 2018 18:30:04 +0100 Subject: [PATCH] gmic_parser: fix parsing + add "About" plugin --- Helpers/gmic_parser.cpp | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Helpers/gmic_parser.cpp b/Helpers/gmic_parser.cpp index 2b033af..f87b7c8 100644 --- a/Helpers/gmic_parser.cpp +++ b/Helpers/gmic_parser.cpp @@ -242,7 +242,9 @@ string gmic_parse_single(const string& content, EffectData& cd) { const string src_prefix_old = src_prefix_old_c; const string src_prefix = src_prefix_c; + const string src_prefix_en = src_prefix + "_en"; const string dst_prefix = dst_prefix_c; + const string dst_prefix_en = dst_prefix + "_en"; string result; bool inNote = false; bool inChoice = false; @@ -255,10 +257,13 @@ string gmic_parse_single(const string& content, EffectData& cd) vector lines; strSplit(content, '\n', lines); for (int i = 0; i < (int)lines.size(); i++) { + printf("[%d]: %s\n", i,lines[i].c_str()); string line = strTrim(lines[i], " \r\n\t"); if (line.size() > 0 && line[0] != '#') result += line + "\n"; strReplace(line, src_prefix_old, dst_prefix); + strReplace(line, src_prefix_en, dst_prefix); strReplace(line, src_prefix, dst_prefix); + strReplace(line, dst_prefix_en, dst_prefix); string n = strTrim(line, " \r\n\t"); int sPos = (int)line.find(":"); int sPos2 = (int)line.find("#"); @@ -350,18 +355,13 @@ string gmic_parse_single(const string& content, EffectData& cd) cd.multiLayer = true; else cd.multiLayer = false; - cd.uniqueId = getUniqueId(cd.name); cd.notes = strTrim(cd.notes, "\n"); -#ifdef OFX_PLUGIN - strReplace(cd.name, "&", "&&"); - strReplace(cd.category, "&", "&&"); - strReplace(cd.notes, "&", "&&"); -#else - strReplace(cd.name, "&", "&"); - strReplace(cd.category, "&", "&"); - strReplace(cd.notes, "&", "&"); -#endif + cd.name = strRemoveXmlTags(cd.name, true); + cd.category = strRemoveXmlTags(cd.category, true); + cd.notes = strRemoveXmlTags(cd.notes, true); + cd.uniqueId = getUniqueId(cd.name); + return result; } @@ -377,6 +377,7 @@ void gmic_parse_multi(const string& content, vector* cds, vector* cds, vector= 0) { + if (cd.category == "About" && cd.uniqueId != "eu.gmic.AboutGMIC") { doOutput = false; } else if ((int)strLowercase(cd.category).find("various") >= 0) { doOutput = false; @@ -405,13 +406,6 @@ void gmic_parse_multi(const string& content, vector* cds, vector 1) { - cd.name = "G'MIC " + cd.name; - strReplace(cd.name, "[", ""); - strReplace(cd.name, "]", ""); - strReplace(cd.name, " - ", " "); - strReplace(cd.name, "inverse", "inv."); - //cd.category = "G'MIC " + cd.category; -cd.category = "GMIC/" + cd.category; if (cds) cds->push_back(cd); if (lines) lines->push_back(line2); } @@ -423,6 +417,20 @@ cd.category = "GMIC/" + cd.category; } } } + for (vector::iterator it = cds->begin(); it != cds->end(); ++it) { + // post-process + EffectData& cd = *it; + if (cd.category == "About") { + cd.category = "GMIC"; + } else { + cd.category = "GMIC/" + cd.category; + cd.name = "G'MIC " + cd.name; + } + strReplace(cd.name, "[", ""); + strReplace(cd.name, "]", ""); + strReplace(cd.name, " - ", " "); + strReplace(cd.name, "inverse", "inv."); + } } }