Developer(s) | The qDecoder Project |
---|---|
Initial release | Dec 1, 2010 |
Development status | Active |
Written in | C |
Operating system | Cross-platform |
Platform | Cross-platform |
Type | Runtime library |
License | 2-clause BSD License |
Website | Official Website |
The qLibc is a C/C++ software library released by The qDecoder Project[1]. The goal of qLibc project is providing general purpose complete C/C++ library which includes all kinds of containers(data structures) and general library routines. It provides ready-made set of common container APIs with constant look that can be used with any built-in types and with any user-defined types
Released under the 2-clause BSD License, qLibc is free software.
Contents |
All container APIs have constant look, basically it provides a creator function which usually returns a pointer of a container structure. And every functions related to that container can be accessed through function pointers inside of that container. .
So regardless of what container you use, you can simple put elements into list like pContainer->put(pContainer, …). It looks like C++ class but it's pure C implementation. Of course it works with both of your C and C++ codes.
We used this concept as much as possible because it simplifies the thinking way and helps to improve readability. Consequently it helps people to write bugless codes more easily.
// create a hash-table with hash range 100. // It does not mean the maximum number of elements in this table. Q_HASHTBL *tbl = qHashtbl(100); // add an element which key name is "score". int x = 12345; tbl->put(tbl, "score", &x, sizeof(int)); // get the value of the element. int *px = tbl->get(tbl, "score", NULL, true); if(px != NULL) { printf("%d\n", *px); free(px); } // release table tbl->free(tbl);