1
0

IntegerField.h 2.8 KB

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