quixdb / squash

Compression abstraction library and utilities
https://quixdb.github.io/squash/
MIT License
407 stars 53 forks source link

Move squash_codec_get_option_* functions to squash_option_get_* #161

Closed nemequ closed 8 years ago

nemequ commented 9 years ago

These should be part of the SquashOption API, not SquashCodec. The SquashOption struct includes the codec, so this should be trivial.

Dr-Emann commented 9 years ago

This bit me indirectly: I went and implemented my own, since I couldn't find them in the option documentation. Oops.

nemequ commented 9 years ago

Argh, I figured out why these are the way they are. If the options parameter is NULL they return the default value for that codec. I still think it might be better to move those to options.c, but that file already has some similar functions.

'options.c' already has squash_options_get_(string|bool|int|size) functions, but they can't handle NULL options. Maybe something like

int squash_options_get_int       (SquashOptions* options, const char* key, SquashCodec* codec);
int squash_options_get_int_index (SquashOptions* options, int index, SquashCodec* codec);
int squash_options_get_int_wide  (SquashOptions* options, const wchar_t* key, SquashCodec* codec);

If the codec parameter comes last it's more likely certain languages will be able to specify a default value if that argument is omitted.

nemequ commented 8 years ago

Fixed now, thanks to @Dr-Emann! The patch is greatly appreciated :)