MythTV  master
dbaccess.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <vector>
3 #include <map>
4 
5 #include "mythdb.h"
6 #include "cleanup.h"
7 #include "dbaccess.h"
8 #include "mythmiscutil.h"
9 
10 namespace
11 {
12  template <typename T, typename arg_type>
13  struct call_sort
14  {
15  explicit call_sort(T &c) : m_c(c) {}
16 
17  bool operator()(const arg_type &lhs, const arg_type &rhs)
18  {
19  return m_c.sort(lhs, rhs);
20  }
21 
22  T &m_c;
23  };
24 }
25 
27 {
28  public:
30  typedef std::vector<entry> entry_list;
31 
32  private:
33  typedef std::map<int, QString> entry_map;
34 
35  public:
36  SingleValueImp(const QString &table_name, const QString &id_name,
37  const QString &value_name) : m_table_name(table_name),
38  m_id_name(id_name), m_value_name(value_name), m_ready(false),
39  m_dirty(true), m_clean_stub(this)
40  {
41  m_insert_sql = QString("INSERT INTO %1 (%2) VALUES (:NAME)")
42  .arg(m_table_name).arg(m_value_name);
43  m_fill_sql = QString("SELECT %1, %2 FROM %3").arg(m_id_name)
44  .arg(m_value_name).arg(m_table_name);
45  m_delete_sql = QString("DELETE FROM %1 WHERE %2 = :ID")
46  .arg(m_table_name).arg(m_id_name);
47  }
48 
49  virtual ~SingleValueImp() = default;
50 
51  mutable QMutex mutex;
52 
53  void load_data()
54  {
55  QMutexLocker locker(&mutex);
56  if (!m_ready)
57  {
58  fill_from_db();
59  m_ready = true;
60  }
61  }
62 
63  int add(const QString &name)
64  {
65  int id = 0;
66 
67  if (!exists(name, &id))
68  {
70  query.prepare(m_insert_sql);
71  query.bindValue(":NAME", name);
72  if (query.exec())
73  {
74  if (query.exec("SELECT LAST_INSERT_ID()") && query.next())
75  {
76  id = query.value(0).toInt();
77  m_entries.insert(entry_map::value_type(id, name));
78  m_dirty = true;
79  }
80  else
81  MythDB::DBError("get last id", query);
82  }
83  }
84 
85  return id;
86  }
87 
88  bool get(int id, QString &value)
89  {
90  entry_map::const_iterator p = m_entries.find(id);
91  if (p != m_entries.end())
92  {
93  value = p->second;
94  return true;
95  }
96  return false;
97  }
98 
99  void remove(int id)
100  {
101  entry_map::iterator p = m_entries.find(id);
102  if (p != m_entries.end())
103  {
104  MSqlQuery query(MSqlQuery::InitCon());
105  query.prepare(m_delete_sql);
106  query.bindValue(":ID", p->first);
107  if (query.exec())
108  {
109  m_dirty = true;
110  m_entries.erase(p);
111  }
112  }
113  }
114 
115  bool exists(int id)
116  {
117  return m_entries.find(id) != m_entries.end();
118  }
119 
120  bool exists(const QString &name, int *id = nullptr)
121  {
122  entry_map::const_iterator p = find(name);
123  if (p != m_entries.end())
124  {
125  if (id)
126  *id = p->first;
127  return true;
128  }
129  return false;
130  }
131 
133  {
134  if (m_dirty)
135  {
136  m_dirty = false;
137  m_ret_entries.clear();
138 
139  for (entry_map::const_iterator p = m_entries.begin();
140  p != m_entries.end(); ++p)
141  {
142  m_ret_entries.push_back(entry_list::value_type(p->first,
143  p->second));
144  }
145  std::sort(m_ret_entries.begin(), m_ret_entries.end(),
146  call_sort<SingleValueImp, entry>(*this));
147  }
148 
149  return m_ret_entries;
150  }
151 
152  virtual bool sort(const entry &lhs, const entry &rhs)
153  {
154  return naturalCompare(lhs.second, rhs.second) < 0;
155  }
156 
157  void cleanup()
158  {
159  m_ready = false;
160  m_dirty = true;
161  m_ret_entries.clear();
162  m_entries.clear();
163  }
164 
165  private:
166  entry_map::iterator find(const QString &name)
167  {
168  for (entry_map::iterator p = m_entries.begin();
169  p != m_entries.end(); ++p)
170  {
171  if (p->second == name)
172  return p;
173  }
174  return m_entries.end();
175  }
176 
178  {
179  m_entries.clear();
180 
181  MSqlQuery query(MSqlQuery::InitCon());
182 
183  if (query.exec(m_fill_sql))
184  {
185  while (query.next())
186  {
187  int id = query.value(0).toInt();
188  QString val = query.value(1).toString();
189  m_entries.insert(entry_map::value_type(id, val));
190  }
191  }
192  }
193 
194  private:
195  QString m_table_name;
196  QString m_id_name;
197  QString m_value_name;
198 
199  QString m_insert_sql;
200  QString m_fill_sql;
201  QString m_delete_sql;
202 
203  bool m_ready;
204  bool m_dirty;
208 };
209 
211 
213 {
214 }
215 
217 {
218  delete m_imp;
219 }
220 
221 int SingleValue::add(const QString &name)
222 {
223  return m_imp->add(name);
224 }
225 
226 bool SingleValue::get(int id, QString &category)
227 {
228  return m_imp->get(id, category);
229 }
230 
232 {
233  m_imp->remove(id);
234 }
235 
237 {
238  return m_imp->exists(id);
239 }
240 
241 bool SingleValue::exists(const QString &name)
242 {
243  return m_imp->exists(name);
244 }
245 
247 {
248  return m_imp->getList();
249 }
250 
252 {
253  m_imp->load_data();
254 }
255 
257 
259 {
260  public:
262 
263  private:
264  typedef std::map<int, entry> id_map;
265 
266  public:
267  MultiValueImp(const QString &table_name, const QString &id_name,
268  const QString &value_name) : m_table_name(table_name),
269  m_id_name(id_name), m_value_name(value_name), m_ready(false),
270  m_clean_stub(this)
271  {
272  m_insert_sql = QString("INSERT INTO %1 (%2, %3) VALUES (:ID, :VALUE)")
273  .arg(m_table_name).arg(m_id_name).arg(m_value_name);
274  m_fill_sql = QString("SELECT %1, %2 FROM %3 ORDER BY %4").arg(m_id_name)
275  .arg(m_value_name).arg(m_table_name).arg(m_id_name);
276  }
277 
278  mutable QMutex mutex;
279 
280  void load_data()
281  {
282  QMutexLocker locker(&mutex);
283  if (!m_ready)
284  {
285  fill_from_db();
286  m_ready = true;
287  }
288  }
289 
290  void cleanup()
291  {
292  m_ready = false;
293  m_val_map.clear();
294  }
295 
296  int add(int id, int value)
297  {
298  bool db_insert = false;
299  id_map::iterator p = m_val_map.find(id);
300  if (p != m_val_map.end())
301  {
302  entry::values_type &va = p->second.values;
303  entry::values_type::iterator v =
304  std::find(va.begin(), va.end(), value);
305  if (v == va.end())
306  {
307  va.push_back(value);
308  db_insert = true;
309  }
310  }
311  else
312  {
313  entry e;
314  e.id = id;
315  e.values.push_back(value);
316  m_val_map.insert(id_map::value_type(id, e));
317  db_insert = true;
318  }
319 
320  if (db_insert)
321  {
322  MSqlQuery query(MSqlQuery::InitCon());
323  query.prepare(m_insert_sql);
324  query.bindValue(":ID", id);
325  query.bindValue(":VALUE", value);
326  if (!query.exec())
327  MythDB::DBError("multi value insert", query);
328  }
329 
330  return id;
331  }
332 
333  bool get(int id, entry &values)
334  {
335  id_map::iterator p = m_val_map.find(id);
336  if (p != m_val_map.end())
337  {
338  values = p->second;
339  return true;
340  }
341  return false;
342  }
343 
344  void remove(int id, int value)
345  {
346  id_map::iterator p = m_val_map.find(id);
347  if (p != m_val_map.end())
348  {
349  entry::values_type::iterator vp =
350  std::find(p->second.values.begin(), p->second.values.end(),
351  value);
352  if (vp != p->second.values.end())
353  {
354  MSqlQuery query(MSqlQuery::InitCon());
355  QString del_query = QString("DELETE FROM %1 WHERE %2 = :ID AND "
356  "%3 = :VALUE")
357  .arg(m_table_name).arg(m_id_name).arg(m_value_name);
358  query.prepare(del_query);
359  query.bindValue(":ID", p->first);
360  query.bindValue(":VALUE", int(*vp));
361  if (!query.exec() || !query.isActive())
362  {
363  MythDB::DBError("multivalue remove", query);
364  }
365  p->second.values.erase(vp);
366  }
367  }
368  }
369 
370  void remove(int id)
371  {
372  id_map::iterator p = m_val_map.find(id);
373  if (p != m_val_map.end())
374  {
375  MSqlQuery query(MSqlQuery::InitCon());
376  QString del_query = QString("DELETE FROM %1 WHERE %2 = :ID")
377  .arg(m_table_name).arg(m_id_name);
378  query.prepare(del_query);
379  query.bindValue(":ID", p->first);
380  if (!query.exec() || !query.isActive())
381  {
382  MythDB::DBError("multivalue remove", query);
383  }
384  m_val_map.erase(p);
385  }
386  }
387 
388  bool exists(int id, int value)
389  {
390  id_map::iterator p = m_val_map.find(id);
391  if (p != m_val_map.end())
392  {
393  entry::values_type::iterator vp =
394  std::find(p->second.values.begin(), p->second.values.end(),
395  value);
396  return vp != p->second.values.end();
397  }
398  return false;
399  }
400 
401  bool exists(int id)
402  {
403  return m_val_map.find(id) != m_val_map.end();
404  }
405 
406  private:
408  {
409  m_val_map.clear();
410 
411  MSqlQuery query(MSqlQuery::InitCon());
412 
413  if (query.exec(m_fill_sql) && query.size() > 0)
414  {
415  id_map::iterator p = m_val_map.end();
416  while (query.next())
417  {
418  int id = query.value(0).toInt();
419  int val = query.value(1).toInt();
420 
421  if (p == m_val_map.end() ||
422  (p != m_val_map.end() && p->first != id))
423  {
424  p = m_val_map.find(id);
425  if (p == m_val_map.end())
426  {
427  entry e;
428  e.id = id;
429  p = m_val_map.insert(id_map::value_type(id, e)).first;
430  }
431  }
432  p->second.values.push_back(val);
433  }
434  }
435  }
436 
437  private:
439 
440  QString m_table_name;
441  QString m_id_name;
442  QString m_value_name;
443 
444  QString m_insert_sql;
445  QString m_fill_sql;
446  QString m_id_sql;
447 
448  bool m_ready;
450 };
451 
453 
455 {
456 }
457 
458 int MultiValue::add(int id, int value)
459 {
460  return m_imp->add(id, value);
461 }
462 
463 bool MultiValue::get(int id, entry &values)
464 {
465  return m_imp->get(id, values);
466 }
467 
468 void MultiValue::remove(int id, int value)
469 {
470  m_imp->remove(id, value);
471 }
472 
473 void MultiValue::remove(int id)
474 {
475  m_imp->remove(id);
476 }
477 
478 bool MultiValue::exists(int id, int value)
479 {
480  return m_imp->exists(id, value);
481 }
482 
483 bool MultiValue::exists(int id)
484 {
485  return m_imp->exists(id);
486 }
487 
489 {
490  m_imp->load_data();
491 }
492 
494 
496  SingleValue(new SingleValueImp("videocategory", "intid", "category"))
497 {
498 }
499 
501 {
502  static VideoCategory vc;
503  vc.load_data();
504  return vc;
505 }
506 
508 
510  SingleValue(new SingleValueImp("videocountry", "intid", "country"))
511 {
512 }
513 
515 {
516  static VideoCountry vc;
517  vc.load_data();
518  return vc;
519 }
520 
522 
524  SingleValue(new SingleValueImp("videogenre", "intid", "genre"))
525 {
526 }
527 
529 {
530  static VideoGenre vg;
531  vg.load_data();
532  return vg;
533 }
534 
536 
538  SingleValue(new SingleValueImp("videocast", "intid", "cast"))
539 {
540 }
541 
543 {
544  static VideoCast vc;
545  vc.load_data();
546  return vc;
547 }
548 
550 
552  MultiValue(new MultiValueImp("videometadatagenre", "idvideo", "idgenre"))
553 {
554 }
555 
557 {
558  static VideoGenreMap vgm;
559  vgm.load_data();
560  return vgm;
561 }
562 
564 
566  MultiValue(new MultiValueImp("videometadatacountry", "idvideo",
567  "idcountry"))
568 {
569 }
570 
572 {
573  static VideoCountryMap vcm;
574  vcm.load_data();
575  return vcm;
576 }
577 
579 
581  MultiValue(new MultiValueImp("videometadatacast", "idvideo",
582  "idcast"))
583 {
584 }
585 
587 {
588  static VideoCastMap vcm;
589  vcm.load_data();
590  return vcm;
591 }
592 
594 
596 {
597  public:
601 
602  public:
603  FileAssociationsImp() = default;
604 
606  {
607  file_association ret_fa(fa);
608 
609  file_association *existing_fa = nullptr;
610  MSqlQuery query(MSqlQuery::InitCon());
611 
612  association_list::iterator p = find(ret_fa.extension);
613  if (p != m_file_associations.end())
614  {
615  ret_fa.id = p->id;
616  existing_fa = &(*p);
617 
618  query.prepare("UPDATE videotypes SET extension = :EXT, "
619  "playcommand = :PLAYCMD, f_ignore = :IGNORED, "
620  "use_default = :USEDEFAULT WHERE intid = :ID");
621  query.bindValue(":ID", ret_fa.id);
622  }
623  else
624  query.prepare("INSERT INTO videotypes (extension, playcommand, "
625  "f_ignore, use_default) VALUES "
626  "(:EXT, :PLAYCMD, :IGNORED, :USEDEFAULT)");
627 
628  query.bindValue(":EXT", ret_fa.extension);
629  query.bindValue(":PLAYCMD", ret_fa.playcommand);
630  query.bindValue(":IGNORED", ret_fa.ignore);
631  query.bindValue(":USEDEFAULT", ret_fa.use_default);
632 
633  if (query.exec() && query.isActive())
634  {
635  if (!existing_fa)
636  {
637  if (query.exec("SELECT LAST_INSERT_ID()") && query.next())
638  {
639  ret_fa.id = query.value(0).toUInt();
640  m_file_associations.push_back(ret_fa);
641  }
642  else
643  return false;
644  }
645  else
646  *existing_fa = ret_fa;
647 
648  fa = ret_fa;
649  return true;
650  }
651 
652  return false;
653  }
654 
655  bool get(unsigned int id, file_association &val) const
656  {
657  association_list::const_iterator p = find(id);
658  if (p != m_file_associations.end())
659  {
660  val = *p;
661  return true;
662  }
663  return false;
664  }
665 
666  bool get(const QString &ext, file_association &val) const
667  {
668  association_list::const_iterator p = find(ext);
669  if (p != m_file_associations.end())
670  {
671  val = *p;
672  return true;
673  }
674  return false;
675  }
676 
677  bool remove(unsigned int id)
678  {
679  association_list::iterator p = find(id);
680  if (p != m_file_associations.end())
681  {
682  MSqlQuery query(MSqlQuery::InitCon());
683  query.prepare("DELETE FROM videotypes WHERE intid = :ID");
684  query.bindValue(":ID", p->id);
685  if (query.exec())
686  {
687  m_file_associations.erase(p);
688  return true;
689  }
690  }
691  return false;
692  }
693 
694  const association_list &getList() const
695  {
696  return m_file_associations;
697  }
698 
699  void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
700  {
701  for (association_list::const_iterator p = m_file_associations.begin();
702  p != m_file_associations.end(); ++p)
703  {
704  ext_ignore.push_back(std::make_pair(p->extension, p->ignore));
705  }
706  }
707 
708  mutable QMutex mutex;
709 
710  void load_data()
711  {
712  QMutexLocker locker(&mutex);
713  if (!m_ready)
714  {
715  fill_from_db();
716  m_ready = true;
717  }
718  }
719 
720  void cleanup()
721  {
722  m_ready = false;
723  m_file_associations.clear();
724  }
725 
726  private:
728  {
729  MSqlQuery query(MSqlQuery::InitCon());
730  if (query.exec("SELECT intid, extension, playcommand, f_ignore, "
731  "use_default FROM videotypes"))
732  {
733  while (query.next())
734  {
735  file_association fa(query.value(0).toUInt(),
736  query.value(1).toString(),
737  query.value(2).toString(),
738  query.value(3).toBool(),
739  query.value(4).toBool());
740  m_file_associations.push_back(fa);
741  }
742  }
743  }
744 
745  association_list::iterator find(const QString &ext)
746  {
747  for (association_list::iterator p = m_file_associations.begin();
748  p != m_file_associations.end(); ++p)
749  {
750  if (p->extension.length() == ext.length() &&
751  ext.indexOf(p->extension) == 0)
752  {
753  return p;
754  }
755  }
756  return m_file_associations.end();
757  }
758 
759  association_list::iterator find(unsigned int id)
760  {
761  for (association_list::iterator p = m_file_associations.begin();
762  p != m_file_associations.end(); ++p)
763  {
764  if (p->id == id) return p;
765  }
766  return m_file_associations.end();
767  }
768 
769  association_list::const_iterator find(const QString &ext) const
770  {
771  for (association_list::const_iterator p = m_file_associations.begin();
772  p != m_file_associations.end(); ++p)
773  {
774  if (p->extension.length() == ext.length() &&
775  ext.indexOf(p->extension) == 0)
776  {
777  return p;
778  }
779  }
780  return m_file_associations.end();
781  }
782 
783  association_list::const_iterator find(unsigned int id) const
784  {
785  for (association_list::const_iterator p = m_file_associations.begin();
786  p != m_file_associations.end(); ++p)
787  {
788  if (p->id == id) return p;
789  }
790  return m_file_associations.end();
791  }
792 
793  private:
795  bool m_ready {false};
796 };
797 
798 
800  use_default(false)
801 {
802 }
803 
805  const QString &ext,
806  const QString &playcmd,
807  bool l_ignore,
808  bool l_use_default) :
809  id(l_id), extension(ext), playcommand(playcmd), ignore(l_ignore),
810  use_default(l_use_default)
811 {
812 }
813 
815 {
816  return m_imp->add(fa);
817 }
818 
819 bool FileAssociations::get(unsigned int id, file_association &val) const
820 {
821  return m_imp->get(id, val);
822 }
823 
824 bool FileAssociations::get(const QString &ext, file_association &val) const
825 {
826  return m_imp->get(ext, val);
827 }
828 
829 bool FileAssociations::remove(unsigned int id)
830 {
831  return m_imp->remove(id);
832 }
833 
835 {
836  return m_imp->getList();
837 }
838 
840 {
841  return m_imp->getExtensionIgnoreList(ext_ignore);
842 }
843 
845 {
846  m_imp->load_data();
847 }
848 
850 {
852 }
853 
855 {
856  delete m_imp;
857 }
858 
860 {
861  static FileAssociations fa;
862  fa.load_data();
863  return fa;
864 }
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:794
bool get(const QString &ext, file_association &val) const
Definition: dbaccess.cpp:666
void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
Definition: dbaccess.cpp:699
QMutex mutex
Definition: dbaccess.cpp:51
association_list::iterator find(const QString &ext)
Definition: dbaccess.cpp:745
void bindValue(const QString &placeholder, const QVariant &val)
Definition: mythdbcon.cpp:875
association_list::iterator find(unsigned int id)
Definition: dbaccess.cpp:759
SimpleCleanup< MultiValueImp > m_clean_stub
Definition: dbaccess.cpp:449
association_list::const_iterator find(unsigned int id) const
Definition: dbaccess.cpp:783
bool exists(int id, int value)
Definition: dbaccess.cpp:388
static VideoCastMap & getCastMap()
Definition: dbaccess.cpp:586
FileAssociations::ext_ignore_list ext_ignore_list
Definition: dbaccess.cpp:600
std::vector< std::pair< QString, bool > > ext_ignore_list
Definition: dbaccess.h:152
std::vector< long > values_type
Definition: dbaccess.h:42
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
QString m_table_name
Definition: dbaccess.cpp:195
QString m_insert_sql
Definition: dbaccess.cpp:444
QString m_value_name
Definition: dbaccess.cpp:442
int add(int id, int value)
Definition: dbaccess.cpp:458
void fill_from_db()
Definition: dbaccess.cpp:407
entry_list m_ret_entries
Definition: dbaccess.cpp:205
std::vector< file_association > association_list
Definition: dbaccess.h:151
const association_list & getList() const
Definition: dbaccess.cpp:834
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
int size(void) const
Definition: mythdbcon.h:187
void load_data()
Definition: dbaccess.cpp:53
int add(const QString &name)
Definition: dbaccess.cpp:221
void load_data()
Definition: dbaccess.cpp:280
static VideoCategory & GetCategory()
Definition: dbaccess.cpp:500
QString m_id_name
Definition: dbaccess.cpp:441
FileAssociations::association_list association_list
Definition: dbaccess.cpp:599
static VideoCountryMap & getCountryMap()
Definition: dbaccess.cpp:571
void remove(int id)
Definition: dbaccess.cpp:231
std::vector< entry > entry_list
Definition: dbaccess.h:15
bool get(unsigned int id, file_association &val) const
Definition: dbaccess.cpp:655
void load_data()
Definition: dbaccess.cpp:488
SimpleCleanup< SingleValueImp > m_clean_stub
Definition: dbaccess.cpp:207
QString m_delete_sql
Definition: dbaccess.cpp:201
QVariant value(int i) const
Definition: mythdbcon.h:182
association_list::const_iterator find(const QString &ext) const
Definition: dbaccess.cpp:769
bool get(int id, entry &values)
Definition: dbaccess.cpp:333
QString m_id_sql
Definition: dbaccess.cpp:446
QString m_fill_sql
Definition: dbaccess.cpp:445
static VideoCountry & getCountry()
Definition: dbaccess.cpp:514
entry_map m_entries
Definition: dbaccess.cpp:206
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
values_type values
Definition: dbaccess.h:43
bool exists(const QString &name, int *id=nullptr)
Definition: dbaccess.cpp:120
bool remove(unsigned int id)
Definition: dbaccess.cpp:829
bool get(int id, QString &value)
Definition: dbaccess.cpp:226
class FileAssociationsImp * m_imp
Definition: dbaccess.h:174
entry_map::iterator find(const QString &name)
Definition: dbaccess.cpp:166
bool isActive(void) const
Definition: mythdbcon.h:188
FileAssociations::file_association file_association
Definition: dbaccess.cpp:598
void remove(int id, int value)
Definition: dbaccess.cpp:344
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:547
int add(const QString &name)
Definition: dbaccess.cpp:63
const char * name
Definition: ParseText.cpp:339
QString m_id_name
Definition: dbaccess.cpp:196
FileAssociationsImp()=default
static VideoCast & GetCast()
Definition: dbaccess.cpp:542
void cleanup()
Definition: dbaccess.cpp:157
static FileAssociations & getFileAssociation()
Definition: dbaccess.cpp:859
MultiValue::entry entry
Definition: dbaccess.cpp:261
virtual bool sort(const entry &lhs, const entry &rhs)
Definition: dbaccess.cpp:152
void remove(int id)
Definition: dbaccess.cpp:99
void remove(int id, int value)
Definition: dbaccess.cpp:468
void cleanup()
Definition: dbaccess.cpp:290
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:819
SingleValueImp * m_imp
Definition: dbaccess.h:32
bool exists(int id)
Definition: dbaccess.cpp:401
QMutex mutex
Definition: dbaccess.cpp:278
QString m_insert_sql
Definition: dbaccess.cpp:199
static VideoGenreMap & getGenreMap()
Definition: dbaccess.cpp:556
bool get(unsigned int id, file_association &val) const
Definition: dbaccess.cpp:819
bool exists(int id)
Definition: dbaccess.cpp:236
bool add(file_association &fa)
Definition: dbaccess.cpp:814
void fill_from_db()
Definition: dbaccess.cpp:177
const entry_list & getList()
Definition: dbaccess.cpp:246
std::pair< int, QString > entry
Definition: dbaccess.h:14
SingleValue(SingleValueImp *imp)
Definition: dbaccess.cpp:212
static VideoGenre & getGenre()
Definition: dbaccess.cpp:528
SingleValue::entry entry
Definition: dbaccess.cpp:29
QString m_fill_sql
Definition: dbaccess.cpp:200
id_map m_val_map
Definition: dbaccess.cpp:438
bool exists(int id, int value)
Definition: dbaccess.cpp:478
association_list m_file_associations
Definition: dbaccess.cpp:794
bool exists(int id)
Definition: dbaccess.cpp:115
SingleValueImp(const QString &table_name, const QString &id_name, const QString &value_name)
Definition: dbaccess.cpp:36
std::vector< entry > entry_list
Definition: dbaccess.cpp:30
MultiValueImp(const QString &table_name, const QString &id_name, const QString &value_name)
Definition: dbaccess.cpp:267
void load_data()
Definition: dbaccess.cpp:251
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:615
QString m_value_name
Definition: dbaccess.cpp:197
virtual ~SingleValueImp()=default
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
const association_list & getList() const
Definition: dbaccess.cpp:694
std::map< int, QString > entry_map
Definition: dbaccess.cpp:33
bool add(file_association &fa)
Definition: dbaccess.cpp:605
MultiValueImp * m_imp
Definition: dbaccess.h:62
bool get(int id, entry &values)
Definition: dbaccess.cpp:463
bool remove(unsigned int id)
Definition: dbaccess.cpp:677
int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity)
bool get(int id, QString &value)
Definition: dbaccess.cpp:88
QString m_table_name
Definition: dbaccess.cpp:440
const entry_list & getList()
Definition: dbaccess.cpp:132
void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
Definition: dbaccess.cpp:839
std::map< int, entry > id_map
Definition: dbaccess.cpp:264
void remove(int id)
Definition: dbaccess.cpp:370
MultiValue(MultiValueImp *imp)
Definition: dbaccess.cpp:454
virtual ~SingleValue()
Definition: dbaccess.cpp:216
int add(int id, int value)
Definition: dbaccess.cpp:296