Misc

Automatic type registering

When you create a new class that has boost::clipp::object as a base class, you get the advantage that it will automatically be registered if it is used as argument or return type in a function or constructor that is exposed to CliPP. It will also be automatically registered if you register a class inheriting from that class.

STL containers

CliPP supports the use of the following stl containers:

In javascript, the Array object can be automatically converted to a list<T>, set<T> or vector<T> with any value for T.
All containers will be automatically registered with CliPP when used in a function or constructor being exposed to CliPP.

    //Define a function
    void polygon(const std::set<point>& points);
	
    //Register function. This will register std::set<point> and point automatically to the scripting.
    function(c,"polygon",polygon);
	
    //In javascript, you can now use this function:
    polygon(Array(point(0,0,0),point(5,6,0),point(8,5,1)));

unwrap/wrap script values

If you want to extract the value produced from a script command, you can do the following:

    //Extract value directly
    double result = unwrap<double>(parser.parse("square(5.89);"))();
    //validate value before extraction
    unwrap<double> result=unwrap<double>(parser.parse("square(5.89);"));
    if(result.ok()) {
	double a=result();
    }

    //Conversely, wrapping values is done in a similar manner	
    valueP a1 = wrap(3);
    valueP a2 = wrap("Hello");

Remaining work