sqlite3_datasrc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #ifndef __DATA_SOURCE_SQLITE3_H
  15. #define __DATA_SOURCE_SQLITE3_H
  16. #include <string>
  17. #include <exceptions/exceptions.h>
  18. #include <datasrc/data_source.h>
  19. namespace isc {
  20. namespace dns {
  21. class Name;
  22. class RRClass;
  23. class RRType;
  24. class RRsetList;
  25. }
  26. namespace datasrc {
  27. class Query;
  28. struct Sqlite3Parameters;
  29. class Sqlite3Error : public Exception {
  30. public:
  31. Sqlite3Error(const char* file, size_t line, const char* what) :
  32. isc::Exception(file, line, what) {}
  33. };
  34. class Sqlite3DataSrc : public DataSrc {
  35. ///
  36. /// \name Constructors, Assignment Operator and Destructor.
  37. ///
  38. /// Note: The copy constructor and the assignment operator are intentionally
  39. /// defined as private.
  40. //@{
  41. private:
  42. Sqlite3DataSrc(const Sqlite3DataSrc& source);
  43. Sqlite3DataSrc& operator=(const Sqlite3DataSrc& source);
  44. public:
  45. Sqlite3DataSrc();
  46. ~Sqlite3DataSrc();
  47. //@}
  48. void findClosestEnclosure(DataSrcMatch& match) const;
  49. Result findRRset(const isc::dns::Name& qname,
  50. const isc::dns::RRClass& qclass,
  51. const isc::dns::RRType& qtype,
  52. isc::dns::RRsetList& target,
  53. uint32_t& flags,
  54. const isc::dns::Name* zonename) const;
  55. Result findExactRRset(const isc::dns::Name& qname,
  56. const isc::dns::RRClass& qclass,
  57. const isc::dns::RRType& qtype,
  58. isc::dns::RRsetList& target,
  59. uint32_t& flags,
  60. const isc::dns::Name* zonename) const;
  61. Result findAddrs(const isc::dns::Name& qname,
  62. const isc::dns::RRClass& qclass,
  63. isc::dns::RRsetList& target,
  64. uint32_t& flags,
  65. const isc::dns::Name* zonename) const;
  66. Result findReferral(const isc::dns::Name& qname,
  67. const isc::dns::RRClass& qclass,
  68. isc::dns::RRsetList& target,
  69. uint32_t& flags,
  70. const isc::dns::Name* zonename) const;
  71. DataSrc::Result findPreviousName(const isc::dns::Name& qname,
  72. isc::dns::Name& target,
  73. const isc::dns::Name* zonename) const;
  74. Result findCoveringNSEC3(const isc::dns::Name& zonename,
  75. std::string& hash,
  76. isc::dns::RRsetList& target) const;
  77. Result init() { return (init(isc::data::ElementPtr())); }
  78. Result init(const isc::data::ConstElementPtr config);
  79. Result close();
  80. private:
  81. enum Mode {
  82. NORMAL,
  83. ADDRESS,
  84. DELEGATION
  85. };
  86. void open(const std::string& name);
  87. int hasExactZone(const char *name) const;
  88. int findRecords(const isc::dns::Name& name, const isc::dns::RRType& rdtype,
  89. isc::dns::RRsetList& target, const isc::dns::Name* zonename,
  90. const Mode mode, uint32_t& flags) const;
  91. int findClosest(const isc::dns::Name& name, unsigned int* position) const;
  92. private:
  93. Sqlite3Parameters* dbparameters;
  94. };
  95. }
  96. }
  97. #endif // __DATA_SOURCE_SQLITE3_H
  98. // Local Variables:
  99. // mode: c++
  100. // End: