CompactBuilders and guide tips
#2
I'll add even one more setting storage for you to consider: Lua source files (syntactically, doesn't matter what extension they actually use). I use those for my more complicated plugins.

Let's review each one, shall we?
INI:
+ Quite easy to read the file from the plugin (cIniFile class)
+ Easy to write to such a file, and contents such as comments are preserved (good when you insert defaults into settings)
+ Human-readable and -editable file
- Only simple values (numbers, strings) are supported, no support for structures or arrays
- Slight inconvenience with line-endings on Linux
SQLite:
+ Moderately easy to read and write from the plugin (lsqlite module)
+ Good for storing LOTS of data with the same structure, with great performance
- Bad for data with changeable structure
- Not human-readable file, need 3rd party tools for reading and editing
XML:
+ Moderately easy to read from plugin (lxp module)
+ Supports any structure of the stored data (values, structures, arrays)
+ Supports changing the structure between plugin versions (adding or removing a setting)
+ Somewhat human-readable and -editable
- No native support for writing, you need to write a serializer, which is a rather big piece of code
- A bit of a "cannon to shoot birds"
Lua:
+ Extremely simple to read from plugin (loadstring() / loadfile() functions)
+ Supports any structure of the stored data
+ Supports changing the structure between plugin versions
+ Allows dynamic calculations ("NumItems = Server:GetMaxPlayers() * 10")
+ Human-readable and -editable
- Doesn't support writing (would lose formatting, comments and dynamic calculations)

Based on these observations, my recommendations are these:
- For plugins that have very little settings of only basic types, use an INI file
- For all the rest, use Lua files
- Use SQLite for data, not for settings
- Use XML only when you need to consume it from an external source (Web API, for example)
(Note that these are biased by my personal opinion)

If you want some examples, have a look at the Gallery plugin - it uses SQLite for data storage and Lua-based config file:
https://github.com/cuberite/gallery
(Example config file: https://github.com/cuberite/gallery/blob...xample.cfg )
Reply
Thanks given by:


Messages In This Thread
CompactBuilders and guide tips - by warmist - 06-10-2015, 08:11 PM
RE: CompactBuilders and guide tips - by xoft - 06-10-2015, 09:54 PM
RE: CompactBuilders and guide tips - by xoft - 06-10-2015, 09:59 PM
RE: CompactBuilders and guide tips - by xoft - 06-11-2015, 12:17 AM
RE: CompactBuilders and guide tips - by warmist - 06-11-2015, 12:40 AM
RE: CompactBuilders and guide tips - by xoft - 06-11-2015, 12:50 AM
RE: CompactBuilders and guide tips - by tigerw - 06-11-2015, 01:10 AM



Users browsing this thread: 1 Guest(s)