Orcus
csv_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 CSV_PARSER_BASE_HPP
9 #define CSV_PARSER_BASE_HPP
10 
11 #include "env.hpp"
12 #include "cell_buffer.hpp"
13 #include "parser_global.hpp"
14 #include "parser_base.hpp"
15 
16 #include <cstdlib>
17 #include <cstring>
18 #include <exception>
19 #include <string>
20 #include <cassert>
21 #include <sstream>
22 
23 #define ORCUS_DEBUG_CSV 0
24 
25 #if ORCUS_DEBUG_CSV
26 #include <iostream>
27 using std::cout;
28 using std::endl;
29 #endif
30 
31 namespace orcus { namespace csv {
32 
33 struct ORCUS_PSR_DLLPUBLIC parser_config
34 {
35  std::string delimiters;
36  char text_qualifier;
37  bool trim_cell_value:1;
38 
39  parser_config();
40 };
41 
42 class ORCUS_PSR_DLLPUBLIC parse_error : public std::exception
43 {
44  std::string m_msg;
45 public:
46  parse_error(const std::string& msg);
47  virtual ~parse_error() throw();
48  virtual const char* what() const throw();
49 };
50 
51 class ORCUS_PSR_DLLPUBLIC parser_base : public ::orcus::parser_base
52 {
53 protected:
54  const csv::parser_config& m_config;
55  cell_buffer m_cell_buf;
56 
57 protected:
58  parser_base(const char* p, size_t n, const parser_config& config);
59 
64  bool is_blank(char c) const;
65  bool is_delim(char c) const;
66  bool is_text_qualifier(char c) const;
67 
68  void skip_blanks();
69 };
70 
71 }}
72 
73 #endif
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: cell_buffer.hpp:21
Definition: csv_parser_base.hpp:51
Definition: csv_parser_base.hpp:42
Definition: config.hpp:17
Definition: parser_base.hpp:34
Definition: base64.hpp:15
Definition: csv_parser_base.hpp:33