Open davidwojnar opened 3 years ago
I'd suggest the 5th way:
Make JlCompress
a full-fledged non-static class, with Pimpl and fluent setters. Delegate static functions to their non-static counterparts for backwards compatibility. Use non-static ones in new code, like
JlCompress().withUtf8Enabled().compressFile(...)
This way more options can be added later while maintaining full API and ABI compatibility.
A good naming scheme is needed to avoid name clashes between static and non-static functions. I can't think of anything good right away, save for silly ideas of capitalizing or underscoring them...
Or wait. Why JlCompress
? Just create a new class. Delegate JlCompress
methods to it. Pick a better name while we're at it, as JlCompress
doesn't even follow the QuaSomething
naming scheme. Let's call it QuaCompress
for the sake of similarity or QuaUtil
maybe...
I was actually hopeing for an easy solution to my problem, but you are right.
Sp I started moving some code around. And will replace JlCompress implementation with a class called QuaZipUtil. That way, JlCompress can still be used as is.
Will send a pull request once I have finished it and added some tests.
@davidwojnar: Have you done a PR?
JlCompress functions have recently been extended with an Options class which could now contain this functionality without expanding the interface into oblivion. I'll consider patching this in when there's an opportunity. I also like the setter idea which could be added in parallel.
It would be nice to be able to use the JlCompress utility function with utf-8 support.
It should be fairly simple to do that. Basically for each function one only has to do the following:
QuaZip zip(fileCompressed);
zip.setUtf8Enabled(true);
Backward compatibility makes it a little bit trickier. So, there are at least four possible solutions for that:
static bool JlCompress::enableUtf8 = false;
static bool compressFile(QString fileCompressed, QString file, bool enableUtf8 = false);
static bool compressFileUtf8(QString fileCompressed, QString file);
I can update the code, and send a pull request, but would like to have some opinion on which way to go. I am preferring 3 the most, but am open for better suggestions.