Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintain config declaration order #1302

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions application/F3DOptionsParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ class ConfigurationOptions
bool ret = false;
if (this->FilePathForConfigBlock.empty())
{
auto localIt = this->GlobalConfigDicEntry.find(option);
if (localIt != this->GlobalConfigDicEntry.end())
auto localIt = this->GlobalConfigEntry.find(option);
if (localIt != this->GlobalConfigEntry.end())
{
configValue = localIt->second;
ret = true;
}
}
else
{
for (auto const& it : this->ConfigDic)
for (auto const& it : this->RegexConfigEntries)
{
std::regex re(it.first, std::regex_constants::icase);
std::smatch matches;
Expand Down Expand Up @@ -204,10 +204,10 @@ class ConfigurationOptions

std::string FilePathForConfigBlock;

using DictionaryEntry = std::map<std::string, std::string>;
using Dictionary = std::map<std::string, DictionaryEntry>;
DictionaryEntry GlobalConfigDicEntry;
Dictionary ConfigDic;
using ConfigEntry = std::map<std::string, std::string>;
using ConfigEntries = std::vector<std::pair<std::string, ConfigEntry> >;
ConfigEntry GlobalConfigEntry;
ConfigEntries RegexConfigEntries;
std::string ExecutableName;
std::vector<std::string> AllLongOptions;
};
Expand Down Expand Up @@ -671,7 +671,7 @@ void ConfigurationOptions::PrintReadersList()
//----------------------------------------------------------------------------
bool ConfigurationOptions::InitializeDictionaryFromConfigFile(const std::string& config)
{
this->ConfigDic.clear();
this->RegexConfigEntries.clear();

std::string configSearch = "config";
if (!config.empty())
Expand Down Expand Up @@ -746,7 +746,7 @@ bool ConfigurationOptions::InitializeDictionaryFromConfigFile(const std::string&
return false;
}

nlohmann::json json;
nlohmann::ordered_json json;
try
{
file >> json;
Expand Down Expand Up @@ -779,11 +779,11 @@ bool ConfigurationOptions::InitializeDictionaryFromConfigFile(const std::string&
}
if (regexpConfig.key() == "global")
{
this->GlobalConfigDicEntry = localDic;
this->GlobalConfigEntry = localDic;
}
else
{
this->ConfigDic[regexpConfig.key()] = localDic;
this->RegexConfigEntries.emplace_back(regexpConfig.key(), localDic);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ f3d_test(NAME TestInvalidUpDirection DATA suzanne.ply ARGS -g --up=W REGEXP "W i
f3d_test(NAME TestUpDirectionNoSign DATA suzanne.ply ARGS --up=X DEFAULT_LIGHTS)
f3d_test(NAME TestTextureMatCap DATA suzanne.ply ARGS --texture-matcap=${F3D_SOURCE_DIR}/testing/data/skin.png DEFAULT_LIGHTS)
f3d_test(NAME TestTextureMatCapWithTCoords DATA WaterBottle.glb ARGS --geometry-only --texture-matcap=${F3D_SOURCE_DIR}/testing/data/skin.png DEFAULT_LIGHTS)
f3d_test(NAME TestConfigOrder DATA suzanne.ply ARGS CONFIG ${F3D_SOURCE_DIR}/testing/data/config-order.json DEFAULT_LIGHTS)

# Needs SSBO: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10675
if(VTK_VERSION VERSION_GREATER_EQUAL 9.3.20231108)
Expand Down
3 changes: 3 additions & 0 deletions testing/baselines/TestConfigOrder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions testing/data/config-order.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong location for this file

Git LFS file not shown
Loading