drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
ascii.cc
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
*
4
* Copyright (C) 2008 Sun Microsystems, Inc.
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
#include <config.h>
21
22
#include <drizzled/plugin.h>
23
#include <drizzled/function/math/int.h>
24
#include <drizzled/plugin/function.h>
25
26
using namespace
std
;
27
using namespace
drizzled
;
28
29
class
AsciiFunction :
public
Item_int_func
30
{
31
String
value;
32
public
:
33
int64_t
val_int
();
34
AsciiFunction() :Item_int_func() {}
35
36
const
char
*func_name()
const
37
{
38
return
"ascii"
;
39
}
40
41
void
fix_length_and_dec()
42
{
43
max_length= 3;
44
}
45
46
bool
check_argument_count
(
int
n)
47
{
48
return
(n == 1);
49
}
50
};
51
52
53
int64_t
AsciiFunction::val_int
()
54
{
55
assert(
fixed
==
true
);
56
String
*res= args[0]->val_str(&value);
57
58
if
(res == NULL)
59
{
60
null_value
=
true
;
61
return
0;
62
}
63
64
null_value
=
false
;
65
return
(int64_t) ( res->length() != 0 ?
66
(
unsigned
char
) (*res)[0] :
67
(
unsigned
char
) 0
68
);
69
}
70
71
plugin::Create_function<AsciiFunction>
*asciiudf= NULL;
72
73
static
int
initialize(
module::Context
&context)
74
{
75
asciiudf=
new
plugin::Create_function<AsciiFunction>
(
"ascii"
);
76
context.add(asciiudf);
77
return
0;
78
}
79
80
DRIZZLE_DECLARE_PLUGIN
81
{
82
DRIZZLE_VERSION_ID,
83
"ascii"
,
84
"1.0"
,
85
"Devananda van der Veen"
,
86
N_(
"ASCII function"
),
87
PLUGIN_LICENSE_GPL,
88
initialize,
89
NULL,
90
NULL
91
}
92
DRIZZLE_DECLARE_PLUGIN_END;
AsciiFunction::val_int
int64_t val_int()
Definition
ascii.cc:53
AsciiFunction::check_argument_count
bool check_argument_count(int n)
Definition
ascii.cc:46
drizzled::Item::fixed
bool fixed
Definition
item.h:122
drizzled::Item::null_value
bool null_value
Definition
item.h:124
drizzled::String
Definition
sql_string.h:58
drizzled::module::Context
Definition
module/context.h:45
drizzled::plugin::Create_function
Definition
drizzled/plugin/function.h:68
drizzled
TODO: Rename this file - func.h is stupid.
Definition
abort_exception.h:27
std
STL namespace.
← Back to Drizzle docs
plugin
ascii
ascii.cc
Generated by
1.15.0