Drizzled Public API Documentation

context.h
00001 /*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00002  * 
00003  *  Drizzle Execute Parser
00004  *
00005  *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions are
00010  *  met:
00011  *
00012  *      * Redistributions of source code must retain the above copyright
00013  *  notice, this list of conditions and the following disclaimer.
00014  *
00015  *      * Redistributions in binary form must reproduce the above
00016  *  copyright notice, this list of conditions and the following disclaimer
00017  *  in the documentation and/or other materials provided with the
00018  *  distribution.
00019  *
00020  *      * The names of its contributors may not be used to endorse or
00021  *  promote products derived from this software without specific prior
00022  *  written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00027  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00028  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00029  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00030  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00031  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00032  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00033  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  */
00037 
00038 #pragma once
00039 
00040 #include <config.h>
00041 #include <cstdlib>
00042 #include <vector>
00043 #include <string>
00044 #include <drizzled/error_t.h>
00045 
00046 
00047 namespace drizzled {
00048 namespace execute {
00049 
00050 class Context
00051 {
00052 public:
00053   Context(const char *option_string, size_t option_string_length, drizzled::error_t &rc_arg) :
00054     scanner(NULL),
00055     begin(NULL),
00056     pos(0),
00057     rc(rc_arg),
00058     _is_server(false),
00059     _end(false)
00060   {
00061     buf= option_string;
00062     length= option_string_length;
00063     init_scanner();
00064     rc= EE_OK;
00065   }
00066 
00067   bool end() const
00068   {
00069     return _end;
00070   }
00071 
00072   std::vector<std::string> start();
00073 
00074   void set_end()
00075   {
00076     rc= EE_OK;
00077     _end= true;
00078   }
00079 
00080   ~Context()
00081   {
00082     destroy_scanner();
00083   }
00084 
00085   void *scanner;
00086   const char *buf;
00087   const char *begin;
00088   size_t pos;
00089   size_t length;
00090   drizzled::error_t &rc;
00091   bool _is_server;
00092 
00093 protected:
00094   void init_scanner();   
00095   void destroy_scanner();
00096 
00097 private:
00098   bool _end;
00099 }; 
00100 
00101 } // namespace execute
00102 } // namespace drizzled