Commit 003f9f9b authored by GILLES Sebastien's avatar GILLES Sebastien

#1468 Rewrite completely the way to compute the list of entry keys. It needs heavy-clean-up though!

parent 80337e43
......@@ -127,6 +127,18 @@ namespace MoReFEM
};
struct Section
{
std::string name;
std::size_t min;
std::size_t max;
};
void AddValueIn(lua_State* lua_state)
{
std::string code = "function value_in(v, table)\
......@@ -358,6 +370,8 @@ namespace MoReFEM
// Filter out the braces without values inside: they were Lua vectors and not sections.
std::vector<std::pair<int, int>> filtered_pair_list;
for (const auto& pair : pair_list)
{
const auto opening = pair.first;
......@@ -398,23 +412,38 @@ namespace MoReFEM
}
std::vector<Section> section_list;
for (auto i = 0ul; i < Npair; ++i)
{
const auto opening_brace = filtered_pair_list[i].first;
auto reverse_it = name_list.rbegin();
// Using standard iterators instead of reverse ones as I want to use erase and conversion with
// normal iterators is shall we say headache prone...
auto it = name_list.end();
--it;
auto end = name_list.begin();
--end;
for (; reverse_it != name_list.rend(); ++reverse_it)
for (; it != end; --it)
{
if (reverse_it->position < opening_brace)
if (it->position < opening_brace)
break;
}
std::cout << reverse_it->name << "\n";
assert(reverse_it != name_list.rend());
std::cout << it->name << "\n";
assert(it != end);
Section section;
section.min = opening_brace;
section.max = filtered_pair_list[i].second;
section.name = it->name;
section_list.push_back(section);
std::cout << "PAIR " << opening_brace << " => lower = " << it->position << " and " << it->name << std::endl;
std::cout << "PAIR " << opening_brace << " => lower = " << reverse_it->position << " and " << reverse_it->name << std::endl;
name_list.erase(it);
// std::cout << name_list[it - equal_position_list.cbegin()] << " -> ";
// Utilities::PrintTuple(pair_list[i]);
......@@ -425,27 +454,34 @@ namespace MoReFEM
}
std::sort(section_list.begin(),
section_list.end(),
[](const auto& lhs, const auto& rhs)
{
return lhs.min < rhs.min;
});
// Reconstruct names.
std::vector<std::string> ret;
for (const auto& name : name_list)
{
// auto Nopening_brace = (std::count(content.cbegin(), content.cend(), '{'));
// auto Nclosing_brace = (std::count(content.cbegin(), content.cend(), '}'));
//
// if (Nopening_brace != Nclosing_brace)
// {
// oconv << "Invalid Lua file (" << path << "): " << Nopening_brace << " '{' were found whereas there "
// "were " << Nclosing_brace << " '}'; the numbers should match!";
// throw Exception(oconv.str(), __FILE__, __LINE__);
// }
oconv.str("");
std::cout << oconv.str() << std::endl;
for (const auto& section : section_list)
{
if (name.position > section.min && name.position < section.max)
oconv << section.name << '.';
}
std::vector<std::string> ret;
oconv << name.name;
ret.push_back(oconv.str());
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment