1
0

db.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef NULLSOT_LOCALMEDIA_DB_H
  2. #define NULLSOT_LOCALMEDIA_DB_H
  3. #define MAINTABLE_ID_FILENAME 0
  4. #define MAINTABLE_ID_TITLE 1
  5. #define MAINTABLE_ID_ARTIST 2
  6. #define MAINTABLE_ID_ALBUM 3
  7. #define MAINTABLE_ID_YEAR 4
  8. #define MAINTABLE_ID_GENRE 5
  9. #define MAINTABLE_ID_COMMENT 6
  10. #define MAINTABLE_ID_TRACKNB 7
  11. #define MAINTABLE_ID_LENGTH 8 //in seconds
  12. #define MAINTABLE_ID_TYPE 9 //0=audio, 1=video
  13. #define MAINTABLE_ID_LASTUPDTIME 10 // last time (seconds since 1970) of db update of this item
  14. #define MAINTABLE_ID_LASTPLAY 11 // last time (seconds since 1970) of last play
  15. #define MAINTABLE_ID_RATING 12
  16. #define MAINTABLE_ID_GRACENOTE_ID 14
  17. #define MAINTABLE_ID_PLAYCOUNT 15 // play count
  18. #define MAINTABLE_ID_FILETIME 16 // file time
  19. #define MAINTABLE_ID_FILESIZE 17 // file size, kilobytes
  20. #define MAINTABLE_ID_BITRATE 18 // file bitratea, kbps
  21. #include "../nde/nde.h"
  22. #include <map>
  23. #include <string>
  24. // DataBase manipulations
  25. class DB
  26. {
  27. // construcotrs
  28. public:
  29. DB();
  30. ~DB();
  31. // methods
  32. public:
  33. int Open();
  34. int Close();
  35. int Nuke();
  36. int AddColumn(char* metaKey, int type); // returns index of the new column or -1 on error
  37. private:
  38. BOOL Discover(void);
  39. void ClearMap(void);
  40. // properties
  41. public:
  42. void SetTableDir(const char* tableDir);
  43. const char* GetTableDir();
  44. int GetColumnsCount();
  45. int GetColumnId(char *metaKey); // returns index of the column or -1 if can't find
  46. // fields
  47. private:
  48. char * tableDir;
  49. Database db;
  50. Table *table;
  51. Scanner *sc;
  52. std::map< std::string, int> columnsMap;
  53. };
  54. #endif //NULLSOT_LOCALMEDIA_DB_H