-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor Sprite XML loading code #797
Comments
It would be helpful to have template code that could parameterized with an arbitrary There is no reflection in C++ that would allow automatic extraction of Usage might look something like: struct SomeData {
int field1;
std::string field2;
};
const auto someData = SomeData{1, "data"};
const auto dictionary = structToDictionary<"fieldName1", "fieldName2">(dataStruct);
EXPECT_EQ(Dictionary{{{"fieldName1", 1}, {"fieldName2", "data"}}}, dictionary); To support the above, I was doing a bit of reading on templates. The structured binding feature can be used to some advantage here, though there is still a problem of determining how many fields are in any given |
I was just thinking, if we require the programmer to specify text strings for each field name, then we can already infer the expected number of fields in a Given the number of fields in the struct, the next problem would be to determine the type of each struct field by index. This may relate to determining the type of a References: |
The author of magic_get has a couple of C++ talks on the development of the library. They are both basically the same talk, though the later with a few updates, including use of C++17's destructuring feature.
Another interesting discussion was about the use of string constants as template non-type parameters. Apparently it was not really possible before C++11 due to issues of internal versus external linkage. Since then some interesting styles were developed for doing this. |
Related: #739, #211
The
Sprite
XML loading code should be examined and refactored. One goal here is to limit the use of XML code, such that it can be largely decoupled from the NAS2D library. This may make it easier to remove the TinyXML dependency from direct inclusion, allowing us to switch tovcpkg
dependency installation, while also making it easier to transition to TinyXML2.One feature needed by the
Sprite
code that is absent from theConfiguration
code is the ability to process arrays of data (the frame list).Similar to the
Configuration
code, we may need to report errors due to missing required keys, or for extra unexpected keys which are neither required nor optional. This is likely to be true whether the we use XML, or JSON, or some other text format to store the data, so such error detecting and reporting code may need to be general and accessible to all such text processing methods.The text was updated successfully, but these errors were encountered: