Drizzled Public API Documentation

temporal_format.h
Go to the documentation of this file.
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  Authors:
00007  *
00008  *  Jay Pipes <jay.pipes@sun.com>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023  */
00024 
00031 #pragma once
00032 
00033 #include <drizzled/common_fwd.h>
00034 
00035 #include PCRE_HEADER
00036 
00037 /* Output vector size for pcre matching.  Should be multiple of 3. */
00038 #define OUT_VECTOR_SIZE 30
00039 
00040 namespace drizzled {
00041 
00042 class TemporalFormat
00043 {
00044 protected:
00045   const char *_pattern; 
00046   pcre *_re; 
00047   int32_t _error_offset; 
00048   const char *_error;
00049   /* Index of the pattern which is a specific temporal part */
00050   uint32_t _year_part_index;
00051   uint32_t _month_part_index;
00052   uint32_t _day_part_index;
00053   uint32_t _hour_part_index;
00054   uint32_t _minute_part_index;
00055   uint32_t _second_part_index;
00056   uint32_t _usecond_part_index;
00057   uint32_t _nsecond_part_index;
00058 public:
00065   TemporalFormat(const char *pattern);
00066 
00067   ~TemporalFormat();
00068 
00073   inline bool is_valid() const {return _re && (_error == NULL);}
00079   inline void set_year_part_index(int32_t index) {_year_part_index= ((index - 1) * 2) + 2;}
00085   inline void set_month_part_index(int32_t index) {_month_part_index= ((index - 1) * 2) + 2;}
00091   inline void set_day_part_index(int32_t index) {_day_part_index= ((index - 1) * 2) + 2;}
00097   inline void set_hour_part_index(int32_t index) {_hour_part_index= ((index - 1) * 2) + 2;}
00103   inline void set_minute_part_index(int32_t index) {_minute_part_index= ((index - 1) * 2) + 2;}
00109   inline void set_second_part_index(int32_t index) {_second_part_index= ((index - 1) * 2) + 2;}
00115   inline void set_usecond_part_index(int32_t index) {_usecond_part_index= ((index - 1) * 2) + 2;}
00121   inline void set_nsecond_part_index(int32_t index) {_nsecond_part_index= ((index - 1) * 2) + 2;}
00130   bool matches(const char *data, size_t data_len, Temporal *to);
00131 };
00132 
00133 
00145 bool init_temporal_formats();
00149 void deinit_temporal_formats();
00150 
00151 } /* end namespace drizzled */
00152