MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
decimal_utils.hpp
1 /*
2  Copyright 2010 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 /*
19  * decimal_utils.hpp
20  */
21 
22 #ifndef decimal_utils_h
23 #define decimal_utils_h
24 
25 /* return values (redeclared here if to be mapped to Java) */
26 #define E_DEC_OK 0
27 #define E_DEC_TRUNCATED 1
28 #define E_DEC_OVERFLOW 2
29 #define E_DEC_BAD_NUM 8
30 #define E_DEC_OOM 16
31 /* return values below here are unique to ndbjtie --
32  not present in MySQL's decimal library */
33 #define E_DEC_BAD_PREC 32
34 #define E_DEC_BAD_SCALE 64
35 
36 /*
37  decimal_str2bin: Convert string directly to on-disk binary format.
38  str - string to convert
39  len - length of string
40  prec - precision of column
41  scale - scale of column
42  dest - buffer for binary representation
43  len - length of buffer
44 
45  NOTES
46  Added so that NDB API programs can convert directly between the stored
47  binary format and a string representation without using decimal_t.
48 
49  RETURN VALUE
50  E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW/E_DEC_OOM
51 */
52 int decimal_str2bin(const char *str, int str_len,
53  int prec, int scale,
54  void *bin, int bin_len);
55 
56 /*
57  decimal_bin2str(): Convert directly from on-disk binary format to string
58  bin - value to convert
59  bin_len - length to convert
60  prec - precision of column
61  scale - scale of column
62  dest - buffer for string representation
63  len - length of buffer
64 
65  NOTES
66  Added so that NDB API programs can convert directly between the stored
67  binary format and a string representation without using decimal_t.
68 
69 
70  RETURN VALUE
71  E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW/E_DEC_BAD_NUM/E_DEC_OOM
72  */
73 int decimal_bin2str(const void *bin, int bin_len,
74  int prec, int scale,
75  char *str, int str_len);
76 
77 #endif // decimal_utils_h