I always wanted to have on hand a certain “gentleman's set” of library classes, with a small dependency, which can be easily combined with other libraries and frameworks and easily transferred to other projects. As they say - turned on and forgot. And most importantly - "do not pay for what you do not use" (C) C ++
nstd ::
I like libraries consisting of header files only. Moreover, modules are coming in C ++! :) At once I will make a reservation, the nstd library in no way claims to be the place of great and powerful libraries and frameworks like boost, Qt, POCO, etc. etc. Rather, it is an addition to them.
My library uses the features of C ++ 17 and consists of several weakly dependent functional classes. I'll warn you
right away that the library is being actively complemented and changing, and, perhaps, at the time you read this article, it has already changed so much that it is better to refer to the source code
here for current information.
')
The library contains several examples of using classes. For them, I included CodeBlocks projects (for Windows). However, the examples also contain a GENie configuration file for generating other types of projects. For example, you can easily generate a Makefile for this purpose. C ++ 17 is supported by GCC 7.1 and the latest versions of Clang. Unfortunately, Visual Studio 2017 does not yet support all the features of the new standard, in particular, inline for data members and the simplified way of declaring nested namespaces are not supported. Therefore, in principle, you can generate a project for VS 2017 via GENie, but it will not compile yet. Although, if you really need it, you can correct the source code for compilation in VS 2017 yourself, it's not difficult there.
If you do not have CodeBlocks or you do not want to install it, then, using MinGW-w64 GCC 7.1 for Windows as an example, I will describe how to quickly generate and compile examples using GENie and Makefiles.
- We swing MinGW-w64 with GCC 7.1, for example from here . Unpack it into a convenient folder for you and set the path to the MinGW / bin folder in the PATH variable.
- We download the executable file GENie for Windows (there is also for other operating systems) from here .
- We copy genie.exe in the folder with examples, where the file genie.lua lies.
- To generate Makefiles, run the command from the examples folder: “genie.exe gmake”
- In the examples folder, the main Makefile and sub-makefiles for each project will appear.
- For example, to collect all the examples in the Release configuration, we run there the same: “mingw32-make.exe config = release”. If you want to collect only one of the examples, then you just need to add the name of the example, for example: "mingw32-make.exe config = release relinx_example".
The nstd library is distributed under the MIT license and contains not only my development classes, but also third-party developments. In the project description on Github, I indicate which specific third-party classes I included in the project. In the repository, they are in a separate
external folder.
Briefly about the current content of nstd:
I already represented the class
Relinx on Habrahabr
here . Simply put, this is LINQ for C ++. Lazy calculations are supported and almost all .NET LINQ methods are implemented. I decided to include Relinx in nstd. Do not disappear the same good :).
The signal_slot classes are convenient in that they allow signals and slots to automatically disconnect from each other when the connection between them breaks down. Each connection of a slot with a signal of any type is represented by a connection class, the destruction of which results in the breaking of the signal-slot connection. The important thing is that connection, unlike signals and slots, is not a template, which allows you to save it in any container, regardless of signal types and slots. Accordingly, when this container is destroyed, all links to the signals will be broken. This is convenient when the object containing this container collapses, without having to specifically disconnect from the signals - this will happen automatically.
live_property is built on the basis of the signal_slot classes. This is a binding over types, which allows you to track changes over them and, if desired, you can control the behavior: change the value or not.
expiry_cache is a template container that stores data for a specific time only and notifies with a signal that the data has expired. It works in two modes: it prolongs the life of the data if it was accessed during the storage time, and the mode without extending the life of the data. Also, there is an automatic cleaning mode in the background through a separate stream (auto vacuum).
json is a third-party library for working with the JSON data format.
asio is a third-party library for working with network connections. Perhaps soon will be included in the standard C ++.
urdl is a third-party library from asio, but forked and developed by other developers. It allows you to conveniently download data from the network.
sqlite is a third-party wrapper over sqlite3. Very interesting implementation.
The quantum random number provider is a class generator of random numbers using the free QRNG service (http://qrng.anu.edu.au), which returns random numbers generated on quantum hardware.
For examples of using these classes (and some others that I didn't mention here), refer to the repository on Github
here . If you have any questions or any good suggestions, please contact us!
I am actively trying to supplement the nstd library with useful classes. I suggest everyone to participate in the development of the nstd library. If there are good and useful classes, then send me. I will try to adapt and include in the library.
/// TODO:
In the near future I want to implement remote signals, working through a TCP or UDP connection. These signals I want to use for communication between processes and communication over the network.
There is another idea to implement GUI classes based on Blend2D or AGG and using its implementation signals slots. I have not yet decided which graphic library to take as a basis. I will be glad to hear your opinion on this issue.