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
Use std::variant in ManifestYamlPopulator #4081
Conversation
This comment has been minimized.
This comment has been minimized.
{ "ProductCode", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->ProductCode = value.as<std::string>(); return {}; } }, | ||
{ | ||
"InstallerType", | ||
[forRootFields](const YAML::Node& value, std::any& any)->ValidationErrors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fragile, I would really prefer to avoid a capture. But I'm guessing it isn't nearly as easy to do as it is to say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried splitting GetRootFieldProcessInfo
and calling ValidateAndProcessFields with root, root installer and root localization separately. but that will result in several ManifestError::FieldUnknown
warning. I don't want to deal with looking at the errors and remove them.
I removed the capture, but it still needs to any_cast to manifest or installer/localization. I'm not sure if the capture is better than this try catch approach.
}, | ||
{ | ||
"Documentations", | ||
[this, forRootFields](const YAML::Node& value, std::any& any)->ValidationErrors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the point of this was to get rid of the this
capture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get rid of it in all of them :(
You are going to hate me, but I think |
This PR uses
std::variant
instead of member pointers to manifest structs to be references used by the processing functions.std::variant
contains pointers to manifest structs to be populated and is passed to theFieldProcessInfo.ProcessFunc
. Each processing function is responsible of callingstd::get
orstd::get_if
with the correct pointer type.ValidateAndProcessFields
takes thestd::variant
and pass it to the processing functions.Processing functions that required the member types now take a pointer to the manifest struct. Some of these can go in the anonymous namespace, but I didn't want to add more moves.
The change will make implementing shadow manifests easier.