Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

CRDeclaration* cr_declaration_parse_from_buf ( CRStatement *  a_statement,
const guchar *  a_str,
enum CREncoding  a_enc 
)

Parses a text buffer that contains a css declaration.

Parameters:
a_statement the parent css2 statement of this this declaration. Must be non NULL and of type RULESET_STMT (must be a ruleset).
a_str the string that contains the statement.
a_enc the encoding of a_str.
Returns:
the parsed declaration, or NULL in case of error.

Definition at line 103 of file cr-declaration.c.

References cr_declaration_new(), cr_parser_destroy(), cr_parser_new_from_buf(), cr_parser_parse_declaration(), cr_parser_try_to_skip_spaces_and_comments(), and cr_term_destroy().

{
        enum CRStatus status = CR_OK;
        CRTerm *value = NULL;
        CRString *property = NULL;
        CRDeclaration *result = NULL;
        gboolean important = FALSE;

        g_return_val_if_fail (a_str, NULL);
        if (a_statement)
                g_return_val_if_fail (a_statement->type == RULESET_STMT,
                                      NULL);

        CRParser *parser = (CRParser *)
                    cr_parser_new_from_buf ((guchar*)a_str,
                          strlen ((char *)a_str), a_enc, FALSE);
        g_return_val_if_fail (parser, NULL);

        status = cr_parser_try_to_skip_spaces_and_comments (parser);
        if (status != CR_OK)
                goto cleanup;

        status = cr_parser_parse_declaration (parser, &property,
                                              &value, &important);
        if (status != CR_OK || !property)
                goto cleanup;

        result = cr_declaration_new (a_statement, property, value);
        if (result) {
                property = NULL;
                value = NULL;
                result->important = important;
        }

      cleanup:

        if (parser) {
                cr_parser_destroy (parser);
                parser = NULL;
        }

        if (property) {
                cr_string_destroy (property);
                property = NULL;
        }

        if (value) {
                cr_term_destroy (value);
                value = NULL;
        }

        return result;
}


Generated by  Doxygen 1.6.0   Back to index