Rookfighter / inifile-cpp

A header-only and easy to use Ini file parser for C++.
MIT License
363 stars 68 forks source link

Disable program crash if invalid input #30

Closed UnrealKaraulov closed 1 year ago

UnrealKaraulov commented 1 year ago

Program crashes if invalid input found.

Need "bypass errors" option :)

Rookfighter commented 1 year ago

@UnrealKaraulov

Maybe you can present the contents of a ini-file which causes a crash, so it gets clearer, what your exact problem is.

UnrealKaraulov commented 1 year ago

@UnrealKaraulov

Maybe you can present the contents of a ini-file which causes a crash, so it gets clearer, what your exact problem is.

Missing keys in any input ini file.

UnrealKaraulov commented 1 year ago

Or bad value in ini file.

@Rookfighter author, if you provide ini file without possibility to manual edit.... For what you use ini file format? You can just use directly any binary format....:)

Rookfighter commented 1 year ago

@UnrealKaraulov Maybe you can present the contents of a ini-file which causes a crash, so it gets clearer, what your exact problem is.

Missing keys in any input ini file.

You can easily check the existance of a key the same way as you do for std::map (all the types in this library are derived from std::map).

Rookfighter commented 1 year ago

Or bad value in ini file.

@Rookfighter author, if you provide ini file without possibility to manual edit.... For what you use ini file format? You can just use directly any binary format....:)

There are many use-cases, e.g. as machine interchange format, saving internal state or simply as configuration file. Now, there are two things here:

On one side you can edit ini files manually and read them with inifile-cpp, e.g. configuration files. However, this is an architectural question of your application and may not apply for you.

On the other side if this architectural paradigm does not apply for your use-case you can also simply fork this library and adjust it to your needs (it's MIT licensed after all). This library is just a few hundred lines so you could easily rewrite it anyways.