Skip to content

Commit d2021d7

Browse files
committed
CollectionInterface: OverrideMapUpdater has method to add association
1 parent 274896d commit d2021d7

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

src/Classes/OverrideMapUpdaterClass.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ OverrideMapUpdater::OverrideMapUpdater(void)
5959
pAssociationMap->InsertEndChild(
6060
pOverrideMapXML->NewComment(" ==================== User Defined Languages ============================ ")
6161
);
62+
6263

63-
tinyxml2::XMLElement* pAssoc = pAssociationMap->InsertNewChildElement("association");
64-
pAssoc->SetAttribute("id", "nppexec.xml");
65-
pAssoc->SetAttribute("userDefinedLangName", "NppExec");
64+
/*tinyxml2::XMLElement* pAssoc =*/ add_udl_assoc("nppexec.xml", "NppExec");
6665
}
6766
else {
6867
// TODO: !!! NEED TO ADD ERROR CHECKING !!!
@@ -74,7 +73,30 @@ OverrideMapUpdater::OverrideMapUpdater(void)
7473
}
7574
}
7675

76+
// add an <association> tag for a given UDL
77+
// converts wstring to string first
78+
tinyxml2::XMLElement* OverrideMapUpdater::add_udl_assoc(std::wstring wsFilename, std::wstring wsUDLname)
79+
{
80+
return add_udl_assoc(
81+
pcjHelper::wstring_to_utf8(wsFilename),
82+
pcjHelper::wstring_to_utf8(wsUDLname)
83+
);
84+
}
85+
86+
// add an <association> tag for a given UDL
87+
tinyxml2::XMLElement* OverrideMapUpdater::add_udl_assoc(std::string sFilename, std::string sUDLname)
88+
{
89+
tinyxml2::XMLElement* pAssoc = pAssociationMap->InsertNewChildElement("association");
90+
if (pAssoc) {
91+
pAssoc->SetAttribute("id", sFilename.c_str());
92+
pAssoc->SetAttribute("userDefinedLangName", sUDLname.c_str());
93+
}
94+
return pAssoc;
95+
}
96+
7797
bool OverrideMapUpdater::experiment(void)
7898
{
79-
return false;
99+
add_udl_assoc("fake.xml", "FakeUDL");
100+
pOverrideMapXML->SaveFile(sOverMapPath().c_str());
101+
return true;
80102
}

src/Classes/OverrideMapUpdaterClass.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class OverrideMapUpdater {
2020
// Experiment with concepts needed, might eventually morph into actual behavior
2121
bool experiment(void);
2222

23+
// add an <association> tag for a given UDL
24+
tinyxml2::XMLElement* OverrideMapUpdater::add_udl_assoc(std::wstring wsFilename, std::wstring wsUDLname);
25+
tinyxml2::XMLElement* OverrideMapUpdater::add_udl_assoc(std::string sFilename, std::string sUDLname);
26+
2327
// getters
2428
std::wstring wsOverMapPath(void) { return _wsOverMapPath; }
2529
std::string sOverMapPath(void) { return pcjHelper::wstring_to_utf8(_wsOverMapPath); }

0 commit comments

Comments
 (0)