C/C++ FLAC tagging library - c++

Is there any C/C++ FLAC tagging library that work on streams? Wherever I look I only find ones that work on files. It's kinda weird to me - why use something limited like file instead of more abstract stream. Well, maybe I'm just spoiled by managed languages neatness (I'm more of a Java guy, but this time I need unmanaged code solution).

I'm not familiar with any FLAC libraries, but the reference FLAC library supports an interface for custom I/O. This allows you to write a small stub that will convert I/O calls to a custom data source, which needn't be a file.
It seems to require capacity to seek, though. If that is the case, then you might not be able to wrap a socket without a high-level protocol that allows you to seek.

Related

Standard serialization protocol to serialize set of objects to disk

I am looking for standard protocol that provides ability to serialize set of object (same type) to a file, but also provide easy way to align to object boundary if reader/de-serializer start reading from random byte offset.
After googling I found out that Apache Avro provides this functionality using sync markers, but they don't have c++ lib to provide seek functionality, plus also no native windows library support for c++.
Is there any other well known protocols for the above requirements?
Possible protocols: protobuff and thrift, but after googling looks like they don't provide seeking capabilities (I might be wrong).

How should I read files in C++ w/ SDL?

I have tried looking for tutorials and reading the docs but there's almost no information on how to use SDL to read and write to text files, etc. So, would it be a better idea to just use regular C++?
While SDL have RWops, its API is exactly the same as stdlib fread/fwrite/fseek. It serves different purpose though. There may be (and, as SDL is game oriented, very often are) cases when data processing code don't really care where data coming from (regular file, byte array in memory, zip or any other form of archive, network source, or even procedural generator). If this code uses RWops-like abstraction you can just write a new implementation for it and it and it will work without any modification or recompilation. SDL itself and all SDL-based libraries like SDL_image, SDL_ttf, etc. support loading data from RWops, as well as a few 'standard' RWops implementations like SDL_RWFromFile or SDL_RWFromMem.
If question is "what you should use", then there is really no answer, as there is no 'better' here. If you're writing a library though, it is very reasonable to provide a way for calling side to redefine what 'file' is (or at least load data from memory array).

Serialize/ Deserialize C++ classes

I'm looking for a way to send C++ class between 2 clients aptication.
I was looking for a way doing so and all i can find is that I need to create for each Class Serialize/ Deserialize (to JSON for example) functions and send it over TCP/IP.
The main problem I'm faceing is that I have ~600 classes (some are classes including instances of others) that I need to pass which mean I need to spent the next writing Serialize/ Deserialize functions.
Is there any generic way writing Serialize/Deserialize functions ?
Is there any other way sending C++ classes ?
Thanks,
Guy Ergas.
Are you using a Framework at all? Qt and MFC for example have built in Serialization that would make your task easier. Otherwise I would guess that you'd need to spend at least some effort on each of the 600 classes.
As recommended above Boost Serialization is probably a good way to go, you can send the serialized class over Tcp using Boost Asio too:
http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio.html
Alternatively, there is a C++ API for Google Protocol Buffers (protobuf):
https://developers.google.com/protocol-buffers/docs/reference/cpp/
Boost Serialization
Although I haven't used it my self, it is very popular around my peers at work.
More info about it can be found in "Boost (1.54.00) Serialization"
Thrift
Thrift have a very limited serialize functionality which I don't think fits your requirements. But it can help you "move" the data from one client to anther even if they are using different languages.
More info about it can be found in "Thrift: The Missing Guide"
try s11n or nosjob
s11n (an abbreviation for serialization) is an Open Source project
focused on the generic serialization of objects (i.e., object
persistence) in the C++ programming language.
nosjob, a C++ library for generating and consuming JSON data.
You may be interested in ASN.1. It's not necessarily the easiest to use and tools/libraries are a little hard to come by (Objective Systems at http://www.obj-sys.com/index.php is worth a look, though not free).
However the big advantage is that it is very heavily standardised (so no trouble with library version incompatibilities) and most languages are supported one way or another. Handy if you need support across multiple platforms. It also does binary encodings, so its way less bloaty than XML (which it also supports). I chose it for these reasons and didn't regret it.
If you are at linux platform , You can directly use json.h library for serialization.
Here is sample code i have come across :)
Json Serializer

C / C++ equivalents to the Python Standard Library

