techniware / shpp

Call c++ functions from a shell with any arguments of any types parsed automatically

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shpp

Call c++ functions from a shell with any arguments of any types parsed automatically

Declare a variable or define a function and register it in shpp with a simple command. Your function will be available to be called by a shell that parses the arguments automatically to the types of the arguments of your function.

Usage

git clone --recursive https://github.com/GrossoMoreira/shpp
cd shpp
make
bin/example

Features

  • list available functions, including their return type and parameter types
  • call functions with any number of arguments of any primitive types or stl-like non-associative containers
  • read and write variables (const/read-only variables supported)
  • when a function is called, output its return value (of any supported type)
  • interactive and non interactive mode
  • auto-complete
  • command history
  • reverse search
  • sourcing commands from files

Interface

#include "shpp/shpp.h"

shpp::service svc;	// create a service

svc.provide("function_name", function_ptr);
svc.provide("variable_name", variable_ref);

shpp::shell sh(svc);	// create a shell for this service
sh.start();			// start shell

Interactive shell

Interactive shell demo

Supported types

  • primitive types
  • stl-like non-associative containers (std::vector, std::list...) that implement the push_back() method, parsed/serialized as JSON objects
  • containers of containers
Sample std::vector<std::list<int>> :

[[0,2,4],[1,3,5],[]]

..can be used as a function parameter or return type.

Dependencies

  • GNU readline

Todo

  • support arguments of user-defined types
  • support asynchronous execution of commands
  • call functions remotely

About

Call c++ functions from a shell with any arguments of any types parsed automatically

License:GNU General Public License v3.0


Languages

Language:C++ 83.3%Language:C 14.1%Language:Makefile 2.6%