Orcus
css_parser_base.hpp
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_CSS_PARSER_BASE_HPP
9 #define INCLUDED_CSS_PARSER_BASE_HPP
10 
11 #include "orcus/env.hpp"
12 #include "orcus/css_types.hpp"
13 #include "orcus/exception.hpp"
14 #include "orcus/parser_base.hpp"
15 
16 #include <string>
17 #include <exception>
18 
19 namespace orcus { namespace css {
20 
21 class ORCUS_PSR_DLLPUBLIC parse_error : public ::orcus::parse_error
22 {
23 public:
24  parse_error(const std::string& msg);
25 
26  static void throw_with(const char* msg_before, char c, const char* msg_after);
27  static void throw_with(const char* msg_before, const char* p, size_t n, const char* msg_after);
28 };
29 
30 class ORCUS_PSR_DLLPUBLIC parser_base : public ::orcus::parser_base
31 {
32 public:
33  parser_base(const char* p, size_t n);
34 
35 protected:
36 
37  void identifier(const char*& p, size_t& len, const char* extra = NULL);
38  uint8_t parse_uint8();
39  double parse_percent();
40  double parse_double_or_throw();
41 
42  void literal(const char*& p, size_t& len, char quote);
43  void skip_to(const char*& p, size_t& len, char c);
44 
52  void skip_to_or_blank(const char*& p, size_t& len, const char* chars);
53  void skip_blanks();
54  void skip_blanks_reverse();
55  void shrink_stream();
56  bool skip_comment();
57  void comment();
58  void skip_comments_and_blanks();
59  void set_combinator(char c, css::combinator_t combinator);
60  void reset_before_block();
61 
62 protected:
63  size_t m_simple_selector_count;
64  combinator_t m_combinator;
65 };
66 
67 
68 }}
69 
70 #endif
71 
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: css_parser_base.hpp:30
Definition: css_parser_base.hpp:21
Definition: parser_base.hpp:34
Definition: parser_base.hpp:20
Definition: base64.hpp:15