Drizzled Public API Documentation

temporal_interval.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2009 Sun Microsystems, Inc.
5  *
6  * Authors:
7  *
8  * Clint Byrum <clint@fewbar.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; version 2 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #pragma once
25 
26 /* @TODO Replace this include with some forward decls */
27 #include <drizzled/item.h>
28 #include <drizzled/type/time.h>
29 
30 namespace drizzled {
31 
37 {
38 public:
39 
40  TemporalInterval(uint32_t in_year,
41  uint32_t in_month,
42  uint32_t in_day,
43  uint32_t in_hour,
44  uint64_t in_minute,
45  uint64_t in_second,
46  uint64_t in_second_part,
47  bool in_neg) :
48  year(in_year),
49  month(in_month),
50  day(in_day),
51  hour(in_hour),
52  minute(in_minute),
53  second(in_second),
54  second_part(in_second_part),
55  neg(in_neg)
56  {}
57 
59  year(0),
60  month(0),
61  day(0),
62  hour(0),
63  minute(0),
64  second(0),
65  second_part(0),
66  neg(false)
67  {}
68 
73  inline void setNegative(bool in_neg= true)
74  {
75  neg= in_neg;
76  }
77 
81  inline void toggleNegative()
82  {
83  neg= !neg;
84  }
85 
90  inline bool getNegative() const
91  {
92  return neg;
93  }
94 
95  inline uint32_t get_year() const { return year; }
96  inline void set_year(uint32_t new_year) { year = new_year; }
97 
98  inline uint32_t get_month() const { return month; }
99  inline void set_month(uint32_t new_month) { month = new_month; }
100 
101  inline uint32_t get_day() const { return day; }
102  inline void set_day(uint32_t new_day) { day = new_day; }
103 
104  inline uint32_t get_hour() const { return hour; }
105  inline void set_hour(uint32_t new_hour) { hour = new_hour; }
106 
107  inline uint64_t get_minute() const { return minute; }
108  inline void set_minute(uint32_t new_minute) { minute = new_minute; }
109 
110  inline uint64_t get_second() const { return second; }
111  inline void set_second(uint32_t new_second) { second = new_second; }
112 
113  inline uint64_t get_second_part() const { return second_part; }
114  inline void set_second_part(uint32_t new_second_part) { second_part = new_second_part; }
115 
127  bool initFromItem(Item *args, interval_type int_type, String *str_value);
128 
137  bool addDate(type::Time *ltime, interval_type int_type);
138 
139 private:
140 
144  static const uint32_t MAX_STRING_ELEMENTS = 5;
145 
149  static const uint32_t NUM_YEAR_MONTH_STRING_ELEMENTS = 2;
150  static const uint32_t NUM_DAY_HOUR_STRING_ELEMENTS = 2;
151  static const uint32_t NUM_DAY_MICROSECOND_STRING_ELEMENTS = 5;
152  static const uint32_t NUM_DAY_MINUTE_STRING_ELEMENTS = 3;
153  static const uint32_t NUM_DAY_SECOND_STRING_ELEMENTS = 4;
154  static const uint32_t NUM_HOUR_MICROSECOND_STRING_ELEMENTS = 4;
155  static const uint32_t NUM_HOUR_MINUTE_STRING_ELEMENTS = 2;
156  static const uint32_t NUM_HOUR_SECOND_STRING_ELEMENTS = 3;
157  static const uint32_t NUM_MINUTE_MICROSECOND_STRING_ELEMENTS = 3;
158  static const uint32_t NUM_MINUTE_SECOND_STRING_ELEMENTS = 2;
159  static const uint32_t NUM_SECOND_MICROSECOND_STRING_ELEMENTS = 2;
160 
179  bool getIntervalFromString(const char *str,
180  uint32_t length,
181  const charset_info_st * const cs,
182  uint32_t count,
183  uint64_t *values,
184  bool transform_msec);
185 
186  uint32_t year;
187  uint32_t month;
188  uint32_t day;
189  uint32_t hour;
190  uint64_t minute;
191  uint64_t second;
192  uint64_t second_part;
193  bool neg;
194 
195 };
196 
197 } /* namespace drizzled */
198 
bool getIntervalFromString(const char *str, uint32_t length, const charset_info_st *const cs, uint32_t count, uint64_t *values, bool transform_msec)
bool initFromItem(Item *args, interval_type int_type, String *str_value)
Stores time interval for date/time manipulation.
TODO: Rename this file - func.h is stupid.
bool addDate(type::Time *ltime, interval_type int_type)
void setNegative(bool in_neg=true)
static const uint32_t NUM_YEAR_MONTH_STRING_ELEMENTS
static const uint32_t MAX_STRING_ELEMENTS