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>
27using std::cout;
28using std::endl;
29#endif
30
31namespace orcus { namespace csv {
32
36struct ORCUS_PSR_DLLPUBLIC parser_config
37{
41 std::string delimiters;
42
47
53
55};
56
57class ORCUS_PSR_DLLPUBLIC parse_error : public std::exception
58{
59 std::string m_msg;
60public:
61 parse_error(const std::string& msg);
62 virtual ~parse_error() throw();
63 virtual const char* what() const throw();
64};
65
66class ORCUS_PSR_DLLPUBLIC parser_base : public ::orcus::parser_base
67{
68protected:
69 const csv::parser_config& m_config;
70 cell_buffer m_cell_buf;
71
72protected:
73 parser_base(const char* p, size_t n, const parser_config& config);
74
79 bool is_blank(char c) const;
80 bool is_delim(char c) const;
81 bool is_text_qualifier(char c) const;
82
83 void skip_blanks();
84
85private:
86 void maybe_skip_bom();
87};
88
89}}
90
91#endif
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: cell_buffer.hpp:22
Definition: csv_parser_base.hpp:58
Definition: csv_parser_base.hpp:67
bool is_blank(char c) const
Definition: parser_base.hpp:41
Definition: config.hpp:20
Definition: csv_parser_base.hpp:37
std::string delimiters
Definition: csv_parser_base.hpp:41
char text_qualifier
Definition: csv_parser_base.hpp:46
bool trim_cell_value
Definition: csv_parser_base.hpp:52