Skip to content

Commit

Permalink
Merge pull request #1302 from snoyer/config-order
Browse files Browse the repository at this point in the history
maintain config declaration order
  • Loading branch information
mwestphal authored Mar 8, 2024
2 parents 7bc53ec + cb9471a commit 680aff9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
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
Git LFS file not shown

0 comments on commit 680aff9

Please sign in to comment.