Orcus
parser_global.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 ORCUS_PARSER_GLOBAL_HPP
9 #define ORCUS_PARSER_GLOBAL_HPP
10 
11 #include "env.hpp"
12 
13 #include <sstream>
14 
15 namespace orcus {
16 
17 class cell_buffer;
18 
19 enum class string_escape_char_t
20 {
21  invalid,
22  valid,
23  control_char
24 };
25 
33 {
34  static constexpr size_t error_no_closing_quote = 1;
35  static constexpr size_t error_illegal_escape_char = 2;
36 
37  const char* str;
38  size_t length;
39 
50  bool transient;
51 };
52 
53 ORCUS_PSR_DLLPUBLIC bool is_blank(char c);
54 ORCUS_PSR_DLLPUBLIC bool is_alpha(char c);
55 ORCUS_PSR_DLLPUBLIC bool is_name_char(char c);
56 ORCUS_PSR_DLLPUBLIC bool is_numeric(char c);
57 
68 ORCUS_PSR_DLLPUBLIC bool is_in(char c, const char* allowed);
69 
70 ORCUS_PSR_DLLPUBLIC void write_to(std::ostringstream& os, const char* p, size_t n);
71 
72 ORCUS_PSR_DLLPUBLIC double parse_numeric(const char*& p, size_t max_length);
73 
74 ORCUS_PSR_DLLPUBLIC long parse_integer(const char*& p, size_t max_length);
75 
79 ORCUS_PSR_DLLPUBLIC parse_quoted_string_state parse_single_quoted_string(
80  const char*& p, size_t max_length, cell_buffer& buffer);
81 
93 ORCUS_PSR_DLLPUBLIC const char* parse_to_closing_single_quote(
94  const char* p, size_t max_length);
95 
96 ORCUS_PSR_DLLPUBLIC parse_quoted_string_state parse_double_quoted_string(
97  const char*& p, size_t max_length, cell_buffer& buffer);
98 
110 ORCUS_PSR_DLLPUBLIC const char* parse_to_closing_double_quote(
111  const char* p, size_t max_length);
112 
122 ORCUS_PSR_DLLPUBLIC string_escape_char_t get_string_escape_char_type(char c);
123 
133 ORCUS_PSR_DLLPUBLIC double clip(double input, double low, double high);
134 
135 }
136 
137 #endif
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: cell_buffer.hpp:21
Definition: parser_global.hpp:32
Definition: base64.hpp:15