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 PCRE_HEADER
00034 
00035 /* Output vector size for pcre matching.  Should be multiple of 3. */
00036 #define OUT_VECTOR_SIZE 30
00037 
00038 namespace drizzled
00039 {
00040 
00041 /* Forward declaration needed */
00042 class Temporal;
00043 
00044 class TemporalFormat
00045 {
00046 protected:
00047   const char *_pattern; 
00048   pcre *_re; 
00049   int32_t _error_offset; 
00050   const char *_error;
00051   /* Index of the pattern which is a specific temporal part */
00052   uint32_t _year_part_index;
00053   uint32_t _month_part_index;
00054   uint32_t _day_part_index;
00055   uint32_t _hour_part_index;
00056   uint32_t _minute_part_index;
00057   uint32_t _second_part_index;
00058   uint32_t _usecond_part_index;
00059   uint32_t _nsecond_part_index;
00060 public:
00067   TemporalFormat(const char *pattern);
00072   inline bool is_valid() const {return _re && (_error == NULL);}
00078   inline void set_year_part_index(int32_t index) {_year_part_index= ((index - 1) * 2) + 2;}
00084   inline void set_month_part_index(int32_t index) {_month_part_index= ((index - 1) * 2) + 2;}
00090   inline void set_day_part_index(int32_t index) {_day_part_index= ((index - 1) * 2) + 2;}
00096   inline void set_hour_part_index(int32_t index) {_hour_part_index= ((index - 1) * 2) + 2;}
00102   inline void set_minute_part_index(int32_t index) {_minute_part_index= ((index - 1) * 2) + 2;}
00108   inline void set_second_part_index(int32_t index) {_second_part_index= ((index - 1) * 2) + 2;}
00114   inline void set_usecond_part_index(int32_t index) {_usecond_part_index= ((index - 1) * 2) + 2;}
00120   inline void set_nsecond_part_index(int32_t index) {_nsecond_part_index= ((index - 1) * 2) + 2;}
00129   bool matches(const char *data, size_t data_len, Temporal *to);
00130 };
00131 
00132 
00144 bool init_temporal_formats();
00148 void deinit_temporal_formats();
00149 
00150 } /* end namespace drizzled */
00151