My Project
gstream.h
00001 #ifndef GSTREAM_INCLUDED
00002 #define GSTREAM_INCLUDED
00003 
00004 /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; version 2 of the License.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
00018 
00019 
00020 #include "my_global.h"                          /* NULL, NullS */
00021 #include "my_sys.h"                             /* MY_ALLOW_ZERO_PTR */
00022 #include "m_ctype.h"           /* my_charset_latin1, my_charset_bin */
00023 
00024 typedef struct charset_info_st CHARSET_INFO;
00025 typedef struct st_mysql_lex_string LEX_STRING;
00026 
00027 class Gis_read_stream
00028 {
00029 public:
00030   enum enum_tok_types
00031   {
00032     unknown,
00033     eostream,
00034     word,
00035     numeric,
00036     l_bra,
00037     r_bra,
00038     comma
00039   };
00040 
00041   Gis_read_stream(const CHARSET_INFO *charset, const char *buffer, int size)
00042     :m_cur(buffer), m_limit(buffer + size), m_err_msg(NULL), m_charset(charset)
00043   {}
00044   Gis_read_stream(): m_cur(NullS), m_limit(NullS), m_err_msg(NullS)
00045   {}
00046   ~Gis_read_stream()
00047   {
00048     my_free(m_err_msg);
00049   }
00050 
00051   enum enum_tok_types get_next_toc_type();
00052   bool get_next_word(LEX_STRING *);
00053   bool get_next_number(double *);
00054   bool check_next_symbol(char);
00055 
00056   inline void skip_space()
00057   {
00058     while ((m_cur < m_limit) && my_isspace(&my_charset_latin1, *m_cur))
00059       m_cur++;
00060   }
00061   /* Skip next character, if match. Return 1 if no match */
00062   inline bool skip_char(char skip)
00063   {
00064     skip_space();
00065     if ((m_cur >= m_limit) || *m_cur != skip)
00066       return 1;                                 /* Didn't find char */
00067     m_cur++;
00068     return 0;
00069   }
00070   void set_error_msg(const char *msg);
00071 
00072   // caller should free this pointer
00073   char *get_error_msg()
00074   {
00075     char *err_msg = m_err_msg;
00076     m_err_msg= NullS;
00077     return err_msg;
00078   }
00079 
00080 protected:
00081   const char *m_cur;
00082   const char *m_limit;
00083   char *m_err_msg;
00084   const CHARSET_INFO *m_charset;
00085 };
00086 
00087 #endif /* GSTREAM_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines