Libcroco
Functions
cr-term.c File Reference
#include <stdio.h>
#include <string.h>
#include "cr-term.h"
#include "cr-num.h"
#include "cr-parser.h"

Go to the source code of this file.

Functions

CRTermcr_term_new (void)
 Instanciate a CRTerm. More...
 
CRTermcr_term_parse_expression_from_buf (const guchar *a_buf, enum CREncoding a_encoding)
 Parses an expresion as defined by the css2 spec and builds the expression as a list of terms. More...
 
enum CRStatus cr_term_set_number (CRTerm *a_this, CRNum *a_num)
 
enum CRStatus cr_term_set_function (CRTerm *a_this, CRString *a_func_name, CRTerm *a_func_param)
 
enum CRStatus cr_term_set_string (CRTerm *a_this, CRString *a_str)
 
enum CRStatus cr_term_set_ident (CRTerm *a_this, CRString *a_str)
 
enum CRStatus cr_term_set_uri (CRTerm *a_this, CRString *a_str)
 
enum CRStatus cr_term_set_rgb (CRTerm *a_this, CRRgb *a_rgb)
 
enum CRStatus cr_term_set_hash (CRTerm *a_this, CRString *a_str)
 
CRTermcr_term_append_term (CRTerm *a_this, CRTerm *a_new_term)
 Appends a new term to the current list of CRTerm. More...
 
CRTermcr_term_prepend_term (CRTerm *a_this, CRTerm *a_new_term)
 Prepends a term to the list of terms represented by a_this. More...
 
guchar * cr_term_to_string (CRTerm const *a_this)
 Serializes the expression represented by the chained instances of #CRterm. More...
 
guchar * cr_term_one_to_string (CRTerm const *a_this)
 
void cr_term_dump (CRTerm const *a_this, FILE *a_fp)
 Dumps the expression (a list of terms connected by operators) to a file. More...
 
int cr_term_nr_values (CRTerm const *a_this)
 Return the number of terms in the expression. More...
 
CRTermcr_term_get_from_list (CRTerm *a_this, int itemnr)
 Use an index to get a CRTerm from the expression. More...
 
void cr_term_ref (CRTerm *a_this)
 Increments the reference counter of the current instance of CRTerm. More...
 
gboolean cr_term_unref (CRTerm *a_this)
 Decrements the ref count of the current instance of CRTerm. More...
 
void cr_term_destroy (CRTerm *a_this)
 The destructor of the the CRTerm class. More...
 

Detailed Description

Definition of the #CRTem class.

Definition in file cr-term.c.

Function Documentation

◆ cr_term_append_term()

CRTerm* cr_term_append_term ( CRTerm a_this,
CRTerm a_new_term 
)

Appends a new term to the current list of CRTerm.

Parameters
a_thisthe "this pointer" of the current instance of CRTerm .
a_new_termthe term to append.
Returns
the list of terms with the a_new_term appended to it.

Definition at line 235 of file cr-term.c.

References _CRTerm::next, and _CRTerm::prev.

◆ cr_term_destroy()

void cr_term_destroy ( CRTerm a_this)

The destructor of the the CRTerm class.

Parameters
a_thisthe "this pointer" of the current instance of CRTerm.

Definition at line 775 of file cr-term.c.

Referenced by cr_declaration_destroy(), cr_rgb_parse_from_buf(), cr_term_parse_expression_from_buf(), and cr_term_unref().

◆ cr_term_dump()

void cr_term_dump ( CRTerm const *  a_this,
FILE *  a_fp 
)

Dumps the expression (a list of terms connected by operators) to a file.

TODO: finish the dump. The dump of some type of terms have not yet been implemented.

Parameters
a_thisthe current instance of CRTerm.
a_fpthe destination file pointer.

Definition at line 679 of file cr-term.c.

References cr_term_to_string().

◆ cr_term_get_from_list()

CRTerm* cr_term_get_from_list ( CRTerm a_this,
int  itemnr 
)

Use an index to get a CRTerm from the expression.

Parameters
a_thisthe current instance of CRTerm.
itemnrthe index into the expression.
Returns
CRTerm at position itemnr, if itemnr > number of terms - 1, it will return NULL.

Definition at line 719 of file cr-term.c.

References _CRTerm::next.

◆ cr_term_new()

CRTerm* cr_term_new ( void  )

Instanciate a CRTerm.

Returns
the newly build instance of CRTerm.

Definition at line 85 of file cr-term.c.

References cr_utils_trace_info.

Referenced by cr_parser_parse_term().

◆ cr_term_nr_values()

int cr_term_nr_values ( CRTerm const *  a_this)

Return the number of terms in the expression.

Parameters
a_thisthe current instance of CRTerm.
Returns
number of terms in the expression.

Definition at line 699 of file cr-term.c.

References _CRTerm::next.

◆ cr_term_one_to_string()

guchar* cr_term_one_to_string ( CRTerm const *  a_this)

◆ cr_term_parse_expression_from_buf()

CRTerm* cr_term_parse_expression_from_buf ( const guchar *  a_buf,
enum CREncoding  a_encoding 
)

Parses an expresion as defined by the css2 spec and builds the expression as a list of terms.

Parameters
a_bufthe buffer to parse.
Returns
a pointer to the first term of the expression or NULL if parsing failed.

Definition at line 106 of file cr-term.c.

References CR_OK, cr_parser_destroy(), cr_parser_new_from_buf(), cr_parser_parse_expr(), cr_parser_try_to_skip_spaces_and_comments(), and cr_term_destroy().

◆ cr_term_prepend_term()

CRTerm* cr_term_prepend_term ( CRTerm a_this,
CRTerm a_new_term 
)

Prepends a term to the list of terms represented by a_this.

Parameters
a_thisthe "this pointer" of the current instance of CRTerm .
a_new_termthe term to prepend.
Returns
the head of the new list.

Definition at line 261 of file cr-term.c.

References _CRTerm::next, and _CRTerm::prev.

◆ cr_term_ref()

void cr_term_ref ( CRTerm a_this)

Increments the reference counter of the current instance of CRTerm.

  • Parameters
    a_thisthe current instance of CRTerm.

Definition at line 738 of file cr-term.c.

References _CRTerm::ref_count.

Referenced by cr_declaration_new().

◆ cr_term_set_function()

enum CRStatus cr_term_set_function ( CRTerm a_this,
CRString a_func_name,
CRTerm a_func_param 
)

Definition at line 153 of file cr-term.c.

References CR_BAD_PARAM_ERROR.

◆ cr_term_set_hash()

enum CRStatus cr_term_set_hash ( CRTerm a_this,
CRString a_str 
)

Definition at line 215 of file cr-term.c.

References CR_BAD_PARAM_ERROR.

◆ cr_term_set_ident()

enum CRStatus cr_term_set_ident ( CRTerm a_this,
CRString a_str 
)

Definition at line 179 of file cr-term.c.

References CR_BAD_PARAM_ERROR.

◆ cr_term_set_number()

enum CRStatus cr_term_set_number ( CRTerm a_this,
CRNum a_num 
)

Definition at line 141 of file cr-term.c.

References CR_BAD_PARAM_ERROR.

◆ cr_term_set_rgb()

enum CRStatus cr_term_set_rgb ( CRTerm a_this,
CRRgb a_rgb 
)

Definition at line 203 of file cr-term.c.

References CR_BAD_PARAM_ERROR.

◆ cr_term_set_string()

enum CRStatus cr_term_set_string ( CRTerm a_this,
CRString a_str 
)

Definition at line 167 of file cr-term.c.

References CR_BAD_PARAM_ERROR.

◆ cr_term_set_uri()

enum CRStatus cr_term_set_uri ( CRTerm a_this,
CRString a_str 
)

Definition at line 191 of file cr-term.c.

References CR_BAD_PARAM_ERROR.

◆ cr_term_to_string()

guchar* cr_term_to_string ( CRTerm const *  a_this)

Serializes the expression represented by the chained instances of #CRterm.

Parameters
a_thisthe current instance of CRTerm
Returns
the zero terminated string containing the serialized form of CRTerm. MUST BE FREED BY THE CALLER using g_free().

Definition at line 279 of file cr-term.c.

References COMMA, _CRTerm::content, cr_num_to_string(), cr_rgb_to_string(), cr_term_to_string(), DIVIDE, _CRTerm::ext_content, _CRTerm::func_param, MINUS_UOP, _CRTerm::next, NO_OP, _CRTerm::num, PLUS_UOP, _CRTerm::prev, _CRTerm::rgb, _CRTerm::str, TERM_FUNCTION, TERM_HASH, TERM_IDENT, TERM_NUMBER, TERM_RGB, TERM_STRING, TERM_UNICODERANGE, TERM_URI, _CRTerm::the_operator, _CRTerm::type, and _CRTerm::unary_op.

Referenced by cr_term_dump(), cr_term_one_to_string(), and cr_term_to_string().

◆ cr_term_unref()

gboolean cr_term_unref ( CRTerm a_this)

Decrements the ref count of the current instance of CRTerm.

If the ref count reaches zero, the instance is destroyed.

Parameters
a_thisthe current instance of CRTerm.
Returns
TRUE if the current instance has been destroyed, FALSE otherwise.

Definition at line 753 of file cr-term.c.

References cr_term_destroy(), and _CRTerm::ref_count.