SkillAgentSearch skills...

CppLibraryInterfacePoC

A library PoC with C++ interface, easy to write, easy to use, yet highly compatible across compiler versions

Install / Use

/learn @mkrevuelta/CppLibraryInterfacePoC
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

CppLibraryInterfacePoC

A Proof-of-Concept library with:

  • Mostly C++ interface (objects, move semantics)
  • Easy to write (real C++, no conversion to/from extern "C" functions)
  • Easy to use (objects are given away, managed by unique pointers)
  • Highly compatible across compiler versions from a given vendor (only requirement: C++11 or above)

This repository contains evolved versions of the examples I proposed in this presentation:

  • https://www.mkrevuelta.com/en/2019/03/06/lets-make-easy-to-use-libraries-using-stdcpp-2019/

NEW: I'm taking all this theory to practice in a real library:

  • https://github.com/mkrevuelta/CppMoveBase64

Foo library

The Foo library can receive or return the next data structures, or "messages":

  • StringMsg: a text string
  • NumbersMsg: an array of numbers
  • MultiMapMsg: a string-to-string multimap

Each type of message is wrapped in a class. With respect to the usage of C++, the main restriction is that the methods provide access to the data through C types (i.e., const char *). On the other hand, these classes are implemented with the PIMPL idiom and support move semantics. Thus, data can be passed with minimal overhead and, at the same time, the lifetime of objects is very easy to manage.

Client program

Sample program that calls every Foo function.

Both Foo and Client can be compiled for MSVC 2012 and MSVC 2019. Note that each Client project is configured to copy and use the DLL compiled with the other version of the compiler!

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated6y ago
Forks0

Languages

C++

Security Score

75/100

Audited on Jun 1, 2019

No findings