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  static void throw_with(const char* msg_before, std::string_view s, const char* msg_after);
29 };
30 
31 class ORCUS_PSR_DLLPUBLIC parser_base : public ::orcus::parser_base
32 {
33 public:
34  parser_base(const char* p, size_t n);
35 
36 protected:
37 
38  void identifier(const char*& p, size_t& len, std::string_view extra = std::string_view{});
39  uint8_t parse_uint8();
40 
47  std::string_view parse_value();
48  double parse_percent();
49  double parse_double_or_throw();
50 
51  void literal(const char*& p, size_t& len, char quote);
52  void skip_to(const char*& p, size_t& len, char c);
53 
62  void skip_to_or_blank(const char*& p, size_t& len, const char* chars, size_t n_chars);
63  void skip_blanks();
64  void skip_blanks_reverse();
65  void shrink_stream();
66  bool skip_comment();
67  void comment();
68  void skip_comments_and_blanks();
69  void set_combinator(char c, css::combinator_t combinator);
70  void reset_before_block();
71 
72 protected:
73  size_t m_simple_selector_count;
74  combinator_t m_combinator;
75 };
76 
77 
78 }}
79 
80 #endif
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: css_parser_base.hpp:22
Definition: css_parser_base.hpp:32
void skip_to_or_blank(const char *&p, size_t &len, const char *chars, size_t n_chars)
std::string_view parse_value()
Definition: parser_base.hpp:27
Definition: parser_base.hpp:41