-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
Rewrite of CInifile
#1543
base: dev
Are you sure you want to change the base?
Rewrite of CInifile
#1543
Conversation
Just out of the top of my head: Do these cases work correct? [sect]
param = "multiline
value"
[sect2]
param = "value" ; single line
[bad_sect]
param = "value ; missing closing quote
; there should be permissive mode in which parser should interpret missing closing quote as single line value and parse until the end of line
; permissive mode should be enabled for Shadow of Chernobyl, but disabled for CS and COP |
The last part no and now I understand why. I couldn't get Shadow of Chernobyl to run and didn't test that. The other ones work as expected. |
SOC ini parser doesn't support multiline values at all, so it just always parse values until the end of the line. For sanity and simplicity I suggest to disable multiline functionality completely for SOC mode, and allow modders to enable it in openxray.ltx, instead of keeping that run-time workaround. And here's the code snippet of the idea: |
Alright thanks for clarifying that.
and without multiline support:
|
Going to run some more tests on the new code and then reopen the PR :) |
649d100
to
1d56768
Compare
Alright testing found no more serious errors. The initialization order is bit complicated and I'm not sure if it's entirely correct.
|
|
Yes you are right. My explanation was wrong 😓 |
Little bit not related to PR itself, but are there easy ways to introduce unit tests for cpp codebase in general? |
Sure just add a testing framework like Catch2 or gtest write a simple test which could just be to test a single function and run them with something like ctest. Both liked frameworks are very easy to setup and have good CMake integration Edit: |
I'd like to highlight https://github.com/doctest/doctest which claims to be the fastest testing frameworks and also very light on compile times. |
Yes although we have to keep in mind that doctest is currently not actively maintained. But the library was and probably is very stable and probably the easiest to integrate since it comes with a single header version. |
I know it is easy to just hang around and leave such comments as mine regarding adding tests, but I would suggest adding it as milestone (issue / task in project etc). It is almost one year since I started rewriting lua codebase with typescript and if I knew total complexity of the project I probably would not even start doing it. Fair to say that C++ part of openxray is even more complex and few times larger Once I changed spacing/align in xml files and game stopped working My point is that it is hard to track such things in PR reviews and even more scary to change when we have few game modes/build types available Once tests are added, easiest things to test could be related to different kind of utils, ini-xml parsers (especially DLTX variant in the future), net packets save-load process where order and type is crucial, planner and other things that do not interfere with global context |
For ini files section names are case insensitive and item name are case sensitive. For the rest I'm not sure. No I totally agree that adding tests is a great idea. I'm actually thinking about adding some basic unit tests for the 2 parsers I worked on now. |
bfa0361
to
ba2ace3
Compare
143d1ca
to
118d39d
Compare
5b2ec76
to
6fffce9
Compare
e89fcc8
to
f6fd5cc
Compare
#include
or inheritance thuswill now be parsed just fine.
first
andsecond
toname
andvalue
CInifile
classxr_ini.h
andxr_ini.cpp