Logo Search packages:      
Sourcecode: inkscape version File versions

const gchar * Inkscape::Extension::Extension::set_param_string ( const gchar *  name,
const gchar *  value,
SPReprDoc *  doc = NULL 
)

Sets a parameter identified by name with the string in the parameter value.

Returns:
The passed in value
Parameters:
name The name of the parameter to set
value The value to set the parameter to
doc The document to look in for document specific parameters
First this function makes sure that the incoming string is not NULL. The value can't be set to NULL.

To get the parameter to be used the function param_shared is called. This function is inline so it shouldn't cause the stack to build or anything like that. If it can't find the parameter, it will throw and exception - we aren't catching that because we want the calling function to catch it.

Next up, the parameter that we got, we're making sure that it is a string parameter. If it isn't, then we throw a param_wrong_type exception.

Finally, if everything is okay, the previous value is free'd and the incoming value is duplicated and placed in the parameter.

Definition at line 776 of file extension.cpp.

References param_shared(), PARAM_STRING, parameters, Inkscape::Extension::Extension::param_switch_t::t_string, Inkscape::Extension::Extension::param_t::type, and Inkscape::Extension::Extension::param_t::val.

{
    Extension::param_t * param;
      gchar * param_name;
    
    if (value == NULL) {
        /* This probably isn't a good error, but the calling function
           will find out soon enough it doesn't have data there ;) */
        return value;
    }

    param = Extension::param_shared(name, parameters);

    if (param->type != Extension::PARAM_STRING) {
        throw Extension::param_wrong_type();
    }

    g_free(param->val.t_string);
    param->val.t_string = g_strdup(value);

      param_name = g_strdup_printf("%s.%s", id, name);
      prefs_set_string_attribute("extensions", param_name, value);
      g_free(param_name);

    return value;
}


Generated by  Doxygen 1.6.0   Back to index