p-ranav / awesome-hpp

A curated list of awesome header-only C++ libraries
The Unlicense
3.52k stars 220 forks source link

More libraries #26

Closed jermp closed 4 years ago

jermp commented 4 years ago

Hi, please consider adding the following libraries. (All header-only, extensively tested, and in C++.)

Argument Parsers https://github.com/jermp/cmd_line_parser

Compression https://github.com/jermp/interpolative_coding

File System https://github.com/jermp/mm_file

Benchmarking and/or Serialization https://github.com/jermp/essentials

Thanks.

p-ranav commented 4 years ago

Can you give me a description for benchmarking or serialization for https://github.com/jermp/essentials? What does the library provide the user?

jermp commented 4 years ago

Hi, thanks for considering my libraries.

The "essentials" lib provides a transparent way of serializing/deserializing a data structure to a file. A minimal example follows, assuming your data structure is named "my_ds". (Also see the example https://github.com/jermp/essentials/blob/master/test/data_structure.cpp)

{ // serialization
  A my_ds;
  char const* output_filename = "./my_ds.bin";
  save(my_ds, output_filename);
}

{ // deserialization
  A my_ds;
  char const* input_filename = "./my_ds.bin";
  load(my_ds, input_filename);
}

All that is required is the data structure to implement a visit method, as exemplified below.

struct A {
  template <typename Visitor>
  void visit(Visitor& visitor) {
      visitor.visit(a);
      visitor.visit(b);
      visitor.visit(c);
  }
private:
  int a, b;
  float c;
};

Regarding benchmarking, it includes a timer class that can be tuned to perform fine-grained code measurements. (See the example https://github.com/jermp/essentials/blob/master/test/timer.cpp)

The library also includes some minor facilities.

p-ranav commented 4 years ago

Thanks. Added to serialization section.