cr-tknzr.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 coypyright information.
  21. */
  22. /**
  23. *@file
  24. *The declaration of the #CRTknzr (tokenizer)
  25. *class.
  26. */
  27. #ifndef __CR_TKNZR_H__
  28. #define __CR_TKNZR_H__
  29. #include "cr-utils.h"
  30. #include "cr-input.h"
  31. #include "cr-token.h"
  32. G_BEGIN_DECLS
  33. typedef struct _CRTknzr CRTknzr ;
  34. typedef struct _CRTknzrPriv CRTknzrPriv ;
  35. /**
  36. *The tokenizer is the class that knows
  37. *about all the css token. Its main job is
  38. *to return the next token found in the character
  39. *input stream.
  40. */
  41. struct _CRTknzr
  42. {
  43. /*the private data of the tokenizer.*/
  44. CRTknzrPriv *priv ;
  45. } ;
  46. CRTknzr * cr_tknzr_new (CRInput *a_input) ;
  47. CRTknzr * cr_tknzr_new_from_uri (const guchar *a_file_uri,
  48. enum CREncoding a_enc) ;
  49. CRTknzr * cr_tknzr_new_from_buf (guchar *a_buf, gulong a_len,
  50. enum CREncoding a_enc,
  51. gboolean a_free_at_destroy) ;
  52. gboolean cr_tknzr_unref (CRTknzr *a_this) ;
  53. void cr_tknzr_ref (CRTknzr *a_this) ;
  54. enum CRStatus cr_tknzr_read_byte (CRTknzr *a_this, guchar *a_byte) ;
  55. enum CRStatus cr_tknzr_read_char (CRTknzr *a_this, guint32 *a_char);
  56. enum CRStatus cr_tknzr_peek_char (CRTknzr *a_this, guint32 *a_char) ;
  57. enum CRStatus cr_tknzr_peek_byte (CRTknzr *a_this, gulong a_offset,
  58. guchar *a_byte) ;
  59. guchar cr_tknzr_peek_byte2 (CRTknzr *a_this, gulong a_offset,
  60. gboolean *a_eof) ;
  61. enum CRStatus cr_tknzr_set_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ;
  62. glong cr_tknzr_get_nb_bytes_left (CRTknzr *a_this) ;
  63. enum CRStatus cr_tknzr_get_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ;
  64. enum CRStatus cr_tknzr_get_parsing_location (CRTknzr *a_this,
  65. CRParsingLocation *a_loc) ;
  66. enum CRStatus cr_tknzr_seek_index (CRTknzr *a_this,
  67. enum CRSeekPos a_origin,
  68. gint a_pos) ;
  69. enum CRStatus cr_tknzr_get_cur_byte_addr (CRTknzr *a_this, guchar **a_addr) ;
  70. enum CRStatus cr_tknzr_consume_chars (CRTknzr *a_this, guint32 a_char,
  71. glong *a_nb_char) ;
  72. enum CRStatus cr_tknzr_get_next_token (CRTknzr *a_this, CRToken ** a_tk) ;
  73. enum CRStatus cr_tknzr_unget_token (CRTknzr *a_this, CRToken *a_token) ;
  74. enum CRStatus cr_tknzr_parse_token (CRTknzr *a_this, enum CRTokenType a_type,
  75. enum CRTokenExtraType a_et, gpointer a_res,
  76. gpointer a_extra_res) ;
  77. enum CRStatus cr_tknzr_set_input (CRTknzr *a_this, CRInput *a_input) ;
  78. enum CRStatus cr_tknzr_get_input (CRTknzr *a_this, CRInput **a_input) ;
  79. void cr_tknzr_destroy (CRTknzr *a_this) ;
  80. G_END_DECLS
  81. #endif /*__CR_TKZNR_H__*/