Federico Fuga

Engineering, Tech, Informatics & science

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