~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.h

Reworked getTableNames() interface. Way simpler, less mallocs....

Added a straight vector<> for use with storage engines.

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, Inc.
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
68
68
 
69
69
#include "drizzled/calendar.h"
70
70
 
71
 
#include <cassert>
72
71
#include <ostream>
73
72
 
74
73
/* Outside forward declarations */
75
 
namespace type {
76
 
class Decimal;
77
 
}
 
74
class my_decimal;
78
75
 
79
76
namespace drizzled
80
77
{
287
284
 
288
285
 
289
286
  /**
 
287
   * Operator overload for adding/subtracting a TemporalInterval
 
288
   * instance to this temporal.
 
289
   *
 
290
   * @param TemporalInterval instance to add/subtract to/from
 
291
   */
 
292
  Date& operator+=(const TemporalIntervalYear &rhs);
 
293
  Date& operator+=(const TemporalIntervalDayOrLess &rhs);
 
294
  Date& operator+=(const TemporalIntervalDayOrWeek &rhs);
 
295
  Date& operator+=(const TemporalIntervalYearMonth &rhs);
 
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
 
 
301
 
 
302
  /**
290
303
   * Operator overload for when a DateTime instance is
291
304
   * assigned to a Date.  We do a copy of the DateTime's
292
305
   * date-related components.
315
328
   *
316
329
   * @param C-String to fill.
317
330
   * @param Length of to C-String
318
 
   * @returns length of string written (including trailing '\0').
 
331
   * @returns length of string written (not including trailing '\0').
319
332
   *          If output was truncated, returns length that would have
320
333
   *          been outputted.
321
334
   */
335
348
   * successful.
336
349
   *
337
350
   * @param String to convert from
338
 
   * @param Length of supplied string (not including trailing '\0').
 
351
   * @param Length of supplied string
339
352
   */
340
353
  virtual bool from_string(const char *from, size_t from_len);
341
354
 
421
434
   *
422
435
   * @param Pointer to a time_t to convert to
423
436
   */
424
 
  virtual void to_time_t(time_t &to) const;
 
437
  virtual void to_time_t(time_t *to) const;
425
438
 
426
439
  /**
427
440
   * Attempts to populate the Date instance based
435
448
  virtual bool from_time_t(const time_t from);
436
449
 
437
450
  /**
438
 
   * Fills a supplied type::Decimal with a representation of
 
451
   * Fills a supplied my_decimal with a representation of
439
452
   * the Date value.
440
453
   *
441
 
   * @param Pointer to the type::Decimal to fill
 
454
   * @param Pointer to the my_decimal to fill
442
455
   */
443
 
  virtual void to_decimal(type::Decimal *to) const;
 
456
  virtual void to_decimal(my_decimal *to) const;
444
457
 
445
458
  friend class TemporalInterval;
446
459
  friend class Timestamp;
458
471
public:
459
472
  Time() :Temporal() {}
460
473
  /* Maximum number of seconds in 23:59:59 (24 * 60 * 60) */
461
 
  static const uint32_t MAX_CUMULATIVE_SECONDS= 86400L;
 
474
  const static uint32_t MAX_CUMULATIVE_SECONDS= 86400L;
462
475
 
463
476
  /**
464
477
   * Comparison operator overloads to compare a Time against
487
500
  bool is_valid_datetime() const {return false;}
488
501
  bool is_valid_time() const {return is_valid();}
489
502
  bool is_valid_timestamp() const {return false;}
490
 
 
491
503
  /** Returns whether the temporal value is valid date. */
492
504
  bool is_valid() const;
493
 
  bool is_fuzzy_valid() const;
494
505
 
495
506
  /**
496
507
   * Fills a supplied char string with a
534
545
  void to_int32_t(int32_t *to) const;
535
546
 
536
547
  /**
537
 
   * Fills a supplied 8-byte integer pointer with an
538
 
   * integer representation of the Time
539
 
   * value. It is assume seconds past unix epoch
540
 
   *
541
 
   * @param Integer to fill.
542
 
   */
543
 
  void to_uint64_t(uint64_t &to) const;
544
 
 
545
 
  /**
546
548
   * Attempts to populate the Time instance based
547
549
   * on the contents of a supplied 4-byte integer.
548
550
   *
570
572
  bool from_time_t(const time_t from);
571
573
 
572
574
  /**
573
 
   * Fills a supplied type::Decimal with a representation of
 
575
   * Fills a supplied my_decimal with a representation of
574
576
   * the Time value.
575
577
   *
576
 
   * @param Pointer to the type::Decimal to fill
 
578
   * @param Pointer to the my_decimal to fill
577
579
   */
578
 
  void to_decimal(type::Decimal *to) const;
 
580
  void to_decimal(my_decimal *to) const;
579
581
 
580
582
  friend class Date;
581
583
  friend class DateTime;
656
658
   * @param time_t to convert from
657
659
   */
658
660
  bool from_time_t(const time_t from);
659
 
  bool from_timeval(struct timeval &_timeval);
660
661
 
661
662
  /**
662
663
   * Attempts to populate the DateTime instance based
685
686
  void to_tm(struct tm *to) const;
686
687
 
687
688
  /**
688
 
   * Fills a supplied type::Decimal with a representation of
 
689
   * Fills a supplied my_decimal with a representation of
689
690
   * the DateTime value.
690
691
   *
691
 
   * @param Pointer to the type::Decimal to fill
 
692
   * @param Pointer to the my_decimal to fill
692
693
   */
693
 
  void to_decimal(type::Decimal *to) const;
 
694
  void to_decimal(my_decimal *to) const;
694
695
 
695
696
  friend class Timestamp;
696
697
};
752
753
   *
753
754
   * @param Pointer to a time_t to convert to
754
755
   */
755
 
  void to_time_t(time_t &to) const;
 
756
  void to_time_t(time_t *to) const;
756
757
};
757
758
 
758
759
/**
800
801
   *
801
802
   * @param timeval to fill.
802
803
   */
803
 
  void to_timeval(struct timeval &to) const;
 
804
  void to_timeval(struct timeval *to) const;
804
805
};
805
806
 
806
807
/**