I depend heavily on Python's standard library, both for useful data structures and manipulators (e.g., collections and itertools) and for utilities (e.g., optparse, json, and logging), to skip the boilerplate and just Get Things Done. Looking through documentation on the C++ standard library, it seems entirely about data structures, with little in the way of the "batteries included" in Python's standard library.
The Boost library is the only open-source C++ library collection I know of that resembles the Python standard library, however while it does have utility libraries such as Regular Expression support, most of it is also dedicated to data structures. I'm just really surprised that even something as simple as assured parsing and writing a CSV file, made delightfully simple with the Python csv module, looks to require rolling-your-own in C++ (even if you leverage some parsing library by Boost).
Are there other open-source libraries out there for C++ that provide "batteries"? If not, what do you do as a C++ programmer: hunt for individual utility libraries (and if so, how), or just roll your own (which seems annoying and wasteful)?
The Poco library is more like other languages' standard libraries.
Actually the Poco web site's logo says "C++ now comes with batteries included!", which seems to be precisely what you're asking for.
I didn't like it when I tried because I found it too C-like and with too many dependencies between parts (difficult to single out just the functionality you want).
But there are many people & firms using it, so it seems I'm in minority and you will perhaps find it very useful.
In addition, as others have mentioned, for data structures, parsers, and indeed an interface to Python!, and such stuff, check out Boost.
Cheers & hth.,
While C++ does offer many of the comforts extended by OO it keeps a very simple standard library. C++ has STL and Boost. These are very good, and have more then just datastructures.
If your needs are these sorts of higher order functions for prototyping or making application without intense (relative term) speed requirements then C/C++ is probably not the right choice for you. I believe you will find that for most projects that high level languages will be fast enough for your needs. If you are working on an application that requires C/C++ speed (and accompanying standard deviations) then you should probably invest your time carefully picking each individual library you will be using.
http://beta.boost.org/community/sandbox.html
http://www.boostpro.com/vault/
also you can google for "boost+bar", eg
boost log ->
http://boost-log.sourceforge.net/libs/log/doc/html/index.html
boost threadpool ->
http://threadpool.sourceforge.net/
http://www.boost.org/doc/libs/1_45_0/?view=categorized
Boost isn't just about data structures - it has lots of the batteries you want - parsing, threads, collections, logging, etc.
With C and C++ you typically won't find a "do it all" library, instead you'll use individual libraries that do different things. You can use one library that does JSON parsing, one that does crypto, one that does logging, etc.
Boost and Qt are the only ones that would be more of a "do it all" type library.

C++ cross-platform zlib simplifer-wrapper

I'm looking for a wrapper that distills zlib to:
OpenZipFile()
GetItemInfo(n)
UnzipItem(n) // Bonus points for unzipping recursively if item n is a directory.
I see a lot of wrappers around the zlib library on, say, codeproject.com but they are all platform-specific in order to provide the added platform-specific functionality of unzipping to file/memory buffer/pipe.
In boost::iostreams there is the possibility to use zlib, gzip and bzip2 formats.
You find it from http://www.boost.org/
In the zlib source archive, there is a contribution named "minizip".
"minizip" is a set of files you can use to play with .zip files. Basic services you need are already there :
unzOpen
unzLocateFile
unzOpenCurrentFile
unzGetCurrentFileInfo
unzCloseCurrentFile
unzClose
Of course, this is not object oriented (and I'm sure that was not the goal of the creator of minizip), but writing a simple object oriented wrapper should be easy.
firstobject's easy zlib stays cross-platform; it has zlib in a single file easyzlib.c and exposes only ezcompress and ezuncompress functions with the added feature of determining the memory requirement before allocating the exact size.
You could try to grab the code from another FOSS project. ScummVM, for example, has a highly portable Zlib wrapper (implementation, header) with all the functions you need, plus an OO layer for interfacing generically with any other kind of archive.
Maybe that's a good starting point? The wrapper functions are totally standalone and portable (heck, they even work on a Nintendo DS), but the OO layer depends on many custom classes which may be hard to add to your own project.
GZStream is worth a look. This is a nice cross-platform wrapper round ZLib which extend the STL iostream classes.
http://www.cs.unc.edu/Research/compgeom/gzstream/
What is good about this wrapper over some of the others is that if you're working with very large archives you don't need to load the whole dataset into memory.
If you will use minizip -- pay attention, thet version shipped with zlib 1.2.3 has 2GB resulting zip file limitation. IT will produce zip with size >2GB - but you won't be able to open them...
This is an old thread, but I thought I'd throw in Boost's ZLib wrapper:
http://www.boost.org/doc/libs/1_47_0/libs/iostreams/doc/classes/zlib.html
You can check also this C++ Zlib wrapper with auto-detection of input format:
https://github.com/mateidavid/zstr