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

cr-stylesheet.c

Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode: ni; 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-stylesheet.c,v 1.1 2003/04/12 16:50:31 dodji Exp $
00025  */
00026 
00027 #include "string.h"
00028 #include "cr-stylesheet.h"
00029 
00030 /**
00031  *@file
00032  *The definition of the #CRStyleSheet class
00033  */
00034 
00035 /**
00036  *Constructor of the #CRStyleSheet class.
00037  *@param the initial list of css statements.
00038  *@return the newly built css2 stylesheet, or NULL in case of error.
00039  */
00040 CRStyleSheet *
00041 cr_stylesheet_new (CRStatement *a_stmts)
00042 {
00043         CRStyleSheet *result ;
00044 
00045         result = g_try_malloc (sizeof (CRStyleSheet)) ;
00046         if (!result)
00047         {
00048                 cr_utils_trace_info ("Out of memory") ;
00049                 return NULL ;
00050         }
00051 
00052         memset (result, 0, sizeof (CRStyleSheet)) ;
00053 
00054         if (a_stmts)
00055                 result->statements = a_stmts ;
00056 
00057         return result ;
00058 }
00059 
00060 
00061 /**
00062  *Dumps the current css2 stylesheet to a file.
00063  *@param a_this the current instance of #CRStyleSheet.
00064  *@param a_fp the destination file
00065  */
00066 void
00067 cr_stylesheet_dump (CRStyleSheet *a_this, FILE *a_fp)
00068 {
00069         CRStatement * cur_stmt = NULL ;
00070 
00071         g_return_if_fail (a_this && a_this->statements) ;
00072 
00073         for (cur_stmt = a_this->statements ; 
00074              cur_stmt ;
00075              cur_stmt = cur_stmt->next)
00076         {
00077                 cr_statement_dump (cur_stmt, a_fp, 0) ;
00078         }
00079 }
00080 
00081 void
00082 cr_stylesheet_ref (CRStyleSheet *a_this)
00083 {
00084         g_return_if_fail (a_this) ;
00085 
00086         a_this->ref_count ++ ;
00087 }
00088 
00089 gboolean
00090 cr_stylesheet_unref (CRStyleSheet *a_this)
00091 {
00092         g_return_val_if_fail (a_this, FALSE) ;
00093         
00094         if (a_this->ref_count)
00095                 a_this->ref_count -- ;
00096 
00097         if (!a_this->ref_count)
00098         {
00099                 cr_stylesheet_destroy (a_this) ;
00100                 return TRUE ;
00101         }
00102 
00103         return FALSE ;
00104 }
00105 
00106 
00107 /**
00108  *Destructor of the #CRStyleSheet class.
00109  *@param a_this the current instance of the #CRStyleSheet class.
00110  */
00111 void
00112 cr_stylesheet_destroy (CRStyleSheet *a_this)
00113 {
00114         g_return_if_fail (a_this) ;
00115 
00116         if (a_this->statements)
00117         {
00118                 cr_statement_destroy (a_this->statements) ;
00119                 a_this->statements = NULL ;
00120         }
00121         g_free (a_this) ;
00122 }

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