Skip to content

Commit

Permalink
Auto-format code changes (#650)
Browse files Browse the repository at this point in the history
Auto-format code using Clang-Format

Co-authored-by: GitHub Actions <actions@github.com>
  • Loading branch information
github-actions[bot] and actions-user authored Sep 9, 2024
1 parent 5299039 commit da3f40a
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions include/micm/configure/solver_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ namespace micm
{
config_file = config_dir / DEFAULT_CONFIG_FILE_YAML;
}
else{
else
{
config_file = config_dir / DEFAULT_CONFIG_FILE_JSON;
}
}
}
else
{
Expand Down Expand Up @@ -227,7 +228,7 @@ namespace micm
{
YAML::Emitter out;
out << config_subset;
throw std::system_error{ make_error_code(MicmConfigErrc::CAMPDataNotFound), out.c_str()};
throw std::system_error{ make_error_code(MicmConfigErrc::CAMPDataNotFound), out.c_str() };
}
// Iterate YAML objects from CAMP data entry
for (const auto& object : config_subset[CAMP_DATA])
Expand All @@ -240,7 +241,7 @@ namespace micm
YAML::Emitter out;
out << object;
std::string msg = "object: " + std::string(out.c_str()) + "; type: " + TYPE;

throw std::system_error{ make_error_code(MicmConfigErrc::ObjectTypeNotFound), msg };
}
// Sort into object arrays by type
Expand Down Expand Up @@ -374,26 +375,26 @@ namespace micm
const std::string THIRD_BODY = "THIRD_BODY";

ValidateSchema(object, { NAME, TYPE }, { TRACER_TYPE, ABS_TOLERANCE, DIFFUSION_COEFF, MOL_WEIGHT });

std::string name = object[NAME].as<std::string>();
Species species{ name };

// Load remaining keys as properties
for(auto it = object.begin(); it != object.end(); ++it)
for (auto it = object.begin(); it != object.end(); ++it)
{
auto key = it->first.as<std::string>();
auto value = it->second;
if(key.empty())

if (key.empty())
{
throw std::system_error{ make_error_code(MicmConfigErrc::InvalidType), key };
}

if (key != NAME && key != TYPE)
{
{
std::string stringValue = value.as<std::string>();

if(stringValue.empty())
if (stringValue.empty())
{
species.SetProperty<std::string>(key, stringValue);
}
Expand All @@ -412,12 +413,12 @@ namespace micm
else if (key == TRACER_TYPE && stringValue == THIRD_BODY)
{
species.SetThirdBody();
}
}
else
{
species.SetProperty<std::string>(key, stringValue);
}
}
}
}
}
species_[name] = species;
}
Expand Down Expand Up @@ -447,7 +448,7 @@ namespace micm
for (auto it = object.begin(); it != object.end(); ++it)
{
auto key = it->first.as<std::string>();
auto value = it->second;
auto value = it->second;

std::size_t qty = 1;
ValidateSchema(value, {}, { "qty" });
Expand All @@ -468,7 +469,7 @@ namespace micm
for (auto it = object.begin(); it != object.end(); ++it)
{
auto key = it->first.as<std::string>();
auto value = it->second;
auto value = it->second;

ValidateSchema(value, {}, { "yield" });
auto species = species_[key];
Expand Down Expand Up @@ -831,21 +832,21 @@ namespace micm
// Utility functions to check types and perform conversions
bool IsBool(const std::string& value)
{
return (value == "true" || value == "false");
return (value == "true" || value == "false");
}

bool IsInt(const std::string& value)
{
std::istringstream iss(value);
int result;
return (iss >> result >> std::ws).eof(); // Check if the entire string is an integer
std::istringstream iss(value);
int result;
return (iss >> result >> std::ws).eof(); // Check if the entire string is an integer
}

bool IsFloat(const std::string& value)
{
std::istringstream iss(value);
float result;
return (iss >> result >> std::ws).eof(); // Check if the entire string is a float
std::istringstream iss(value);
float result;
return (iss >> result >> std::ws).eof(); // Check if the entire string is a float
}

/// @brief Search for nonstandard keys. Only nonstandard keys starting with __ are allowed. Others are considered typos
Expand All @@ -871,7 +872,8 @@ namespace micm
}

std::vector<std::string> sorted_object_keys;
for (auto it = object.begin(); it != object.end(); ++it) {
for (auto it = object.begin(); it != object.end(); ++it)
{
std::string key = it->first.as<std::string>();
sorted_object_keys.push_back(key);
}
Expand Down Expand Up @@ -903,7 +905,8 @@ namespace micm
sorted_object_keys.end(),
std::back_inserter(missing_keys));
std::string msg;
for (auto& key : missing_keys){
for (auto& key : missing_keys)
{
msg += "Missing required key '" + key + "' in object: " + out.c_str() + "\n";
}

Expand Down

0 comments on commit da3f40a

Please sign in to comment.