• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/libcroco/
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 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 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 <glib.h>
26#include "cr-utils.h"
27#include "cr-rgb.h"
28#include "cr-num.h"
29#include "cr-string.h"
30
31#ifndef __CR_TERM_H__
32#define __CR_TERM_H__
33
34G_BEGIN_DECLS
35
36/**
37 *@file
38 *Declaration of the #CRTem class.
39 */
40
41enum CRTermType
42{
43        TERM_NO_TYPE = 0,
44        TERM_NUMBER,
45        TERM_FUNCTION,
46        TERM_STRING,
47        TERM_IDENT,
48        TERM_URI,
49        TERM_RGB,
50        TERM_UNICODERANGE,
51        TERM_HASH
52} ;
53
54
55enum UnaryOperator
56{
57        NO_UNARY_UOP = 0,
58        PLUS_UOP,
59        MINUS_UOP,
60        EMPTY_UNARY_UOP
61} ;
62
63enum Operator
64{
65        NO_OP = 0,
66        DIVIDE,
67        COMMA
68} ;
69
70struct _CRTerm ;
71typedef struct _CRTerm CRTerm ;
72
73/**
74 *An abstraction of a css2 term as
75 *defined in the CSS2 spec in appendix D.1:
76 *term ::=
77 *[ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S*
78 *| ANGLE S* | TIME S* | FREQ S* | function ]
79 * | STRING S* | IDENT S* | URI S* | RGB S*
80 *| UNICODERANGE S* | hexcolor
81 */
82struct _CRTerm
83{
84        /**
85         *The type of the term.
86         */
87        enum CRTermType type ;
88
89        /**
90         *The unary operator associated to
91         *the current term.
92         */
93        enum UnaryOperator unary_op ;
94
95        /**
96         *The operator associated to the current term.
97         */
98        enum Operator the_operator ;
99
100
101        /**
102         *The content of the term.
103         *Depending of the type of the term,
104         *this holds either a number, a percentage ...
105         */
106        union
107        {
108                CRNum *num ;
109                CRString * str ;
110                CRRgb * rgb ;
111        } content ;
112
113        /**
114         *If the term is of type UNICODERANGE,
115         *this field holds the upper bound of the range.
116         *if the term is of type FUNCTION, this holds
117         *an instance of CRTerm that represents
118         * the expression which is the argument of the function.
119         */
120        union
121        {
122                CRTerm *func_param ;
123        } ext_content ;
124
125        /**
126         *A spare pointer, just in case.
127         *Can be used by the application.
128         */
129        gpointer app_data ;
130
131        glong ref_count ;
132
133        /**
134         *A pointer to the next term,
135         *just in case this term is part of
136         *an expression.
137         */
138        CRTerm *next ;
139
140        /**
141         *A pointer to the previous
142         *term.
143         */
144        CRTerm *prev ;
145        CRParsingLocation location ;
146} ;
147
148CRTerm * cr_term_parse_expression_from_buf (const guchar *a_buf,
149                                            enum CREncoding a_encoding) ;
150CRTerm * cr_term_new (void) ;
151
152enum CRStatus cr_term_set_number (CRTerm *a_this, CRNum *a_num) ;
153
154enum CRStatus cr_term_set_function (CRTerm *a_this,
155                                    CRString *a_func_name,
156                                    CRTerm *a_func_param) ;
157
158enum CRStatus cr_term_set_string (CRTerm *a_this, CRString *a_str) ;
159
160enum CRStatus cr_term_set_ident (CRTerm *a_this, CRString *a_str) ;
161
162enum CRStatus cr_term_set_uri (CRTerm *a_this, CRString *a_str) ;
163
164enum CRStatus cr_term_set_rgb (CRTerm *a_this, CRRgb *a_rgb) ;
165
166enum CRStatus cr_term_set_hash (CRTerm *a_this, CRString *a_str) ;
167
168CRTerm * cr_term_append_term (CRTerm *a_this, CRTerm *a_new_term) ;
169
170CRTerm * cr_term_prepend_term (CRTerm *a_this, CRTerm *a_new_term) ;
171
172guchar * cr_term_to_string (CRTerm *a_this) ;
173
174guchar * cr_term_one_to_string (CRTerm * a_this) ;
175
176void cr_term_dump (CRTerm *a_this, FILE *a_fp) ;
177
178int cr_term_nr_values (CRTerm *a_this) ;
179
180CRTerm * cr_term_get_from_list (CRTerm *a_this, int itemnr) ;
181
182void cr_term_ref (CRTerm *a_this) ;
183
184gboolean cr_term_unref (CRTerm *a_this) ;
185
186void cr_term_destroy (CRTerm * a_term) ;
187
188G_END_DECLS
189
190#endif /*__CR_TERM_H__*/
191