Libcroco
cr-term.c
Go to the documentation of this file.
1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
2 
3 /*
4  * This file is part of The Croco Library
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2.1 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  *
20  * Author: Dodji Seketeli
21  * See COPYRIGHTS file for copyright information.
22  */
23 
24 #include <stdio.h>
25 #include <string.h>
26 #include "cr-term.h"
27 #include "cr-num.h"
28 #include "cr-parser.h"
29 
30 /**
31  *@file
32  *Definition of the #CRTem class.
33  */
34 
35 static void
36 cr_term_clear (CRTerm * a_this)
37 {
38  g_return_if_fail (a_this);
39 
40  switch (a_this->type) {
41  case TERM_NUMBER:
42  if (a_this->content.num) {
43  cr_num_destroy (a_this->content.num);
44  a_this->content.num = NULL;
45  }
46  break;
47 
48  case TERM_FUNCTION:
49  if (a_this->ext_content.func_param) {
51  a_this->ext_content.func_param = NULL;
52  }
53  case TERM_STRING:
54  case TERM_IDENT:
55  case TERM_URI:
56  case TERM_HASH:
57  if (a_this->content.str) {
58  cr_string_destroy (a_this->content.str);
59  a_this->content.str = NULL;
60  }
61  break;
62 
63  case TERM_RGB:
64  if (a_this->content.rgb) {
65  cr_rgb_destroy (a_this->content.rgb);
66  a_this->content.rgb = NULL;
67  }
68  break;
69 
70  case TERM_UNICODERANGE:
71  case TERM_NO_TYPE:
72  default:
73  break;
74  }
75 
76  a_this->type = TERM_NO_TYPE;
77 }
78 
79 /**
80  *Instanciate a #CRTerm.
81  *@return the newly build instance
82  *of #CRTerm.
83  */
84 CRTerm *
86 {
87  CRTerm *result = NULL;
88 
89  result = g_try_malloc (sizeof (CRTerm));
90  if (!result) {
91  cr_utils_trace_info ("Out of memory");
92  return NULL;
93  }
94  memset (result, 0, sizeof (CRTerm));
95  return result;
96 }
97 
98 /**
99  *Parses an expresion as defined by the css2 spec
100  *and builds the expression as a list of terms.
101  *@param a_buf the buffer to parse.
102  *@return a pointer to the first term of the expression or
103  *NULL if parsing failed.
104  */
105 CRTerm *
106 cr_term_parse_expression_from_buf (const guchar * a_buf,
107  enum CREncoding a_encoding)
108 {
109  CRParser *parser = NULL;
110  CRTerm *result = NULL;
111  enum CRStatus status = CR_OK;
112 
113  g_return_val_if_fail (a_buf, NULL);
114 
115  parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen ((const char *) a_buf),
116  a_encoding, FALSE);
117  g_return_val_if_fail (parser, NULL);
118 
120  if (status != CR_OK) {
121  goto cleanup;
122  }
123  status = cr_parser_parse_expr (parser, &result);
124  if (status != CR_OK) {
125  if (result) {
126  cr_term_destroy (result);
127  result = NULL;
128  }
129  }
130 
131  cleanup:
132  if (parser) {
133  cr_parser_destroy (parser);
134  parser = NULL;
135  }
136 
137  return result;
138 }
139 
140 enum CRStatus
141 cr_term_set_number (CRTerm * a_this, CRNum * a_num)
142 {
143  g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
144 
145  cr_term_clear (a_this);
146 
147  a_this->type = TERM_NUMBER;
148  a_this->content.num = a_num;
149  return CR_OK;
150 }
151 
152 enum CRStatus
153 cr_term_set_function (CRTerm * a_this, CRString * a_func_name,
154  CRTerm * a_func_param)
155 {
156  g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
157 
158  cr_term_clear (a_this);
159 
160  a_this->type = TERM_FUNCTION;
161  a_this->content.str = a_func_name;
162  a_this->ext_content.func_param = a_func_param;
163  return CR_OK;
164 }
165 
166 enum CRStatus
167 cr_term_set_string (CRTerm * a_this, CRString * a_str)
168 {
169  g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
170 
171  cr_term_clear (a_this);
172 
173  a_this->type = TERM_STRING;
174  a_this->content.str = a_str;
175  return CR_OK;
176 }
177 
178 enum CRStatus
179 cr_term_set_ident (CRTerm * a_this, CRString * a_str)
180 {
181  g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
182 
183  cr_term_clear (a_this);
184 
185  a_this->type = TERM_IDENT;
186  a_this->content.str = a_str;
187  return CR_OK;
188 }
189 
190 enum CRStatus
191 cr_term_set_uri (CRTerm * a_this, CRString * a_str)
192 {
193  g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
194 
195  cr_term_clear (a_this);
196 
197  a_this->type = TERM_URI;
198  a_this->content.str = a_str;
199  return CR_OK;
200 }
201 
202 enum CRStatus
203 cr_term_set_rgb (CRTerm * a_this, CRRgb * a_rgb)
204 {
205  g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
206 
207  cr_term_clear (a_this);
208 
209  a_this->type = TERM_RGB;
210  a_this->content.rgb = a_rgb;
211  return CR_OK;
212 }
213 
214 enum CRStatus
215 cr_term_set_hash (CRTerm * a_this, CRString * a_str)
216 {
217  g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
218 
219  cr_term_clear (a_this);
220 
221  a_this->type = TERM_HASH;
222  a_this->content.str = a_str;
223  return CR_OK;
224 }
225 
226 /**
227  *Appends a new term to the current list of #CRTerm.
228  *
229  *@param a_this the "this pointer" of the current instance
230  *of #CRTerm .
231  *@param a_new_term the term to append.
232  *@return the list of terms with the a_new_term appended to it.
233  */
234 CRTerm *
235 cr_term_append_term (CRTerm * a_this, CRTerm * a_new_term)
236 {
237  CRTerm *cur = NULL;
238 
239  g_return_val_if_fail (a_new_term, NULL);
240 
241  if (a_this == NULL)
242  return a_new_term;
243 
244  for (cur = a_this; cur->next; cur = cur->next) ;
245 
246  cur->next = a_new_term;
247  a_new_term->prev = cur;
248 
249  return a_this;
250 }
251 
252 /**
253  *Prepends a term to the list of terms represented by a_this.
254  *
255  *@param a_this the "this pointer" of the current instance of
256  *#CRTerm .
257  *@param a_new_term the term to prepend.
258  *@return the head of the new list.
259  */
260 CRTerm *
261 cr_term_prepend_term (CRTerm * a_this, CRTerm * a_new_term)
262 {
263  g_return_val_if_fail (a_this && a_new_term, NULL);
264 
265  a_new_term->next = a_this;
266  a_this->prev = a_new_term;
267 
268  return a_new_term;
269 }
270 
271 /**
272  *Serializes the expression represented by
273  *the chained instances of #CRterm.
274  *@param a_this the current instance of #CRTerm
275  *@return the zero terminated string containing the serialized
276  *form of #CRTerm. MUST BE FREED BY THE CALLER using g_free().
277  */
278 guchar *
279 cr_term_to_string (CRTerm const * a_this)
280 {
281  GString *str_buf = NULL;
282  CRTerm const *cur = NULL;
283  guchar *result = NULL,
284  *content = NULL;
285 
286  g_return_val_if_fail (a_this, NULL);
287 
288  str_buf = g_string_new (NULL);
289  g_return_val_if_fail (str_buf, NULL);
290 
291  for (cur = a_this; cur; cur = cur->next) {
292  if ((cur->content.str == NULL)
293  && (cur->content.num == NULL)
294  && (cur->content.str == NULL)
295  && (cur->content.rgb == NULL))
296  continue;
297 
298  switch (cur->the_operator) {
299  case DIVIDE:
300  g_string_append (str_buf, " / ");
301  break;
302 
303  case COMMA:
304  g_string_append (str_buf, ", ");
305  break;
306 
307  case NO_OP:
308  if (cur->prev) {
309  g_string_append (str_buf, " ");
310  }
311  break;
312  default:
313 
314  break;
315  }
316 
317  switch (cur->unary_op) {
318  case PLUS_UOP:
319  g_string_append (str_buf, "+");
320  break;
321 
322  case MINUS_UOP:
323  g_string_append (str_buf, "-");
324  break;
325 
326  default:
327  break;
328  }
329 
330  switch (cur->type) {
331  case TERM_NUMBER:
332  if (cur->content.num) {
333  content = cr_num_to_string (cur->content.num);
334  }
335 
336  if (content) {
337  g_string_append (str_buf, (const gchar *) content);
338  g_free (content);
339  content = NULL;
340  }
341 
342  break;
343 
344  case TERM_FUNCTION:
345  if (cur->content.str) {
346  content = (guchar *) g_strndup
347  (cur->content.str->stryng->str,
348  cur->content.str->stryng->len);
349  }
350 
351  if (content) {
352  g_string_append_printf (str_buf, "%s(",
353  content);
354 
355  if (cur->ext_content.func_param) {
356  guchar *tmp_str = NULL;
357 
358  tmp_str = cr_term_to_string
359  (cur->
360  ext_content.func_param);
361 
362  if (tmp_str) {
363  g_string_append (str_buf,
364  (const gchar *) tmp_str);
365  g_free (tmp_str);
366  tmp_str = NULL;
367  }
368  }
369  g_string_append (str_buf, ")");
370  g_free (content);
371  content = NULL;
372  }
373 
374  break;
375 
376  case TERM_STRING:
377  if (cur->content.str) {
378  content = (guchar *) g_strndup
379  (cur->content.str->stryng->str,
380  cur->content.str->stryng->len);
381  }
382 
383  if (content) {
384  g_string_append_printf (str_buf,
385  "\"%s\"", content);
386  g_free (content);
387  content = NULL;
388  }
389  break;
390 
391  case TERM_IDENT:
392  if (cur->content.str) {
393  content = (guchar *) g_strndup
394  (cur->content.str->stryng->str,
395  cur->content.str->stryng->len);
396  }
397 
398  if (content) {
399  g_string_append (str_buf, (const gchar *) content);
400  g_free (content);
401  content = NULL;
402  }
403  break;
404 
405  case TERM_URI:
406  if (cur->content.str) {
407  content = (guchar *) g_strndup
408  (cur->content.str->stryng->str,
409  cur->content.str->stryng->len);
410  }
411 
412  if (content) {
413  g_string_append_printf
414  (str_buf, "url(%s)", content);
415  g_free (content);
416  content = NULL;
417  }
418  break;
419 
420  case TERM_RGB:
421  if (cur->content.rgb) {
422  guchar *tmp_str = NULL;
423 
424  g_string_append (str_buf, "rgb(");
425  tmp_str = cr_rgb_to_string (cur->content.rgb);
426 
427  if (tmp_str) {
428  g_string_append (str_buf, (const gchar *) tmp_str);
429  g_free (tmp_str);
430  tmp_str = NULL;
431  }
432  g_string_append (str_buf, ")");
433  }
434 
435  break;
436 
437  case TERM_UNICODERANGE:
438  g_string_append
439  (str_buf,
440  "?found unicoderange: dump not supported yet?");
441  break;
442 
443  case TERM_HASH:
444  if (cur->content.str) {
445  content = (guchar *) g_strndup
446  (cur->content.str->stryng->str,
447  cur->content.str->stryng->len);
448  }
449 
450  if (content) {
451  g_string_append_printf (str_buf,
452  "#%s", content);
453  g_free (content);
454  content = NULL;
455  }
456  break;
457 
458  default:
459  g_string_append (str_buf,
460  "Unrecognized Term type");
461  break;
462  }
463  }
464 
465  if (str_buf) {
466  result =(guchar *) str_buf->str;
467  g_string_free (str_buf, FALSE);
468  str_buf = NULL;
469  }
470 
471  return result;
472 }
473 
474 guchar *
476 {
477  GString *str_buf = NULL;
478  guchar *result = NULL,
479  *content = NULL;
480 
481  g_return_val_if_fail (a_this, NULL);
482 
483  str_buf = g_string_new (NULL);
484  g_return_val_if_fail (str_buf, NULL);
485 
486  if ((a_this->content.str == NULL)
487  && (a_this->content.num == NULL)
488  && (a_this->content.str == NULL)
489  && (a_this->content.rgb == NULL))
490  return NULL ;
491 
492  switch (a_this->the_operator) {
493  case DIVIDE:
494  g_string_append_printf (str_buf, " / ");
495  break;
496 
497  case COMMA:
498  g_string_append_printf (str_buf, ", ");
499  break;
500 
501  case NO_OP:
502  if (a_this->prev) {
503  g_string_append_printf (str_buf, " ");
504  }
505  break;
506  default:
507 
508  break;
509  }
510 
511  switch (a_this->unary_op) {
512  case PLUS_UOP:
513  g_string_append_printf (str_buf, "+");
514  break;
515 
516  case MINUS_UOP:
517  g_string_append_printf (str_buf, "-");
518  break;
519 
520  default:
521  break;
522  }
523 
524  switch (a_this->type) {
525  case TERM_NUMBER:
526  if (a_this->content.num) {
527  content = cr_num_to_string (a_this->content.num);
528  }
529 
530  if (content) {
531  g_string_append (str_buf, (const gchar *) content);
532  g_free (content);
533  content = NULL;
534  }
535 
536  break;
537 
538  case TERM_FUNCTION:
539  if (a_this->content.str) {
540  content = (guchar *) g_strndup
541  (a_this->content.str->stryng->str,
542  a_this->content.str->stryng->len);
543  }
544 
545  if (content) {
546  g_string_append_printf (str_buf, "%s(",
547  content);
548 
549  if (a_this->ext_content.func_param) {
550  guchar *tmp_str = NULL;
551 
552  tmp_str = cr_term_to_string
553  (a_this->
554  ext_content.func_param);
555 
556  if (tmp_str) {
557  g_string_append_printf
558  (str_buf,
559  "%s", tmp_str);
560  g_free (tmp_str);
561  tmp_str = NULL;
562  }
563 
564  g_string_append_printf (str_buf, ")");
565  g_free (content);
566  content = NULL;
567  }
568  }
569 
570  break;
571 
572  case TERM_STRING:
573  if (a_this->content.str) {
574  content = (guchar *) g_strndup
575  (a_this->content.str->stryng->str,
576  a_this->content.str->stryng->len);
577  }
578 
579  if (content) {
580  g_string_append_printf (str_buf,
581  "\"%s\"", content);
582  g_free (content);
583  content = NULL;
584  }
585  break;
586 
587  case TERM_IDENT:
588  if (a_this->content.str) {
589  content = (guchar *) g_strndup
590  (a_this->content.str->stryng->str,
591  a_this->content.str->stryng->len);
592  }
593 
594  if (content) {
595  g_string_append (str_buf, (const gchar *) content);
596  g_free (content);
597  content = NULL;
598  }
599  break;
600 
601  case TERM_URI:
602  if (a_this->content.str) {
603  content = (guchar *) g_strndup
604  (a_this->content.str->stryng->str,
605  a_this->content.str->stryng->len);
606  }
607 
608  if (content) {
609  g_string_append_printf
610  (str_buf, "url(%s)", content);
611  g_free (content);
612  content = NULL;
613  }
614  break;
615 
616  case TERM_RGB:
617  if (a_this->content.rgb) {
618  guchar *tmp_str = NULL;
619 
620  g_string_append_printf (str_buf, "rgb(");
621  tmp_str = cr_rgb_to_string (a_this->content.rgb);
622 
623  if (tmp_str) {
624  g_string_append (str_buf, (const gchar *) tmp_str);
625  g_free (tmp_str);
626  tmp_str = NULL;
627  }
628  g_string_append_printf (str_buf, ")");
629  }
630 
631  break;
632 
633  case TERM_UNICODERANGE:
634  g_string_append_printf
635  (str_buf,
636  "?found unicoderange: dump not supported yet?");
637  break;
638 
639  case TERM_HASH:
640  if (a_this->content.str) {
641  content = (guchar *) g_strndup
642  (a_this->content.str->stryng->str,
643  a_this->content.str->stryng->len);
644  }
645 
646  if (content) {
647  g_string_append_printf (str_buf,
648  "#%s", content);
649  g_free (content);
650  content = NULL;
651  }
652  break;
653 
654  default:
655  g_string_append_printf (str_buf,
656  "%s",
657  "Unrecognized Term type");
658  break;
659  }
660 
661  if (str_buf) {
662  result = (guchar *) str_buf->str;
663  g_string_free (str_buf, FALSE);
664  str_buf = NULL;
665  }
666 
667  return result;
668 }
669 
670 /**
671  *Dumps the expression (a list of terms connected by operators)
672  *to a file.
673  *TODO: finish the dump. The dump of some type of terms have not yet been
674  *implemented.
675  *@param a_this the current instance of #CRTerm.
676  *@param a_fp the destination file pointer.
677  */
678 void
679 cr_term_dump (CRTerm const * a_this, FILE * a_fp)
680 {
681  guchar *content = NULL;
682 
683  g_return_if_fail (a_this);
684 
685  content = cr_term_to_string (a_this);
686 
687  if (content) {
688  fprintf (a_fp, "%s", content);
689  g_free (content);
690  }
691 }
692 
693 /**
694  *Return the number of terms in the expression.
695  *@param a_this the current instance of #CRTerm.
696  *@return number of terms in the expression.
697  */
698 int
699 cr_term_nr_values (CRTerm const *a_this)
700 {
701  CRTerm const *cur = NULL ;
702  int nr = 0;
703 
704  g_return_val_if_fail (a_this, -1) ;
705 
706  for (cur = a_this ; cur ; cur = cur->next)
707  nr ++;
708  return nr;
709 }
710 
711 /**
712  *Use an index to get a CRTerm from the expression.
713  *@param a_this the current instance of #CRTerm.
714  *@param itemnr the index into the expression.
715  *@return CRTerm at position itemnr, if itemnr > number of terms - 1,
716  *it will return NULL.
717  */
718 CRTerm *
719 cr_term_get_from_list (CRTerm *a_this, int itemnr)
720 {
721  CRTerm *cur = NULL ;
722  int nr = 0;
723 
724  g_return_val_if_fail (a_this, NULL) ;
725 
726  for (cur = a_this ; cur ; cur = cur->next)
727  if (nr++ == itemnr)
728  return cur;
729  return NULL;
730 }
731 
732 /**
733  *Increments the reference counter of the current instance
734  *of #CRTerm.*
735  *@param a_this the current instance of #CRTerm.
736  */
737 void
738 cr_term_ref (CRTerm * a_this)
739 {
740  g_return_if_fail (a_this);
741 
742  a_this->ref_count++;
743 }
744 
745 /**
746  *Decrements the ref count of the current instance of
747  *#CRTerm. If the ref count reaches zero, the instance is
748  *destroyed.
749  *@param a_this the current instance of #CRTerm.
750  *@return TRUE if the current instance has been destroyed, FALSE otherwise.
751  */
752 gboolean
754 {
755  g_return_val_if_fail (a_this, FALSE);
756 
757  if (a_this->ref_count) {
758  a_this->ref_count--;
759  }
760 
761  if (a_this->ref_count == 0) {
762  cr_term_destroy (a_this);
763  return TRUE;
764  }
765 
766  return FALSE;
767 }
768 
769 /**
770  *The destructor of the the #CRTerm class.
771  *@param a_this the "this pointer" of the current instance
772  *of #CRTerm.
773  */
774 void
776 {
777  g_return_if_fail (a_this);
778 
779  cr_term_clear (a_this);
780 
781  if (a_this->next) {
782  cr_term_destroy (a_this->next);
783  a_this->next = NULL;
784  }
785 
786  if (a_this) {
787  g_free (a_this);
788  }
789 
790 }
TERM_FUNCTION
@ TERM_FUNCTION
Definition: cr-term.h:45
TERM_STRING
@ TERM_STRING
Definition: cr-term.h:46
_CRTerm::the_operator
enum Operator the_operator
The operator associated to the current term.
Definition: cr-term.h:98
cr_parser_parse_expr
enum CRStatus cr_parser_parse_expr(CRParser *a_this, CRTerm **a_expr)
cr_parser_parse_expr: @a_this: the current instance of CRParser.
Definition: cr-parser.c:3011
cr_term_set_hash
enum CRStatus cr_term_set_hash(CRTerm *a_this, CRString *a_str)
Definition: cr-term.c:215
cr_term_set_function
enum CRStatus cr_term_set_function(CRTerm *a_this, CRString *a_func_name, CRTerm *a_func_param)
Definition: cr-term.c:153
cr_parser_new_from_buf
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.
Definition: cr-parser.c:2784
cr_term_destroy
void cr_term_destroy(CRTerm *a_this)
The destructor of the the CRTerm class.
Definition: cr-term.c:775
COMMA
@ COMMA
Definition: cr-term.h:67
TERM_RGB
@ TERM_RGB
Definition: cr-term.h:49
_CRTerm::type
enum CRTermType type
The type of the term.
Definition: cr-term.h:87
_CRParser
The implementation of the SAC parser.
Definition: cr-parser.h:51
cr_num_to_string
guchar * cr_num_to_string(CRNum const *a_this)
cr_num_to_string: @a_this: the current instance of CRNum.
Definition: cr-num.c:95
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.
Definition: cr-term.c:719
_CRTerm::str
CRString * str
Definition: cr-term.h:109
PLUS_UOP
@ PLUS_UOP
Definition: cr-term.h:58
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.
Definition: cr-term.c:679
cr_parser_try_to_skip_spaces_and_comments
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.
Definition: cr-parser.c:621
CR_BAD_PARAM_ERROR
@ CR_BAD_PARAM_ERROR
Definition: cr-utils.h:45
cr-parser.h
TERM_IDENT
@ TERM_IDENT
Definition: cr-term.h:47
CRString
typedefG_BEGIN_DECLS struct _CRString CRString
Definition: cr-string.h:37
cr_rgb_to_string
guchar * cr_rgb_to_string(CRRgb const *a_this)
cr_rgb_to_string: @a_this: the instance of CRRgb to serialize.
Definition: cr-rgb.c:248
cr_term_set_rgb
enum CRStatus cr_term_set_rgb(CRTerm *a_this, CRRgb *a_rgb)
Definition: cr-term.c:203
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.
Definition: cr-term.c:106
_CRTerm::ref_count
glong ref_count
Definition: cr-term.h:131
cr_string_destroy
void cr_string_destroy(CRString *a_this)
Definition: cr-string.c:159
CR_OK
@ CR_OK
Definition: cr-utils.h:44
_CRNum
An abstraction of a number (num) as defined in the css2 spec.
Definition: cr-num.h:90
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.
Definition: cr-term.c:235
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.
Definition: cr-term.c:261
cr_term_to_string
guchar * cr_term_to_string(CRTerm const *a_this)
Serializes the expression represented by the chained instances of #CRterm.
Definition: cr-term.c:279
_CRTerm::ext_content
union _CRTerm::@3 ext_content
If the term is of type UNICODERANGE, this field holds the upper bound of the range.
cr_term_new
CRTerm * cr_term_new(void)
Instanciate a CRTerm.
Definition: cr-term.c:85
cr_term_nr_values
int cr_term_nr_values(CRTerm const *a_this)
Return the number of terms in the expression.
Definition: cr-term.c:699
cr_num_destroy
void cr_num_destroy(CRNum *a_this)
cr_num_destroy: @a_this: the this pointer of the current instance of CRNum.
Definition: cr-num.c:308
_CRTerm::next
CRTerm * next
A pointer to the next term, just in case this term is part of an expression.
Definition: cr-term.h:138
DIVIDE
@ DIVIDE
Definition: cr-term.h:66
cr_term_ref
void cr_term_ref(CRTerm *a_this)
Increments the reference counter of the current instance of CRTerm.
Definition: cr-term.c:738
cr-num.h
cr_term_set_string
enum CRStatus cr_term_set_string(CRTerm *a_this, CRString *a_str)
Definition: cr-term.c:167
_CRTerm::unary_op
enum UnaryOperator unary_op
The unary operator associated to the current term.
Definition: cr-term.h:93
TERM_HASH
@ TERM_HASH
Definition: cr-term.h:51
cr_term_one_to_string
guchar * cr_term_one_to_string(CRTerm const *a_this)
Definition: cr-term.c:475
NO_OP
@ NO_OP
Definition: cr-term.h:65
cr-term.h
TERM_NO_TYPE
@ TERM_NO_TYPE
Definition: cr-term.h:43
TERM_URI
@ TERM_URI
Definition: cr-term.h:48
CRRgb
typedefG_BEGIN_DECLS struct _CRRgb CRRgb
Definition: cr-rgb.h:34
CREncoding
CREncoding
Encoding values.
Definition: cr-utils.h:84
_CRTerm::num
CRNum * num
Definition: cr-term.h:108
_CRTerm
An abstraction of a css2 term as defined in the CSS2 spec in appendix D.1: term ::= [ NUMBER S* | PER...
Definition: cr-term.h:82
_CRTerm::func_param
CRTerm * func_param
Definition: cr-term.h:122
cr_term_set_ident
enum CRStatus cr_term_set_ident(CRTerm *a_this, CRString *a_str)
Definition: cr-term.c:179
_CRTerm::content
union _CRTerm::@2 content
The content of the term.
CRStatus
CRStatus
The status type returned by the methods of the croco library.
Definition: cr-utils.h:43
MINUS_UOP
@ MINUS_UOP
Definition: cr-term.h:59
cr_rgb_destroy
void cr_rgb_destroy(CRRgb *a_this)
cr_rgb_destroy: @a_this: the "this pointer" of the current instance of CRRgb.
Definition: cr-rgb.c:632
TERM_NUMBER
@ TERM_NUMBER
Definition: cr-term.h:44
cr_parser_destroy
void cr_parser_destroy(CRParser *a_this)
cr_parser_destroy: @a_this: the current instance of CRParser to destroy.
Definition: cr-parser.c:4498
cr_term_set_uri
enum CRStatus cr_term_set_uri(CRTerm *a_this, CRString *a_str)
Definition: cr-term.c:191
_CRTerm::rgb
CRRgb * rgb
Definition: cr-term.h:110
cr_term_unref
gboolean cr_term_unref(CRTerm *a_this)
Decrements the ref count of the current instance of CRTerm.
Definition: cr-term.c:753
_CRTerm::prev
CRTerm * prev
A pointer to the previous term.
Definition: cr-term.h:144
cr_utils_trace_info
#define cr_utils_trace_info(a_msg)
Traces an info message.
Definition: cr-utils.h:127
cr_term_set_number
enum CRStatus cr_term_set_number(CRTerm *a_this, CRNum *a_num)
Definition: cr-term.c:141
TERM_UNICODERANGE
@ TERM_UNICODERANGE
Definition: cr-term.h:50