Federico Fuga

Engineering, Tech, Informatics & science

Strong Typing PODs

07 Sep 2017 21:29 +0000 c++ Code
Identifiying object by a numerical integer is an almost trivial task. In DISPLACE, a very complex simulator I am involved with, there are many of different categories of objects that model different categoris of agents in the simulator, like vessels, marine locations, ships, ports, and so on. Each object has an Id, and it was very natural, at the start of the project, to implement it using an **int**. Problems started when we decided, for optimization purpose, to shrink the memory footprint, to use smaller int instead. Continue reading

A compact CSV parser using C++ TMP

07 Mar 2016 17:24 +0000 c++ Metaprogramming
How many times have you implemented a CSV parser to fill a list of stucts from a text file? Personally, it happens to me about every time I have new project. Though it is a simple task that requires no more than half an hour to build and debug, it is boring, error prone and repetitive. The algorithm is quite trivial, read each line, split it in a vector of string using some separator (about always a comma, hence the "Comma Separated" name), use something to convert each field in a PoD (int, double, whatever) and fill a struct. Continue reading

The dbus-cpp Library, introduction

28 Nov 2015 22:33 +0000 c++ Code Linux
While working on a bluetooth based embedded device, I needed to deal with the somehow infamous dbus. [DBus](https://wiki.freedesktop.org/www/Software/dbus/) and [Bluez5](http://www.bluez.org/) have a very steep learning curve, and if you are don't have access to either [Qt framework](https://www.qt.io/) or [glib framework](https://developer.gnome.org/glib/), you have indeed a problem. Glib are very complex C libraries that mimick some of the built-in feature of the C++ language, while on the other hand, Qt are very vast and sometime a big overkill. Continue reading