1
/* Copyright (C) 2004 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
Functions to read and parse geometrical data.
18
NOTE: These functions assumes that the string is end \0 terminated!
21
#include "mysql_priv.h"
23
enum Gis_read_stream::enum_tok_types Gis_read_stream::get_next_toc_type()
28
if (my_isvar_start(&my_charset_bin, *m_cur))
30
if ((*m_cur >= '0' && *m_cur <= '9') || *m_cur == '-' || *m_cur == '+')
42
bool Gis_read_stream::get_next_word(LEX_STRING *res)
45
res->str= (char*) m_cur;
46
/* The following will also test for \0 */
47
if ((m_cur >= m_limit) || !my_isvar_start(&my_charset_bin, *m_cur))
51
We can't combine the following increment with my_isvar() because
52
my_isvar() is a macro that would cause side effects
55
while ((m_cur < m_limit) && my_isvar(&my_charset_bin, *m_cur))
58
res->length= (uint32) (m_cur - res->str);
64
Read a floating point number
66
NOTE: Number must start with a digit or sign. It can't start with a decimal
70
bool Gis_read_stream::get_next_number(double *d)
77
if ((m_cur >= m_limit) ||
78
((*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+'))
80
set_error_msg("Numeric constant expected");
84
*d = my_strntod(m_charset, (char *)m_cur,
85
(uint) (m_limit-m_cur), &endptr, &err);
94
bool Gis_read_stream::check_next_symbol(char symbol)
97
if ((m_cur >= m_limit) || (*m_cur != symbol))
100
strmov(buff, "'?' expected");
111
Remember error message.
114
void Gis_read_stream::set_error_msg(const char *msg)
116
size_t len= strlen(msg); // ok in this context
117
m_err_msg= (char *) my_realloc(m_err_msg, (uint) len + 1, MYF(MY_ALLOW_ZERO_PTR));
118
memcpy(m_err_msg, msg, len + 1);