1
0

IntegerField.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* ---------------------------------------------------------------------------
  2. Nullsoft Database Engine
  3. --------------------
  4. codename: Near Death Experience
  5. --------------------------------------------------------------------------- */
  6. /* ---------------------------------------------------------------------------
  7. IntegerField Class Prototypes
  8. --------------------------------------------------------------------------- */
  9. #ifndef __INTEGERFIELD_H
  10. #define __INTEGERFIELD_H
  11. #include <bfc/platform/types.h>
  12. class TimeParse {
  13. public:
  14. int is_relative; // ago/after/before used
  15. int absolute_datetime; // if not is_relative, this is the date/time, otherwise it's the resulting date/time if the query was ran now
  16. int absolute_hasdate; // if not, use only the time portion of absolute_datetime, the rest is now
  17. int absolute_hastime; // if not, use only the date portion of absolute_datetime, the rest is now
  18. int relative_year; // -1 = this year
  19. int relative_month; // -1 = this month
  20. int relative_day; // -1 = this day, -2 = this week
  21. int relative_hour; // -1 = this hour
  22. int relative_min; // -1 = this minute
  23. int relative_sec; // -1 = this second
  24. int relative_kwday; // not used(-1), 0 to 6 for sunday to saturday, yesterday(7), today(8), tomorrow(9)
  25. int offset_value; // timeago/offsetby numerical edit field
  26. int offset_what; // not used(-1) years(0), months(1), weeks(2), days(3), hours(4), minutes(5), seconds(6)
  27. int offset_whence; // not used(-1), after(0), ago/before(1)
  28. int offset_used; // if 1, 'time ago' / 'offset by' should be checked
  29. };
  30. class IntegerField : public Field
  31. {
  32. protected:
  33. virtual void ReadTypedData(const uint8_t *, size_t len);
  34. virtual void WriteTypedData(uint8_t *, size_t len);
  35. virtual size_t GetDataSize(void);
  36. virtual int Compare(Field *Entry);
  37. virtual bool ApplyFilter(Field *Data, int op);
  38. void InitField(void);
  39. int Value;
  40. enum {
  41. WHAT_YEARS,
  42. WHAT_MONTHS,
  43. WHAT_WEEKS,
  44. WHAT_DAYS,
  45. WHAT_HOURS,
  46. WHAT_MINUTES,
  47. WHAT_SECONDS,
  48. };
  49. enum {
  50. FROM_BARE,
  51. FROM_AGO,
  52. FROM_SINCE,
  53. };
  54. public:
  55. ~IntegerField();
  56. IntegerField(int);
  57. IntegerField();
  58. int GetValue(void);
  59. void SetValue(int);
  60. int ApplyConversion(const char *format, TimeParse *tp=NULL);
  61. static int LookupToken(CFStringRef t);
  62. };
  63. class DateTimeField : public IntegerField {
  64. public:
  65. DateTimeField();
  66. DateTimeField(int Val);
  67. virtual ~DateTimeField();
  68. };
  69. class LengthField : public IntegerField {
  70. public:
  71. LengthField();
  72. LengthField(int Val);
  73. virtual ~LengthField();
  74. };
  75. #endif