A random grab-bag of header-only, dependency-free C++ classes.
When you start trying to write a C++ project of any size, you'll soon start finding gaping holes in what the C++ standard library provides. To fill them, you'll end up either writing lots of helper functions yourself, or trawling the web for awful 3rd-party libraries which come with all kinds of baggage like messy build requirements, scads of stupid compiler warnings, awkward licenses, etc.
I got tired of re-implementing many of the same little helper classes and functions in different projects, so CHOC is an attempt at preventing future wheel-reinvention, by providing some commonly-needed things in a format that makes it as frictionless as possible for anyone to use this code in any kind of project.
So with that goal in mind, the rules for everything in CHOC are:
#include
the file you want, and you're done. Nothing needs adding to your build system to use any of this stuff.Basically CHOC is aimed at people (like me) who just want to use some decent library code without also spending their afternoon fighting CMake or looking up the right compiler flags to make the dratted thing work.
The library is getting quite big now! Some of its many delights include:
std::iostream
compatible classes for compressing and decompressing data.boost::beast
works and write all the boilerplate required just to serve some content and talk down a web-socket, so this class hides all the horribleness behind a very simple API.std::span
.The world's most hassle-free single-header WebView class!
This lets you create an embedded browser view (either as a desktop window or added to an existing window), and interact with it by invoking javascript code and binding callback C++ functions to be called by javascript. Something that makes this particularly special compared to other web-view libraries is that on Windows, it provides the modern Edge browser without you needing to install extra SDKs to compile it, and without any need to link or redistribute the Microsoft loader DLLs - it's literally a dependency-free single-header Edge implementation. (Internally, some absolutely hideous shenanegans are involved to make this possible!)
To try it out, if you compile the choc/tests project and run it with the command-line arg "webview", it pops up an example page and shows how to do some event-handling.
A cross-engine Javascript API, with implementations for V8, QuickJS and Duktape!
Both QuickJS and Duktape have been squashed into single-file header-only implementations, so are trivially easy to add to any project. V8 unfortunately requires you to link to their enormous static libraries, but obviously provides optimum performance.
All these engines are abstracted behind the same choc::javascript::Context
base-class, and you can choose to use any combination of engines interchangeably (or simultaneously) in your project.
A JSON parser that uses choc::value::Value objects.
Hopefully some people will find some of these things useful! If you like it, please tell your friends! If you think you're up to contributing, that's great, but be aware that anything other than an utterly immaculate pull request will be given short shrift :)
-- Jules
[^1]: ...or maybe "Clean Header-Only Classes" ...or "Cuddly Header-Only Classes"... It's just a backronym, so feel free to pick whatever C-word feels right to you. I may change the word occasionally on a whim, just to cause annoying diffs in the codebase.