Libcroco
cr-tknzr.h
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 coypyright information.
22  */
23 
24 /**
25  *@file
26  *The declaration of the #CRTknzr (tokenizer)
27  *class.
28  */
29 
30 #ifndef __CR_TKNZR_H__
31 #define __CR_TKNZR_H__
32 
33 #include "cr-utils.h"
34 #include "cr-input.h"
35 #include "cr-token.h"
36 
37 G_BEGIN_DECLS
38 
39 
40 typedef struct _CRTknzr CRTknzr ;
41 typedef struct _CRTknzrPriv CRTknzrPriv ;
42 
43 /**
44  *The tokenizer is the class that knows
45  *about all the css token. Its main job is
46  *to return the next token found in the character
47  *input stream.
48  */
49 struct _CRTknzr
50 {
51  /*the private data of the tokenizer.*/
53 } ;
54 
55 CRTknzr * cr_tknzr_new (CRInput *a_input) ;
56 
57 CRTknzr * cr_tknzr_new_from_uri (const guchar *a_file_uri,
58  enum CREncoding a_enc) ;
59 
60 CRTknzr * cr_tknzr_new_from_buf (guchar *a_buf, gulong a_len,
61  enum CREncoding a_enc,
62  gboolean a_free_at_destroy) ;
63 
64 gboolean cr_tknzr_unref (CRTknzr *a_this) ;
65 
66 void cr_tknzr_ref (CRTknzr *a_this) ;
67 
68 enum CRStatus cr_tknzr_read_byte (CRTknzr *a_this, guchar *a_byte) ;
69 
70 enum CRStatus cr_tknzr_read_char (CRTknzr *a_this, guint32 *a_char);
71 
72 enum CRStatus cr_tknzr_peek_char (CRTknzr *a_this, guint32 *a_char) ;
73 
74 enum CRStatus cr_tknzr_peek_byte (CRTknzr *a_this, gulong a_offset,
75  guchar *a_byte) ;
76 
77 guchar cr_tknzr_peek_byte2 (CRTknzr *a_this, gulong a_offset,
78  gboolean *a_eof) ;
79 
80 enum CRStatus cr_tknzr_set_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ;
81 
82 glong cr_tknzr_get_nb_bytes_left (CRTknzr *a_this) ;
83 
84 enum CRStatus cr_tknzr_get_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ;
85 
87  CRParsingLocation *a_loc) ;
88 
90  enum CRSeekPos a_origin,
91  gint a_pos) ;
92 
93 enum CRStatus cr_tknzr_get_cur_byte_addr (CRTknzr *a_this, guchar **a_addr) ;
94 
95 
96 enum CRStatus cr_tknzr_consume_chars (CRTknzr *a_this, guint32 a_char,
97  glong *a_nb_char) ;
98 
99 enum CRStatus cr_tknzr_get_next_token (CRTknzr *a_this, CRToken ** a_tk) ;
100 
101 enum CRStatus cr_tknzr_unget_token (CRTknzr *a_this, CRToken *a_token) ;
102 
103 
104 enum CRStatus cr_tknzr_parse_token (CRTknzr *a_this, enum CRTokenType a_type,
105  enum CRTokenExtraType a_et, gpointer a_res,
106  gpointer a_extra_res) ;
107 enum CRStatus cr_tknzr_set_input (CRTknzr *a_this, CRInput *a_input) ;
108 
109 enum CRStatus cr_tknzr_get_input (CRTknzr *a_this, CRInput **a_input) ;
110 
111 void cr_tknzr_destroy (CRTknzr *a_this) ;
112 
113 G_END_DECLS
114 
115 #endif /*__CR_TKZNR_H__*/
_CRTknzr
The tokenizer is the class that knows about all the css token.
Definition: cr-tknzr.h:49
cr_tknzr_new_from_buf
CRTknzr * cr_tknzr_new_from_buf(guchar *a_buf, gulong a_len, enum CREncoding a_enc, gboolean a_free_at_destroy)
Definition: cr-tknzr.c:1627
cr_tknzr_unget_token
enum CRStatus cr_tknzr_unget_token(CRTknzr *a_this, CRToken *a_token)
Definition: cr-tknzr.c:1946
cr-input.h
cr_tknzr_set_input
enum CRStatus cr_tknzr_set_input(CRTknzr *a_this, CRInput *a_input)
Definition: cr-tknzr.c:1685
cr_tknzr_destroy
void cr_tknzr_destroy(CRTknzr *a_this)
Definition: cr-tknzr.c:2740
CRTknzr
typedefG_BEGIN_DECLS struct _CRTknzr CRTknzr
Definition: cr-tknzr.h:40
CRTokenExtraType
CRTokenExtraType
Definition: cr-token.h:78
cr_tknzr_consume_chars
enum CRStatus cr_tknzr_consume_chars(CRTknzr *a_this, guint32 a_char, glong *a_nb_char)
Definition: cr-tknzr.c:1911
cr_tknzr_parse_token
enum CRStatus cr_tknzr_parse_token(CRTknzr *a_this, enum CRTokenType a_type, enum CRTokenExtraType a_et, gpointer a_res, gpointer a_extra_res)
Definition: cr-tknzr.c:2629
cr_tknzr_get_parsing_location
enum CRStatus cr_tknzr_get_parsing_location(CRTknzr *a_this, CRParsingLocation *a_loc)
Definition: cr-tknzr.c:1867
cr_tknzr_read_char
enum CRStatus cr_tknzr_read_char(CRTknzr *a_this, guint32 *a_char)
Reads the next char from the parser input stream.
Definition: cr-tknzr.c:1740
_CRInputPos
Definition: cr-input.h:54
cr_tknzr_get_input
enum CRStatus cr_tknzr_get_input(CRTknzr *a_this, CRInput **a_input)
Definition: cr-tknzr.c:1701
cr_tknzr_peek_char
enum CRStatus cr_tknzr_peek_char(CRTknzr *a_this, guint32 *a_char)
Peeks a char from the parser input stream.
Definition: cr-tknzr.c:1765
_CRTknzrPriv
Definition: cr-tknzr.c:34
cr_tknzr_get_cur_byte_addr
enum CRStatus cr_tknzr_get_cur_byte_addr(CRTknzr *a_this, guchar **a_addr)
Definition: cr-tknzr.c:1880
_CRInput
The CRInput class provides the abstraction of an utf8-encoded character stream.
Definition: cr-input.h:47
cr_tknzr_ref
void cr_tknzr_ref(CRTknzr *a_this)
Definition: cr-tknzr.c:1660
cr_tknzr_get_nb_bytes_left
glong cr_tknzr_get_nb_bytes_left(CRTknzr *a_this)
Gets the number of bytes left in the topmost input stream associated to this parser.
Definition: cr-tknzr.c:1834
_CRParsingLocation
Definition: cr-parsing-location.h:39
cr_tknzr_set_cur_pos
enum CRStatus cr_tknzr_set_cur_pos(CRTknzr *a_this, CRInputPos *a_pos)
Definition: cr-tknzr.c:1932
cr_tknzr_peek_byte2
guchar cr_tknzr_peek_byte2(CRTknzr *a_this, gulong a_offset, gboolean *a_eof)
Same as cr_tknzr_peek_byte() but this api returns the byte peeked.
Definition: cr-tknzr.c:1819
CREncoding
CREncoding
Encoding values.
Definition: cr-utils.h:84
cr_tknzr_peek_byte
enum CRStatus cr_tknzr_peek_byte(CRTknzr *a_this, gulong a_offset, guchar *a_byte)
Peeks a byte ahead at a given postion in the parser input stream.
Definition: cr-tknzr.c:1791
CRStatus
CRStatus
The status type returned by the methods of the croco library.
Definition: cr-utils.h:43
CRTokenType
CRTokenType
Definition: cr-token.h:36
cr_tknzr_get_cur_pos
enum CRStatus cr_tknzr_get_cur_pos(CRTknzr *a_this, CRInputPos *a_pos)
Definition: cr-tknzr.c:1850
cr-utils.h
cr_tknzr_seek_index
enum CRStatus cr_tknzr_seek_index(CRTknzr *a_this, enum CRSeekPos a_origin, gint a_pos)
Definition: cr-tknzr.c:1895
_CRToken
This class abstracts a css2 token.
Definition: cr-token.h:101
cr_tknzr_read_byte
enum CRStatus cr_tknzr_read_byte(CRTknzr *a_this, guchar *a_byte)
Reads the next byte from the parser input stream.
Definition: cr-tknzr.c:1724
cr_tknzr_new
CRTknzr * cr_tknzr_new(CRInput *a_input)
Definition: cr-tknzr.c:1595
cr-token.h
cr_tknzr_new_from_uri
CRTknzr * cr_tknzr_new_from_uri(const guchar *a_file_uri, enum CREncoding a_enc)
Definition: cr-tknzr.c:1645
cr_tknzr_get_next_token
enum CRStatus cr_tknzr_get_next_token(CRTknzr *a_this, CRToken **a_tk)
Returns the next token of the input stream.
Definition: cr-tknzr.c:1969
cr_tknzr_unref
gboolean cr_tknzr_unref(CRTknzr *a_this)
Definition: cr-tknzr.c:1668
CRSeekPos
CRSeekPos
Values used by cr_input_seek_position() ;.
Definition: cr-utils.h:75
_CRTknzr::priv
CRTknzrPriv * priv
Definition: cr-tknzr.h:52