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