Setting Values in the brEval Class

In order to set the result, use the overloaded method set() in the brEval class. This method can take any of the C types listed above and will set the brEval's type according to the input type. Some examples are shown below.

        // for a function returning an integer
        result->set( 10 );

        // for a function returning a string
        char *myString = "look at me, I'm returning a string!";
        result->set( myString );

In most cases, passing data to set() is as simple as in the examples above. However, care must be taken to ensure that the C-type being passed in corresponds to the desired brEval type. This may become an issue, for example, if a plugin calculation uses floating point math, but desires to return an integer, or when returning NULL pointers. It is therefore necessary to explicitly typecast values that do not match the expected return type. Some examples are shown below. In each example, the wrong type would be returned without the typecast.

        // our calculation creates a double, but we wish to return an AT_INT type to breve:
        result->set( (int)pow( x, y ) );

        // we want to return an AT_STRING type, but the value is NULL:
        result->set( (char*)NULL );

        // now we want to return an AT_LIST type, but the value is NULL:
        result->set( (brEvalListHead*)NULL );