4

I often find myself needing to write functions to load/save from/to ASCII (or similar) text files; such as config files or data. I can and have done so many times but never feel like I do it well. ie the results are not very tolerant of minor changes to the file format.

Can anyone point me to a good guide to writing robust text file io or even better some libraries to make it easier?

trepanated
  • 43
  • 2
  • It's kinda subjective. Depends a lot on the file format – Kiril Kirov May 31 '11 at 13:53
  • 2
    Your concerns are legitimate: its usually way easier and more maintainable to use an existing format with an existing library. Of course, it mainly depends on what your files are for (data is a wide term) and you haven't given any information about that. – ereOn May 31 '11 at 13:54
  • Possible duplicate of http://stackoverflow.com/questions/147902/linux-configuration-file-libraries – Chris Eberle May 31 '11 at 13:56

2 Answers2

5

Off the top of my head, there's:

Both of these are pretty standard under linux.

Chris Eberle
  • 47,994
  • 12
  • 82
  • 119
2

YAML is a really good choice. Here we use yaml-cpp

my2c

neuro
  • 14,948
  • 3
  • 36
  • 59