Git Product home page Git Product logo

qlibc's Introduction

What's qLibc?

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

qLibc Copyright

All of the deliverable code in qLibc has been dedicated to the public domain by the authors. Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original qLibc code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

API Reference

  • qlibc Core API Reference

    • Containers
      • List --- Doubly Linked List.
      • List Table --- KEY/VALUE paired table implemented on linked-list.
      • Hash Table --- Hash based KEY/VALUE paired table.
      • Static Hash Table --- Static(array/mmapped/shared) memory based KEY/VALUE paired table.
      • Vector --- implements a growable array of elements.
      • Queue --- FIFO(First In First Out) implementation.
      • Stack --- LIFO(Last In First Out) implementation.
    • General utilities.
      • String
      • I/O
      • File
      • IPC, Semaphore Shared-memory
      • En/decoders
      • Hashes
      • System
      • Time
  • qLibc Extension API Reference

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

Consistant API Look

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 the container can be accessed through function pointers inside of the 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.

See the example below to see how it works.

  // create a hash-table.
  qhashtbl_t *tbl = qhashtbl(0, QHASHTBL_OPT_THREADSAFE);
  
  // 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");
  if(px != NULL) {
    printf("%d\n", *px);
    free(px);
  }
  
  // release table
  tbl->free(tbl);

Here is an identical implementation with Linked-List-Table container. You might noticed that there's no code change entirely except of 1 line for 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_OPT_THREADSAFE);
  
  // 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");
  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 developing and improving qLibc. Currently, we have high demands on following areas.

  • Automated testing
  • Documentation.
  • New feature implementation.

qlibc's People

Contributors

wolkykim avatar

Watchers

Colin Tregenza Dancer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.