~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.h

  • Committer: Brian Aker
  • Date: 2009-06-08 02:42:24 UTC
  • mfrom: (1054.1.6 merge)
  • Revision ID: brian@gaz-20090608024224-zlff1bpq62r8m5gy
Removal of LOCK TABLES.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  Authors:
 
7
 *
 
8
 *  Jay Pipes <jay.pipes@sun.com>
5
9
 *
6
10
 *  This program is free software; you can redistribute it and/or modify
7
11
 *  it under the terms of the GNU General Public License as published by
68
72
 
69
73
#include "drizzled/calendar.h"
70
74
 
71
 
#include <cassert>
72
75
#include <ostream>
73
76
 
74
77
/* Outside forward declarations */
285
288
 
286
289
 
287
290
  /**
 
291
   * Operator overload for adding/subtracting a TemporalInterval
 
292
   * instance to this temporal.
 
293
   *
 
294
   * @param TemporalInterval instance to add/subtract to/from
 
295
   */
 
296
  Date& operator+=(const TemporalIntervalYear &rhs);
 
297
  Date& operator+=(const TemporalIntervalDayOrLess &rhs);
 
298
  Date& operator+=(const TemporalIntervalDayOrWeek &rhs);
 
299
  Date& operator+=(const TemporalIntervalYearMonth &rhs);
 
300
  Date& operator-=(const TemporalIntervalYear &rhs);
 
301
  Date& operator-=(const TemporalIntervalDayOrLess &rhs);
 
302
  Date& operator-=(const TemporalIntervalDayOrWeek &rhs);
 
303
  Date& operator-=(const TemporalIntervalYearMonth &rhs);
 
304
 
 
305
 
 
306
  /**
288
307
   * Operator overload for when a DateTime instance is
289
308
   * assigned to a Date.  We do a copy of the DateTime's
290
309
   * date-related components.
312
331
   * value.
313
332
   *
314
333
   * @param C-String to fill.
315
 
   * @param Length of to C-String
316
 
   * @returns length of string written (including trailing '\0').
317
 
   *          If output was truncated, returns length that would have
318
 
   *          been outputted.
319
 
   */
320
 
  virtual int to_string(char *to, size_t to_len) const;
321
 
 
322
 
  /**
323
 
   * Maximum length of C-String needed to represent type
324
 
   * (including '\0').
325
 
   */
326
 
  static const int MAX_STRING_LENGTH= 11;
 
334
   * @param Length of filled string (out param)
 
335
   */
 
336
  virtual void to_string(char *to, size_t *to_len) const;
327
337
 
328
338
  /**
329
339
   * Attempts to populate the Date instance based
333
343
   * successful.
334
344
   *
335
345
   * @param String to convert from
336
 
   * @param Length of supplied string (not including trailing '\0').
 
346
   * @param Length of supplied string
337
347
   */
338
348
  virtual bool from_string(const char *from, size_t from_len);
339
349
 
456
466
public:
457
467
  Time() :Temporal() {}
458
468
  /* Maximum number of seconds in 23:59:59 (24 * 60 * 60) */
459
 
  static const uint32_t MAX_CUMULATIVE_SECONDS= 86400L;
 
469
  const static uint32_t MAX_CUMULATIVE_SECONDS= 86400L;
460
470
 
461
471
  /**
462
472
   * Comparison operator overloads to compare a Time against
493
503
   * string representation of the Time
494
504
   * value.
495
505
   *
496
 
   * @param C-String to fill
497
 
   * @param Length of to C-String
498
 
   * @returns length of string written (not including trailing '\0').
499
 
   *          If output was truncated, returns length that would have
500
 
   *          been outputted.
501
 
   */
502
 
  int to_string(char *to, size_t to_len) const;
503
 
 
504
 
  /**
505
 
   * Maximum length of C-String needed to represent type
506
 
   * (including '\0').
507
 
   */
508
 
  static const int MAX_STRING_LENGTH= 9;
509
 
 
 
506
   * @param C-String to fill.
 
507
   * @param Length of filled string (out param)
 
508
   */
 
509
  void to_string(char *to, size_t *to_len) const;
510
510
 
511
511
  /**
512
512
   * Attempts to populate the Time instance based
598
598
   * string representation of the DateTime
599
599
   * value.
600
600
   *
601
 
   * @param C-String to fill
602
 
   * @param Length of to C-String
603
 
   * @returns length of string written (not including trailing '\0').
604
 
   *          If output was truncated, returns length that would have
605
 
   *          been outputted.
606
 
   */
607
 
  virtual int to_string(char *to, size_t to_len) const;
608
 
 
609
 
  /**
610
 
   * Maximum length of C-String needed to represent type
611
 
   * (including '\0').
612
 
   */
613
 
  static const int MAX_STRING_LENGTH= 27;
 
601
   * @param C-String to fill.
 
602
   * @param Length of filled string (out param)
 
603
   */
 
604
  virtual void to_string(char *to, size_t *to_len) const;
614
605
 
615
606
  /**
616
607
   * Attempts to populate the DateTime instance based
652
643
   * successful.
653
644
   *
654
645
   * @param Integer to convert from
655
 
   * @param convert if conversion to canonical representation
656
 
   *        should be attempted
657
646
   */
658
 
  bool from_int64_t(const int64_t from, bool convert);
659
 
 
660
 
  bool from_int64_t(const int64_t from) {
661
 
    return from_int64_t(from, true);
662
 
  }
 
647
  bool from_int64_t(const int64_t from);
663
648
 
664
649
  /**
665
650
   * Fills a supplied tm pointer with an
762
747
   * string representation of the MicroTimestamp
763
748
   * value.
764
749
   *
765
 
   * @param C-String to fill
766
 
   * @param Length of to C-String
767
 
   * @returns length of string written (not including trailing '\0').
768
 
   *          If output was truncated, returns length that would have
769
 
   *          been outputted.
770
 
   */
771
 
  int to_string(char *to, size_t to_len) const;
772
 
 
773
 
  /**
774
 
   * Maximum length of C-String needed to represent type
775
 
   * (including '\0').
776
 
   */
777
 
  static const int MAX_STRING_LENGTH= 27;
 
750
   * @param C-String to fill.
 
751
   * @param Length of filled string (out param)
 
752
   */
 
753
  void to_string(char *to, size_t *to_len) const;
778
754
 
779
755
  /**
780
756
   * Fills a supplied timeval pointer with an