36 cr_term_clear (
CRTerm * a_this)
38 g_return_if_fail (a_this);
40 switch (a_this->
type) {
89 result = g_try_malloc (
sizeof (
CRTerm));
94 memset (result, 0,
sizeof (
CRTerm));
113 g_return_val_if_fail (a_buf, NULL);
117 g_return_val_if_fail (parser, NULL);
120 if (status !=
CR_OK) {
124 if (status !=
CR_OK) {
145 cr_term_clear (a_this);
158 cr_term_clear (a_this);
171 cr_term_clear (a_this);
183 cr_term_clear (a_this);
195 cr_term_clear (a_this);
207 cr_term_clear (a_this);
219 cr_term_clear (a_this);
239 g_return_val_if_fail (a_new_term, NULL);
244 for (cur = a_this; cur->
next; cur = cur->
next) ;
246 cur->
next = a_new_term;
247 a_new_term->
prev = cur;
263 g_return_val_if_fail (a_this && a_new_term, NULL);
265 a_new_term->
next = a_this;
266 a_this->
prev = a_new_term;
281 GString *str_buf = NULL;
283 guchar *result = NULL,
286 g_return_val_if_fail (a_this, NULL);
288 str_buf = g_string_new (NULL);
289 g_return_val_if_fail (str_buf, NULL);
291 for (cur = a_this; cur; cur = cur->
next) {
300 g_string_append (str_buf,
" / ");
304 g_string_append (str_buf,
", ");
309 g_string_append (str_buf,
" ");
319 g_string_append (str_buf,
"+");
323 g_string_append (str_buf,
"-");
337 g_string_append (str_buf, (
const gchar *) content);
346 content = (guchar *) g_strndup
352 g_string_append_printf (str_buf,
"%s(",
356 guchar *tmp_str = NULL;
363 g_string_append (str_buf,
364 (
const gchar *) tmp_str);
369 g_string_append (str_buf,
")");
378 content = (guchar *) g_strndup
384 g_string_append_printf (str_buf,
393 content = (guchar *) g_strndup
399 g_string_append (str_buf, (
const gchar *) content);
407 content = (guchar *) g_strndup
413 g_string_append_printf
414 (str_buf,
"url(%s)", content);
422 guchar *tmp_str = NULL;
424 g_string_append (str_buf,
"rgb(");
428 g_string_append (str_buf, (
const gchar *) tmp_str);
432 g_string_append (str_buf,
")");
440 "?found unicoderange: dump not supported yet?");
445 content = (guchar *) g_strndup
451 g_string_append_printf (str_buf,
459 g_string_append (str_buf,
460 "Unrecognized Term type");
466 result =(guchar *) str_buf->str;
467 g_string_free (str_buf, FALSE);
477 GString *str_buf = NULL;
478 guchar *result = NULL,
481 g_return_val_if_fail (a_this, NULL);
483 str_buf = g_string_new (NULL);
484 g_return_val_if_fail (str_buf, NULL);
494 g_string_append_printf (str_buf,
" / ");
498 g_string_append_printf (str_buf,
", ");
503 g_string_append_printf (str_buf,
" ");
513 g_string_append_printf (str_buf,
"+");
517 g_string_append_printf (str_buf,
"-");
524 switch (a_this->
type) {
531 g_string_append (str_buf, (
const gchar *) content);
540 content = (guchar *) g_strndup
546 g_string_append_printf (str_buf,
"%s(",
550 guchar *tmp_str = NULL;
557 g_string_append_printf
564 g_string_append_printf (str_buf,
")");
574 content = (guchar *) g_strndup
580 g_string_append_printf (str_buf,
589 content = (guchar *) g_strndup
595 g_string_append (str_buf, (
const gchar *) content);
603 content = (guchar *) g_strndup
609 g_string_append_printf
610 (str_buf,
"url(%s)", content);
618 guchar *tmp_str = NULL;
620 g_string_append_printf (str_buf,
"rgb(");
624 g_string_append (str_buf, (
const gchar *) tmp_str);
628 g_string_append_printf (str_buf,
")");
634 g_string_append_printf
636 "?found unicoderange: dump not supported yet?");
641 content = (guchar *) g_strndup
647 g_string_append_printf (str_buf,
655 g_string_append_printf (str_buf,
657 "Unrecognized Term type");
662 result = (guchar *) str_buf->str;
663 g_string_free (str_buf, FALSE);
681 guchar *content = NULL;
683 g_return_if_fail (a_this);
688 fprintf (a_fp,
"%s", content);
701 CRTerm const *cur = NULL ;
704 g_return_val_if_fail (a_this, -1) ;
706 for (cur = a_this ; cur ; cur = cur->
next)
724 g_return_val_if_fail (a_this, NULL) ;
726 for (cur = a_this ; cur ; cur = cur->
next)
740 g_return_if_fail (a_this);
755 g_return_val_if_fail (a_this, FALSE);
777 g_return_if_fail (a_this);
779 cr_term_clear (a_this);
union _CRTerm::@3 ext_content
If the term is of type UNICODERANGE, this field holds the upper bound of the range.
typedefG_BEGIN_DECLS struct _CRRgb CRRgb
enum CRTermType type
The type of the term.
The implementation of the SAC parser.
CRTerm * cr_term_get_from_list(CRTerm *a_this, int itemnr)
Use an index to get a CRTerm from the expression.
guchar * cr_num_to_string(CRNum const *a_this)
cr_num_to_string: @a_this: the current instance of CRNum.
enum CRStatus cr_term_set_function(CRTerm *a_this, CRString *a_func_name, CRTerm *a_func_param)
void cr_term_dump(CRTerm const *a_this, FILE *a_fp)
Dumps the expression (a list of terms connected by operators) to a file.
enum CRStatus cr_term_set_hash(CRTerm *a_this, CRString *a_str)
void cr_string_destroy(CRString *a_this)
union _CRTerm::@2 content
The content of the term.
CREncoding
Encoding values.
enum CRStatus cr_parser_try_to_skip_spaces_and_comments(CRParser *a_this)
cr_parser_try_to_skip_spaces_and_comments: @a_this: the current instance of CRParser.
void cr_num_destroy(CRNum *a_this)
cr_num_destroy: @a_this: the this pointer of the current instance of CRNum.
CRStatus
The status type returned by the methods of the croco library.
CRTerm * cr_term_append_term(CRTerm *a_this, CRTerm *a_new_term)
Appends a new term to the current list of CRTerm.
CRTerm * cr_term_prepend_term(CRTerm *a_this, CRTerm *a_new_term)
Prepends a term to the list of terms represented by a_this.
enum CRStatus cr_term_set_rgb(CRTerm *a_this, CRRgb *a_rgb)
enum CRStatus cr_term_set_string(CRTerm *a_this, CRString *a_str)
The declaration of the CRNum class.
guchar * cr_term_to_string(CRTerm const *a_this)
Serializes the expression represented by the chained instances of #CRterm.
void cr_term_ref(CRTerm *a_this)
Increments the reference counter of the current instance of CRTerm.
CRParser * cr_parser_new_from_buf(guchar *a_buf, gulong a_len, enum CREncoding a_enc, gboolean a_free_buf)
cr_parser_new_from_buf: @a_buf: the buffer to parse.
typedefG_BEGIN_DECLS struct _CRString CRString
enum CRStatus cr_parser_parse_expr(CRParser *a_this, CRTerm **a_expr)
cr_parser_parse_expr: @a_this: the current instance of CRParser.
void cr_rgb_destroy(CRRgb *a_this)
cr_rgb_destroy: @a_this: the "this pointer" of the current instance of CRRgb.
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.
guchar * cr_rgb_to_string(CRRgb const *a_this)
cr_rgb_to_string: @a_this: the instance of CRRgb to serialize.
CRTerm * prev
A pointer to the previous term.
CRTerm * cr_term_new(void)
Instanciate a CRTerm.
int cr_term_nr_values(CRTerm const *a_this)
Return the number of terms in the expression.
enum UnaryOperator unary_op
The unary operator associated to the current term.
An abstraction of a css2 term as defined in the CSS2 spec in appendix D.1: term ::= [ NUMBER S* | PER...
enum Operator the_operator
The operator associated to the current term.
An abstraction of a number (num) as defined in the css2 spec.
The declaration file of the CRParser class.
void cr_parser_destroy(CRParser *a_this)
cr_parser_destroy: @a_this: the current instance of CRParser to destroy.
enum CRStatus cr_term_set_ident(CRTerm *a_this, CRString *a_str)
Declaration of the #CRTem class.
gboolean cr_term_unref(CRTerm *a_this)
Decrements the ref count of the current instance of CRTerm.
enum CRStatus cr_term_set_uri(CRTerm *a_this, CRString *a_str)
guchar * cr_term_one_to_string(CRTerm const *a_this)
CRTerm * next
A pointer to the next term, just in case this term is part of an expression.
enum CRStatus cr_term_set_number(CRTerm *a_this, CRNum *a_num)
void cr_term_destroy(CRTerm *a_this)
The destructor of the the CRTerm class.
#define cr_utils_trace_info(a_msg)
Traces an info message.