stevemarple / IniFile

Arduino library to parse ini files.
GNU Lesser General Public License v2.1
87 stars 45 forks source link

Added function to browse through all sections of an ini file #28

Closed kaixxx closed 3 years ago

kaixxx commented 3 years ago

Allows to browse through an ini file with an unknown number of sections which all contain the same elements. This can be useful to store different profiles which are selectable on the device. I use it for reflow profiles in my arduino controlled lab oven. I have also added an example.

stevemarple commented 3 years ago

This looks useful but sadly the regression test fails to compile with this error:

IniFile.h:130:7: error: extra qualification ‘IniFile::’ on member ‘browseSections’ [-fpermissive]
  bool IniFile::browseSections(char* buffer, size_t len, IniFileState &state) const;

With the IniFile:: qualification removed the regression test compiles and passes. It would be nice to see some a new regression test added to extras/test, probably based off of your IniBrowserExample.ino example but we can add that later.

Can you please fix the compile issue and update the pull request (ideally squishing the the commits into one)? You can also add your name to the end of the contributors list in the same format as used for the other names.

kaixxx commented 3 years ago

Sorry for the error. It compiled fine in Arduino so I didn't notice. Hiding my mistake by changing the initial commit is not possible in GitHub Desktop (which I use), so I made a second commit. I hope that's ok. Thank you very much for this great library! I am happy to contribute a little bit. Best Kai

stevemarple commented 3 years ago

I squished your second commit into the first and merged into the master branch. I'd like to have a test for the new functionality so I'll not close this issue just yet - I think I can use your example code to generate and then I'll post back here.

stevemarple commented 3 years ago

I've modified the regression test program to include a test for the browseSections() function. This approach isn't as powerful as proper unit testing but it is a very convenient way to check that future changes don't inadvertently break or change existing behaviour and has caught bugs in the past.

I also added a line break to your example as the comment was longer than the 80 character buffer set in the example.

kaixxx commented 3 years ago

Great! Thank you very much. I think this can be closed now.

stevemarple commented 3 years ago

Thank you very much for your contribution. I'll close the issue and bump the version number so that the changes can be downloaded via the Arduino IDE.