Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

cr-term.h

Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
00002 
00003 /*
00004  * This file is part of The Croco Library
00005  *
00006  * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of version 2.1 of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020  * USA
00021  */
00022 
00023 /*
00024  *$Id: cr-term.h,v 1.4 2003/06/20 22:08:50 dodji Exp $
00025  */
00026 
00027 #include <stdio.h>
00028 #include <glib.h>
00029 #include "cr-utils.h"
00030 #include "cr-rgb.h"
00031 #include "cr-num.h"
00032 
00033 #ifndef __CR_TERM_H__
00034 #define __CR_TERM_H__
00035 
00036 G_END_DECLS
00037 
00038 /**
00039  *@file
00040  *Declaration of the #CRTem class.
00041  */
00042 
00043 enum CRTermType
00044 {        
00045         TERM_NO_TYPE = 0,
00046         TERM_NUMBER,
00047         TERM_FUNCTION,
00048         TERM_STRING,
00049         TERM_IDENT,
00050         TERM_URI,
00051         TERM_RGB,
00052         TERM_UNICODERANGE,
00053         TERM_HASH,
00054 } ;
00055 
00056 
00057 enum UnaryOperator
00058 {
00059         NO_UNARY_UOP = 0,
00060         PLUS_UOP,
00061         MINUS_UOP,
00062         EMPTY_UNARY_UOP
00063 } ;
00064 
00065 enum Operator
00066 {
00067         NO_OP = 0,
00068         DIVIDE,
00069         COMMA           
00070 } ;
00071 
00072 struct _CRTerm ;
00073 typedef struct _CRTerm CRTerm ;
00074 
00075 /**
00076  *An abstraction of a css2 term as
00077  *defined in the CSS2 spec in appendix D.1:
00078  *term ::=
00079  *[ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* 
00080  *| ANGLE S* | TIME S* | FREQ S* | function ]
00081  * | STRING S* | IDENT S* | URI S* | RGB S* 
00082  *| UNICODERANGE S* | hexcolor
00083  */
00084 struct _CRTerm
00085 {
00086         /**
00087          *The type of the term.
00088          */
00089         enum CRTermType type ;
00090                 
00091         /**
00092          *The unary operator associated to
00093          *the current term.
00094          */
00095         enum UnaryOperator unary_op ;
00096 
00097         /**
00098          *The operator associated to the current term.
00099          */
00100         enum Operator operator ;
00101 
00102 
00103         /**
00104          *The content of the term.
00105          *Depending of the type of the term,
00106          *this holds either a number, a percentage ...
00107          */
00108         union
00109         {
00110                 CRNum *num ;
00111                 GString * str ;
00112                 CRRgb * rgb ;
00113         } content ;
00114 
00115         /**
00116          *If the term is of type UNICODERANGE, 
00117          *this field holds the upper bound of the range.
00118          *if the term is of type FUNCTION, this holds
00119          *an instance of CRTerm that represents
00120          * the expression which is the argument of the function.
00121          */
00122         union
00123         {
00124                 CRTerm *func_param ;                        
00125         } ext_content ;
00126 
00127         /**
00128          *A spare pointer, just in case.
00129          *Can be used by the application.
00130          */
00131         gpointer app_data ;
00132 
00133         glong ref_count ;
00134 
00135         /**
00136          *A pointer to the next term, 
00137          *just in case this term is part of
00138          *an expression.
00139          */
00140         CRTerm *next ;
00141 
00142         /**
00143          *A pointer to the previous
00144          *term.
00145          */
00146         CRTerm *prev ;
00147 } ;
00148 
00149 CRTerm *
00150 cr_term_parse_expression_from_buf (const guchar *a_buf, 
00151                                    enum CREncoding a_encoding) ;
00152 CRTerm *
00153 cr_term_new (void) ;
00154 
00155 enum CRStatus
00156 cr_term_set_number (CRTerm *a_this, CRNum *a_num) ;
00157         
00158 enum CRStatus
00159 cr_term_set_function (CRTerm *a_this, GString *a_func_name,
00160                       CRTerm *a_func_param) ;
00161 
00162 enum CRStatus
00163 cr_term_set_string (CRTerm *a_this, GString *a_str) ;
00164 
00165 enum CRStatus
00166 cr_term_set_ident (CRTerm *a_this, GString *a_str) ;
00167 
00168 enum CRStatus
00169 cr_term_set_uri (CRTerm *a_this, GString *a_str) ;
00170         
00171 enum CRStatus
00172 cr_term_set_rgb (CRTerm *a_this, CRRgb *a_rgb) ;                
00173         
00174 enum CRStatus
00175 cr_term_set_hash (CRTerm *a_this, GString *a_str) ;
00176         
00177 CRTerm *
00178 cr_term_append_term (CRTerm *a_this, CRTerm *a_new_term) ;
00179 
00180 CRTerm *
00181 cr_term_prepend_term (CRTerm *a_this, CRTerm *a_new_term) ;
00182 
00183 
00184 guchar *
00185 cr_term_to_string (CRTerm *a_this) ;
00186 
00187 void
00188 cr_term_dump (CRTerm *a_this, FILE *a_fp) ;
00189 
00190 void
00191 cr_term_ref (CRTerm *a_this) ;
00192 
00193 gboolean
00194 cr_term_unref (CRTerm *a_this) ;
00195 
00196 void
00197 cr_term_destroy (CRTerm * a_term) ;
00198 
00199 G_END_DECLS
00200 
00201 #endif /*__CR_TERM_H__*/

Generated on Wed Oct 1 01:36:49 2003 for Libcroco by doxygen 1.3.3