I have a massive library written in C++ that handles a lot of mathematical operations, using C++ makes it fast and in all honesty, I don't want to re-write the whole functionality.
I am thinking about opening this library up to other, web languages (Such as PHP) and will pass the data between the two using JSON.
The issue, I have not had much experience designing/developing an API in C++ and from thinking about the implementation I have come up with this:
The API can be accessed from a HTTP URL: http://localhost/api/
and pass in different commands into it. For example: getDeter
.. Which I know how I will do this using PHP.
The problem that I am having difficult understanding is how will visiting http://localhost/api
work in C++? Is there another approach to doing this:
- Compiling the C++ into a output file
main.out
- Have a function in PHP that calls a command
./main.out [command] [arg]
- Return the response
I did not want to do this approach as I don't think that it is very clean, but I can't seem to think of an alternative to solving this problem.
P.S. I don't want to really open up the core C++ code and make changes. I would like to do the following (In C++)
function calculateDeter(std::vector<double> input)
{
// call library function
// call another library function
// return json data
}