~drizzle-trunk/drizzle/development

584.4.2 by Monty Taylor
Split out hybrid_type_traits.
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.
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
21
2032 by Brian Aker
MErge in the include changes.
22
#include <drizzled/type/decimal.h>
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
23
2252.1.14 by Olaf van der Spek
Common fwd
24
namespace drizzled {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
25
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
26
/*************************************************************************/
27
/*
28
  A framework to easily handle different return types for hybrid items
29
  (hybrid item is an item whose operand can be of any type, e.g. integer,
30
  real, decimal).
31
*/
32
33
class Hybrid_type
34
{
35
public:
36
  int64_t integer;
37
38
  double real;
39
  /*
40
    Use two decimal buffers interchangeably to speed up += operation
41
    which has no native support in decimal library.
42
    Hybrid_type+= arg is implemented as dec_buf[1]= dec_buf[0] + arg.
43
    The third decimal is used as a handy temporary storage.
44
  */
2030.1.4 by Brian Aker
Change my_decimal to Decimal
45
  type::Decimal dec_buf[3];
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
46
  int used_dec_buf_no;
47
48
  /*
49
    Traits moved to a separate class to
50
      a) be able to easily change object traits in runtime
51
      b) they work as a differentiator for the union above
52
  */
53
  const Hybrid_type_traits *traits;
54
55
  Hybrid_type() {}
56
  /* XXX: add traits->copy() when needed */
57
  Hybrid_type(const Hybrid_type &rhs) :traits(rhs.traits) {}
58
};
59
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
60
} /* namespace drizzled */
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
61