Skip to content

Commit 2e2880f

Browse files
committed
Add variant .add_udl_assoc(map<str,str>) to add multiple UDL at once
1 parent d2021d7 commit 2e2880f

2 files changed

Lines changed: 41 additions & 8 deletions

File tree

src/Classes/OverrideMapUpdaterClass.cpp

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ OverrideMapUpdater::OverrideMapUpdater(void)
4646
pAssociationMap = pFunctionList->InsertNewChildElement("associationMap");
4747

4848
pAssociationMap->InsertEndChild(
49-
pOverrideMapXML->NewComment("\r\n"
50-
"\t\t\tSee https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/installer/functionList/overrideMap.xml for the \"official\" default for this file\r\n"
51-
"\t\t\t\tincluding the default id-vs-langID values\r\n"
52-
"\r\n"
53-
"\t\t\tEach functionlist parse rule links to a language ID(\"langID\") or a UDL name.\r\n"
54-
"\t\t\tExamples:\r\n"
55-
"\t\t\t\t<association id=\"my_perl.xml\" langID=\"21\" />\r\n"
56-
"\t\t\t\t<association id=\"nppexec.xml\" userDefinedLangName=\"NppExec\" />\r\n"
49+
pOverrideMapXML->NewComment(
50+
" \n"
51+
" See https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/installer/functionList/overrideMap.xml for the \"official\" default for this file\n"
52+
" tincluding the default id-vs-langID values\n"
53+
" \n"
54+
" Each functionlist parse rule links to a language ID(\"langID\") or a UDL name.\n"
55+
" Examples:\n"
56+
" <association id=\"my_perl.xml\" langID=\"21\" />\n"
57+
" <association id=\"nppexec.xml\" userDefinedLangName=\"NppExec\" />\n"
58+
" "
5759
)
5860
);
5961
pAssociationMap->InsertEndChild(
@@ -94,9 +96,36 @@ tinyxml2::XMLElement* OverrideMapUpdater::add_udl_assoc(std::string sFilename, s
9496
return pAssoc;
9597
}
9698

99+
// add <association> tags for each filename,udl pair in the map
100+
std::vector<tinyxml2::XMLElement*> OverrideMapUpdater::add_udl_assoc(std::map<std::string, std::string> msUdls)
101+
{
102+
std::vector<tinyxml2::XMLElement*> vpAssoc;
103+
for (const auto& pair : msUdls) {
104+
vpAssoc.push_back(add_udl_assoc(pair.first, pair.second));
105+
}
106+
return vpAssoc;
107+
}
108+
109+
// add <association> tags for each filename,udl pair in the map
110+
std::vector<tinyxml2::XMLElement*> OverrideMapUpdater::add_udl_assoc(std::map<std::wstring, std::wstring> mwsUdls)
111+
{
112+
std::vector<tinyxml2::XMLElement*> vpAssoc;
113+
for (const auto& pair : mwsUdls) {
114+
vpAssoc.push_back(add_udl_assoc(pair.first, pair.second));
115+
}
116+
return vpAssoc;
117+
}
118+
97119
bool OverrideMapUpdater::experiment(void)
98120
{
99121
add_udl_assoc("fake.xml", "FakeUDL");
122+
std::map<std::wstring, std::wstring> myMap = {
123+
{L"udl1.xml", L"UDL 1"},
124+
{L"udl2.xml", L"UDL 2"},
125+
{L"udl3.xml", L"UDL 3"}
126+
};
127+
add_udl_assoc(myMap);
100128
pOverrideMapXML->SaveFile(sOverMapPath().c_str());
129+
101130
return true;
102131
}

src/Classes/OverrideMapUpdaterClass.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class OverrideMapUpdater {
2424
tinyxml2::XMLElement* OverrideMapUpdater::add_udl_assoc(std::wstring wsFilename, std::wstring wsUDLname);
2525
tinyxml2::XMLElement* OverrideMapUpdater::add_udl_assoc(std::string sFilename, std::string sUDLname);
2626

27+
// add <association> tags for each filename,udl pair in the map
28+
std::vector<tinyxml2::XMLElement*> OverrideMapUpdater::add_udl_assoc(std::map<std::wstring, std::wstring> mwsUdls);
29+
std::vector<tinyxml2::XMLElement*> OverrideMapUpdater::add_udl_assoc(std::map<std::string, std::string> msUdls);
30+
2731
// getters
2832
std::wstring wsOverMapPath(void) { return _wsOverMapPath; }
2933
std::string sOverMapPath(void) { return pcjHelper::wstring_to_utf8(_wsOverMapPath); }

0 commit comments

Comments
 (0)