My Project
parse_file.h
00001 /* -*- C++ -*- */
00002 /* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; version 2 of the License.
00007 
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; if not, write to the Free Software Foundation,
00015    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
00016 
00017 #ifndef _PARSE_FILE_H_
00018 #define _PARSE_FILE_H_
00019 
00020 #include "my_global.h"                          // uchar
00021 #include "sql_string.h"                         // LEX_STRING
00022 #include "sql_alloc.h"
00023 
00024 class THD;
00025 
00026 typedef struct st_mem_root MEM_ROOT;
00027 
00028 #define PARSE_FILE_TIMESTAMPLENGTH 19
00029 
00030 enum file_opt_type {
00031   FILE_OPTIONS_STRING,          
00032   FILE_OPTIONS_ESTRING,         
00033   FILE_OPTIONS_ULONGLONG,       
00034   FILE_OPTIONS_TIMESTAMP,       
00036   FILE_OPTIONS_STRLIST,         
00038   FILE_OPTIONS_ULLLIST          
00040 };
00041 
00042 struct File_option
00043 {
00044   LEX_STRING name;              
00045   size_t offset;                
00046   file_opt_type type;           
00047 };
00048 
00049 
00055 class Unknown_key_hook
00056 {
00057 public:
00058   Unknown_key_hook() {}                       /* Remove gcc warning */
00059   virtual ~Unknown_key_hook() {}              /* Remove gcc warning */
00060   virtual bool process_unknown_string(const char *&unknown_key, uchar* base,
00061                                       MEM_ROOT *mem_root, const char *end)= 0;
00062 };
00063 
00064 
00067 class File_parser_dummy_hook: public Unknown_key_hook
00068 {
00069 public:
00070   File_parser_dummy_hook() {}                 /* Remove gcc warning */
00071   virtual bool process_unknown_string(const char *&unknown_key, uchar* base,
00072                                       MEM_ROOT *mem_root, const char *end);
00073 };
00074 
00075 extern File_parser_dummy_hook file_parser_dummy_hook;
00076 
00077 bool get_file_options_ulllist(const char *&ptr, const char *end,
00078                               const char *line, uchar* base,
00079                               File_option *parameter,
00080                               MEM_ROOT *mem_root);
00081 
00082 const char *
00083 parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
00084                      LEX_STRING *str);
00085 
00086 class File_parser;
00087 File_parser *sql_parse_prepare(const LEX_STRING *file_name,
00088                                MEM_ROOT *mem_root, bool bad_format_errors);
00089 
00090 my_bool
00091 sql_create_definition_file(const LEX_STRING *dir, const  LEX_STRING *file_name,
00092                            const LEX_STRING *type,
00093                            uchar* base, File_option *parameters);
00094 my_bool rename_in_schema_file(THD *thd,
00095                               const char *schema, const char *old_name,
00096                               const char *new_db, const char *new_name);
00097 
00098 class File_parser: public Sql_alloc
00099 {
00100   const char *start, *end;
00101   LEX_STRING file_type;
00102   my_bool content_ok;
00103 public:
00104   File_parser() :start(0), end(0), content_ok(0)
00105     { file_type.str= 0; file_type.length= 0; }
00106 
00107   my_bool ok() { return content_ok; }
00108   const LEX_STRING *type() const { return &file_type; }
00109   my_bool parse(uchar* base, MEM_ROOT *mem_root,
00110                 struct File_option *parameters, uint required,
00111                 Unknown_key_hook *hook) const;
00112 
00113   friend File_parser *sql_parse_prepare(const LEX_STRING *file_name,
00114                                         MEM_ROOT *mem_root,
00115                                         bool bad_format_errors);
00116 };
00117 #endif /* _PARSE_FILE_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines