PageRenderTime 49ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/cssed-0.4.0/libcroco/parser/cr-term.h

#
C++ Header | 190 lines | 81 code | 40 blank | 69 comment | 0 complexity | 840cac532019168a257342c3ee534ef3 MD5 | raw file
Possible License(s): GPL-2.0
  1. /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
  2. /*
  3. * This file is part of The Croco Library
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of version 2.1 of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  17. * USA
  18. *
  19. * Author: Dodji Seketeli
  20. * See COPYRIGHTS file for copyright information.
  21. */
  22. #include <stdio.h>
  23. #include <glib.h>
  24. #include "cr-utils.h"
  25. #include "cr-rgb.h"
  26. #include "cr-num.h"
  27. #include "cr-string.h"
  28. #ifndef __CR_TERM_H__
  29. #define __CR_TERM_H__
  30. G_BEGIN_DECLS
  31. /**
  32. *@file
  33. *Declaration of the #CRTem class.
  34. */
  35. enum CRTermType
  36. {
  37. TERM_NO_TYPE = 0,
  38. TERM_NUMBER,
  39. TERM_FUNCTION,
  40. TERM_STRING,
  41. TERM_IDENT,
  42. TERM_URI,
  43. TERM_RGB,
  44. TERM_UNICODERANGE,
  45. TERM_HASH
  46. } ;
  47. enum UnaryOperator
  48. {
  49. NO_UNARY_UOP = 0,
  50. PLUS_UOP,
  51. MINUS_UOP,
  52. EMPTY_UNARY_UOP
  53. } ;
  54. enum Operator
  55. {
  56. NO_OP = 0,
  57. DIVIDE,
  58. COMMA
  59. } ;
  60. struct _CRTerm ;
  61. typedef struct _CRTerm CRTerm ;
  62. /**
  63. *An abstraction of a css2 term as
  64. *defined in the CSS2 spec in appendix D.1:
  65. *term ::=
  66. *[ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S*
  67. *| ANGLE S* | TIME S* | FREQ S* | function ]
  68. * | STRING S* | IDENT S* | URI S* | RGB S*
  69. *| UNICODERANGE S* | hexcolor
  70. */
  71. struct _CRTerm
  72. {
  73. /**
  74. *The type of the term.
  75. */
  76. enum CRTermType type ;
  77. /**
  78. *The unary operator associated to
  79. *the current term.
  80. */
  81. enum UnaryOperator unary_op ;
  82. /**
  83. *The operator associated to the current term.
  84. */
  85. enum Operator the_operator ;
  86. /**
  87. *The content of the term.
  88. *Depending of the type of the term,
  89. *this holds either a number, a percentage ...
  90. */
  91. union
  92. {
  93. CRNum *num ;
  94. CRString * str ;
  95. CRRgb * rgb ;
  96. } content ;
  97. /**
  98. *If the term is of type UNICODERANGE,
  99. *this field holds the upper bound of the range.
  100. *if the term is of type FUNCTION, this holds
  101. *an instance of CRTerm that represents
  102. * the expression which is the argument of the function.
  103. */
  104. union
  105. {
  106. CRTerm *func_param ;
  107. } ext_content ;
  108. /**
  109. *A spare pointer, just in case.
  110. *Can be used by the application.
  111. */
  112. gpointer app_data ;
  113. glong ref_count ;
  114. /**
  115. *A pointer to the next term,
  116. *just in case this term is part of
  117. *an expression.
  118. */
  119. CRTerm *next ;
  120. /**
  121. *A pointer to the previous
  122. *term.
  123. */
  124. CRTerm *prev ;
  125. CRParsingLocation location ;
  126. } ;
  127. CRTerm * cr_term_parse_expression_from_buf (const guchar *a_buf,
  128. enum CREncoding a_encoding) ;
  129. CRTerm * cr_term_new (void) ;
  130. enum CRStatus cr_term_set_number (CRTerm *a_this, CRNum *a_num) ;
  131. enum CRStatus cr_term_set_function (CRTerm *a_this,
  132. CRString *a_func_name,
  133. CRTerm *a_func_param) ;
  134. enum CRStatus cr_term_set_string (CRTerm *a_this, CRString *a_str) ;
  135. enum CRStatus cr_term_set_ident (CRTerm *a_this, CRString *a_str) ;
  136. enum CRStatus cr_term_set_uri (CRTerm *a_this, CRString *a_str) ;
  137. enum CRStatus cr_term_set_rgb (CRTerm *a_this, CRRgb *a_rgb) ;
  138. enum CRStatus cr_term_set_hash (CRTerm *a_this, CRString *a_str) ;
  139. CRTerm * cr_term_append_term (CRTerm *a_this, CRTerm *a_new_term) ;
  140. CRTerm * cr_term_prepend_term (CRTerm *a_this, CRTerm *a_new_term) ;
  141. guchar * cr_term_to_string (CRTerm *a_this) ;
  142. guchar * cr_term_one_to_string (CRTerm * a_this) ;
  143. void cr_term_dump (CRTerm *a_this, FILE *a_fp) ;
  144. int cr_term_nr_values (CRTerm *a_this) ;
  145. CRTerm * cr_term_get_from_list (CRTerm *a_this, int itemnr) ;
  146. void cr_term_ref (CRTerm *a_this) ;
  147. gboolean cr_term_unref (CRTerm *a_this) ;
  148. void cr_term_destroy (CRTerm * a_term) ;
  149. G_END_DECLS
  150. #endif /*__CR_TERM_H__*/