~drizzle-trunk/drizzle/development

850 by Brian Aker
More class creation.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
850 by Brian Aker
More class creation.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
21
#ifndef DRIZZLED_SELECT_EXPORT_H
22
#define DRIZZLED_SELECT_EXPORT_H
23
2154.2.17 by Brian Aker
Additional removal of session
24
#include <drizzled/select_to_file.h>
25
850 by Brian Aker
More class creation.
26
/*
27
 List of all possible characters of a numeric value text representation.
28
*/
29
#define NUMERIC_CHARS ".0123456789e+-"
30
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
31
namespace drizzled
32
{
850 by Brian Aker
More class creation.
33
1813.2.9 by Monty Taylor
Made data_home be fs::path natively.
34
class select_export :
35
  public select_to_file
36
{
850 by Brian Aker
More class creation.
37
  uint32_t field_term_length;
38
  int field_sep_char,escape_char,line_sep_char;
39
  int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT
40
  /*
41
    The is_ambiguous_field_sep field is true if a value of the field_sep_char
42
    field is one of the 'n', 't', 'r' etc characters
43
    (see the READ_INFO::unescape method and the ESCAPE_CHARS constant value).
44
  */
45
  bool is_ambiguous_field_sep;
46
  /*
47
     The is_ambiguous_field_term is true if field_sep_char contains the first
48
     char of the FIELDS TERMINATED BY (ENCLOSED BY is empty), and items can
49
     contain this character.
50
  */
51
  bool is_ambiguous_field_term;
52
  /*
53
    The is_unsafe_field_sep field is true if a value of the field_sep_char
54
    field is one of the '0'..'9', '+', '-', '.' and 'e' characters
55
    (see the NUMERIC_CHARS constant value).
56
  */
57
  bool is_unsafe_field_sep;
58
  bool fixed_row_size;
59
public:
1889.1.5 by Brian Aker
Additional C++ warning fixes.
60
  select_export(file_exchange *ex) :
61
    select_to_file(ex),
62
    field_term_length(0),
63
    field_sep_char(0),
64
    escape_char(0),
65
    line_sep_char(0),
66
    field_term_char(0),
67
    is_ambiguous_field_sep(0),
68
    is_ambiguous_field_term(0),
69
    is_unsafe_field_sep(0),
70
    fixed_row_size(0)
71
  {}
850 by Brian Aker
More class creation.
72
  ~select_export();
73
  int prepare(List<Item> &list, Select_Lex_Unit *u);
74
  bool send_data(List<Item> &items);
1377.6.3 by pawel
changed function-like defines into functions in some files
75
private:
76
  inline bool needs_escaping(char character, bool enclosed)
77
  {
78
    if ((character == escape_char) ||
79
        (enclosed ? character == field_sep_char : character == field_term_char) ||
80
        character == line_sep_char  ||
81
        (character == 0))
82
      return true;
83
84
    return false;
85
86
  }
850 by Brian Aker
More class creation.
87
};
88
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
89
} /* namespace drizzled */
90
850 by Brian Aker
More class creation.
91
#endif /* DRIZZLED_SELECT_EXPORT_H */