Assignment: C++ Cross Platform
Problem Statement: Create a library in C++ that retrieves activities from the Bored API. Fetch the values from the server and provide a response in JSON format to the caller. Additionally add functionality to create and delete created activities (local storage only, not server) that can be utilized by a front end.
Requirements for success:
-
- C++ layer: fetch activities from the API
-
- C++ layer: add and delete activities in local storage
- Create 3 frontends (very simple one screen)
- iOS , 1 screen to display activities, both fetched and local, 1 screen to create an activity
- Android 1 screen to display activities, both fetched and local, 1 screen to create an activity
- React JS 1 screen to display activities, both fetched and local, 1 screen to create an activity
Note: the UI frontend is only to demonstrate how the native platform code, ie: swift, Kotlin/java & javascript interact with the C++ code that is written.
What's missed in library: 1) data validation 2) tests 3) documentation 4) closing of all TODOes.
- Scapix will be used. It can automatically create bridge files for all platforms. It converts C++ data types to Kotlin, OBJ C, JS data types. And also it perfectly fits in CMake projects. So, I use the following algorithm to build a portable library.
- Creating an idiomatic C++ working draft of a library
- Looking at list of compatible types. And writing an API for a library.
And CMake will make the all the rest work for me. It will generate static lib files and launch Scapix, that will remade .h files.
Sample Query:
http://www.boredapi.com/api/activity/
Response:
{
"activity": "Learn Express.js",
"accessibility": 0.25,
"type": "education",
"participants": 1,
"price": 0.1,
"link": "https://expressjs.com/",
"key": "3943506"
}
- Linux (Ubuntu 19.04)
- Windows
- MacOS
If you are running UNIX based system.
Run "prepare.sh" and it will install vcpkg with needed packages.
$ chmod +x prepare.sh
$ ./prepare.sh
$ mkdir build
$ cd build
$ cmake