Other

项目介绍

wolkykim/qlibc 是一个托管在 GitHub 上的开源项目,主要使用 C 编写,采用 Other 许可证,目前获得 1.0k 个 Star、178 次 Fork。

仓库全名
wolkykim/qlibc
开源许可证
Other
Star 数
1.0k
Fork 数
178

README 摘要

============= qLibc is currently one of the most functionally-complete, publicly-licensed C/C++ libraries. The goal of the qLibc project is to provide a simple and powerful general purpose C/C++ library that includes all kinds of containers and general library routines. It provides a ready-made set of common container APIs with a consistent API look. qLibc Copyright qLibc is published under the 2-clause BSD license,…

完整内容见 GitHub 原始 README 或本页 。

常见问题

qlibc 用什么语言开发?

主要使用 C 编写,采用 Other 许可证,目前有 1.0k 个 Star。

qlibc 可以免费商用吗?

仓库标注的许可证为 Other,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 qlibc 的源码?

可以直接克隆仓库:git clone https://github.com/wolkykim/qlibc.git,默认分支为 main;安装与运行步骤见仓库 README。

qlibc 最近还在维护吗?

仓库最近一次更新为 8月11日,当前没有未关闭的 Issue;Star 数为 1.0k,可作为社区活跃度的参考。

简要分析

热度分
1424
价值分
669
活跃状态
活跃

语言占比

C
CMake
M4
Makefile
Shell

Release

README

What’s qLibc? Actions Status

qLibc is currently one of the most functionally-complete, publicly-licensed C/C++ libraries. The goal of the qLibc project is to provide a simple and powerful general purpose C/C++ library that includes all kinds of containers and general library routines. It provides a ready-made set of common container APIs with a consistent API look.

qLibc is published under the 2-clause BSD license, also known as the Simplified BSD License. Please refer to the LICENSE document included in the package for more details.

Installation

qlibc uses GNU AutoTools as the primary tool for compilation. Simply execute the following commands while in the main directory of the project.

./configure
make
sudo make install

qLibc requires at least GNU99 and confirmed to be compiling in GNU23.

API Reference

  • qlibc Core API Reference

    • Containers for Key/Value pairs
      • Tree Table — in binary tree (left-leaning red-black tree) data structure.
      • Hash Table — in hash-based data structure.
      • Static Hash Table — in fixed size memory(array/mmapped/shared).
      • List Table — in (doubly) linked-list data structure.
    • Containers for Objects
      • List — Doubly Linked List.
      • Vector — implements a growable array of elements.
      • Queue — FIFO(First In First Out) implementation.
      • Stack — LIFO(Last In First Out) implementation.
    • General utilities.
      • String — string trimmer, modifier, replacer, case converter, pattern detectors, …
      • I/O — non-blocking I/O, stream reader/writer, …
      • File — file locking, file/directory handler, path correctors, …
      • IPC, semaphores, shared memory
      • Encoders/decoders — URL encoder/decoder, Base64 encoder/decoder, Hex encoder/decoder, …
      • Hashes — Murmur hashes, FNV hashes, MD5 hashes, …
      • Time — time diff, time format conversion, …
  • qLibc Extension API Reference

    • Apache-style Configuration File Parser.
    • INI-style Configuration File Parser.
    • HTTP client.
    • Rotating File Logger.
    • Database (MySQL) interface.
    • Token-Bucket

qLibc Tables at a Glance

Characteristics Tree Table Hash Table Static Hash Table List Table
Data structure Binary Tree Slot Index Block Array Linked-List
Search complexity O(log n) O(1) / O(n) O(1) / O(n) O(n)
Insert complexity O(log n) O(1) / O(n) O(1) / O(n) O(1)
Delete complexity O(log n) O(1) / O(n) O(1) / O(n) O(n)
Space complexity O(n) O(n) - O(n)
Space allocation Dynamic Dynamic Pre-allocation Dynamic
Key Stored Sorted Yes No No Yes (option)
User comparator Supported - - Supported
Duplicated keys No No No Yes (option)
Key stored digested No No Yes No
Search Nearest Key Yes No No No
Iterator support Yes Yes Yes Yes
Iterator visit order min -> max random random insert order
Thread-safe option Supported Supported User Supported
Can use shared mem No No Yes No

Consistent API Look

All container APIs have a consistent look and feel. It basically provides a creator function which usually returns a pointer to a container structure. Also, all functions related to the container can be accessed through function pointers inside the container or through traditional direct-access APIs.

So, regardless of which container you use, you can simply put elements into a list with container->put(container, ...) or you can call them using direct APIs such as qtreetbl_put(container, ...).

The example below illustrates what it looks like.

  // create a hash-table.
  qhashtbl_t *tbl = qhashtbl(0, QHASHTBL_THREADSAFE);
  
  // add an element whose key 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);

Here is an identical implementation with a Linked-List-Table container. You may notice that there aren’t any code changes at all, except for 1 line in the table creation. This is why qLibc encapsulates corresponding function pointers inside the container object.

  // create a linked-list-table. THE ONLY LINE YOU NEED TO CHANGE.
  qlisttbl_t *tbl = qlisttbl(QLISTTBL_THREADSAFE);
  
  // add an element whose key 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);

Looking for people to work with.

We’re looking for people who want to work together to develop and improve qLibc. Currently, we have high demand in the following areas.

  • Automated testing
  • Documentation.
  • New feature implementation.

Contributors

The following people have helped with suggestions, ideas, code or fixing bugs: (in alphabetical order by first name)

If we have forgotten or misspelled your name, please let us know.

评论

暂无评论