~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to drizzled/type/boolean.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.2.11) (2.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20120619104649-9ij634mxm4x8pp4l
Tags: 1:7.1.36-stable-1ubuntu1
* Merge from Debian unstable. (LP: #987575)
  Remaining changes:
  - Added upstart script.
* debian/drizzle.upstart: dropped logger since upstart logs job
  output now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <drizzled/sql_string.h>
24
24
#include <drizzled/type/boolean.h>
25
 
#include <drizzled/global_charset_info.h>
26
 
#include <drizzled/charset_info.h>
27
 
 
28
 
namespace drizzled
29
 
{
30
 
 
31
 
namespace type
32
 
{
33
 
 
34
 
bool convert(String &destination, const bool source, bool ansi_display)
35
 
{
36
 
  uint32_t mlength= (5) * system_charset_info->mbmaxlen;
37
 
 
38
 
  destination.alloc(mlength);
39
 
  char *buffer=(char*) destination.c_ptr();
40
 
 
 
25
#include <drizzled/charset.h>
 
26
 
 
27
namespace drizzled {
 
28
namespace type {
 
29
 
 
30
const char* convert(bool source, bool ansi_display)
 
31
{
41
32
  if (source)
42
 
  {
43
 
    if (ansi_display)
44
 
    {
45
 
      memcpy(buffer, "YES", 3);
46
 
      destination.length(3);
47
 
    }
48
 
    else
49
 
    {
50
 
      memcpy(buffer, "TRUE", 4);
51
 
      destination.length(4);
52
 
    }
53
 
  }
54
 
  else
55
 
  {
56
 
    if (ansi_display)
57
 
    {
58
 
      memcpy(buffer, "NO", 2);
59
 
      destination.length(2);
60
 
    }
61
 
    else
62
 
    {
63
 
      memcpy(buffer, "FALSE", 5);
64
 
      destination.length(5);
65
 
    }
66
 
  }
 
33
    return ansi_display ? "YES" : "TRUE";
 
34
  return ansi_display ? "NO" : "FALSE";
 
35
}
67
36
 
68
 
  return true;
 
37
void convert(String& destination, bool source, bool ansi_display)
 
38
{
 
39
  const char* v= convert(source, ansi_display);
 
40
  destination.alloc(strlen(v));
 
41
  strcpy(destination.c_ptr(), v);
 
42
  destination.length(strlen(v));
69
43
}
70
44
 
71
45
bool convert(bool &destination, const char *source, const size_t source_length)
90
64
    break;
91
65
 
92
66
  case 5:
93
 
    if (not (my_strcasecmp(system_charset_info, source, "FALSE")))
 
67
    if (not (system_charset_info->strcasecmp(source, "FALSE")))
94
68
    {
95
69
      destination= false;
96
70
      return true;
98
72
    break;
99
73
 
100
74
  case 4:
101
 
    if (not (my_strcasecmp(system_charset_info, source, "TRUE")))
 
75
    if (not (system_charset_info->strcasecmp(source, "TRUE")))
102
76
    {
103
77
      destination= true;
104
78
      return true;
106
80
    break;
107
81
 
108
82
  case 3:
109
 
    if (not (my_strcasecmp(system_charset_info, source, "YES")))
 
83
    if (not (system_charset_info->strcasecmp(source, "YES")))
110
84
    {
111
85
      destination= true;
112
86
      return true;
114
88
    break;
115
89
 
116
90
  case 2:
117
 
    if (not (my_strcasecmp(system_charset_info, source, "NO")))
 
91
    if (not (system_charset_info->strcasecmp(source, "NO")))
118
92
    {
119
93
      destination= false;
120
94
      return true;