sqlite3_datasrc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 <datasrc/data_source.h>
  20. namespace isc {
  21. namespace dns {
  22. class Name;
  23. class RRClass;
  24. class RRType;
  25. class RRsetList;
  26. }
  27. namespace datasrc {
  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(DataSrcMatch& match) const;
  50. Result findRRset(const isc::dns::Name& qname,
  51. const isc::dns::RRClass& qclass,
  52. const isc::dns::RRType& qtype,
  53. isc::dns::RRsetList& target,
  54. uint32_t& flags,
  55. const isc::dns::Name* zonename) const;
  56. Result findExactRRset(const isc::dns::Name& qname,
  57. const isc::dns::RRClass& qclass,
  58. const isc::dns::RRType& qtype,
  59. isc::dns::RRsetList& target,
  60. uint32_t& flags,
  61. const isc::dns::Name* zonename) const;
  62. Result findAddrs(const isc::dns::Name& qname,
  63. const isc::dns::RRClass& qclass,
  64. isc::dns::RRsetList& target,
  65. uint32_t& flags,
  66. const isc::dns::Name* zonename) const;
  67. Result findReferral(const isc::dns::Name& qname,
  68. const isc::dns::RRClass& qclass,
  69. isc::dns::RRsetList& target,
  70. uint32_t& flags,
  71. const isc::dns::Name* zonename) const;
  72. DataSrc::Result findPreviousName(const isc::dns::Name& qname,
  73. isc::dns::Name& target,
  74. const isc::dns::Name* zonename) const;
  75. Result findCoveringNSEC3(const isc::dns::Name& zonename,
  76. std::string& hash,
  77. isc::dns::RRsetList& target) const;
  78. Result init() { return init(isc::data::ElementPtr()); };
  79. Result init(const isc::data::ElementPtr config);
  80. Result close();
  81. private:
  82. enum Mode {
  83. NORMAL,
  84. ADDRESS,
  85. DELEGATION
  86. };
  87. void open(const std::string& name);
  88. int hasExactZone(const char *name) const;
  89. int findRecords(const isc::dns::Name& name, const isc::dns::RRType& rdtype,
  90. isc::dns::RRsetList& target, const isc::dns::Name* zonename,
  91. const Mode mode, uint32_t& flags) const;
  92. int findClosest(const isc::dns::Name& name, unsigned int* position) const;
  93. private:
  94. Sqlite3Parameters* dbparameters;
  95. };
  96. }
  97. }
  98. #endif // __DATA_SOURCE_SQLITE3_H
  99. // Local Variables:
  100. // mode: c++
  101. // End: