sqlite3_datasrc.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. // $Id$
  15. #ifndef __DATA_SOURCE_SQLITE3_H
  16. #define __DATA_SOURCE_SQLITE3_H
  17. #include <string>
  18. #include <exceptions/exceptions.h>
  19. #include "data_source.h"
  20. namespace isc {
  21. namespace dns {
  22. class Name;
  23. class RRClass;
  24. class RRType;
  25. class RRsetList;
  26. }
  27. namespace auth {
  28. class Query;
  29. struct Sqlite3Parameters;
  30. class Sqlite3Error : public Exception {
  31. public:
  32. Sqlite3Error(const char* file, size_t line, const char* what) :
  33. isc::Exception(file, line, what) {}
  34. };
  35. class Sqlite3DataSrc : public DataSrc {
  36. ///
  37. /// \name Constructors, Assignment Operator and Destructor.
  38. ///
  39. /// Note: The copy constructor and the assignment operator are intentionally
  40. /// defined as private.
  41. //@{
  42. private:
  43. Sqlite3DataSrc(const Sqlite3DataSrc& source);
  44. Sqlite3DataSrc& operator=(const Sqlite3DataSrc& source);
  45. public:
  46. Sqlite3DataSrc();
  47. ~Sqlite3DataSrc();
  48. //@}
  49. void findClosestEnclosure(NameMatch& match,
  50. const isc::dns::RRClass& qclass) const;
  51. Result findRRset(const isc::dns::Name& qname,
  52. const isc::dns::RRClass& qclass,
  53. const isc::dns::RRType& qtype,
  54. isc::dns::RRsetList& target,
  55. uint32_t& flags,
  56. const isc::dns::Name* zonename) const;
  57. Result findExactRRset(const isc::dns::Name& qname,
  58. const isc::dns::RRClass& qclass,
  59. const isc::dns::RRType& qtype,
  60. isc::dns::RRsetList& target,
  61. uint32_t& flags,
  62. const isc::dns::Name* zonename) const;
  63. Result findAddrs(const isc::dns::Name& qname,
  64. const isc::dns::RRClass& qclass,
  65. isc::dns::RRsetList& target,
  66. uint32_t& flags,
  67. const isc::dns::Name* zonename) const;
  68. Result findReferral(const isc::dns::Name& qname,
  69. const isc::dns::RRClass& qclass,
  70. isc::dns::RRsetList& target,
  71. uint32_t& flags,
  72. const isc::dns::Name* zonename) const;
  73. DataSrc::Result findPreviousName(const isc::dns::Name& qname,
  74. isc::dns::Name& target,
  75. const isc::dns::Name* zonename) const;
  76. Result findCoveringNSEC3(const isc::dns::Name& zonename,
  77. std::string& hash,
  78. isc::dns::RRsetList& target) const;
  79. Result init() { return init(isc::data::ElementPtr()); };
  80. Result init(const isc::data::ElementPtr config);
  81. Result close();
  82. private:
  83. enum Mode {
  84. NORMAL,
  85. ADDRESS,
  86. DELEGATION
  87. };
  88. void open(const std::string& name);
  89. void release(sqlite3_stmt* prepared);
  90. int hasExactZone(const char *name) const;
  91. int findRecords(const isc::dns::Name& name, const isc::dns::RRType& rdtype,
  92. isc::dns::RRsetList& target, const isc::dns::Name* zonename,
  93. const Mode mode, uint32_t& flags) const;
  94. int findClosest(const isc::dns::Name& name, unsigned int* position) const;
  95. private:
  96. Sqlite3Parameters* dbparameters;
  97. };
  98. }
  99. }
  100. #endif // __DATA_SOURCE_SQLITE3_H
  101. // Local Variables:
  102. // mode: c++
  103. // End: