1
0

IntegerField.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 wchar_t *format, TimeParse *tp=NULL);
  61. #ifdef _WIN32
  62. static int LookupToken(const wchar_t *t);
  63. #else
  64. static int LookupToken(CFStringRef t);
  65. #endif
  66. };
  67. class DateTimeField : public IntegerField {
  68. public:
  69. DateTimeField();
  70. DateTimeField(int Val);
  71. virtual ~DateTimeField();
  72. };
  73. class LengthField : public IntegerField {
  74. public:
  75. LengthField();
  76. LengthField(int Val);
  77. virtual ~LengthField();
  78. };
  79. #endif