Introduce Denial-of-Existence (DoE) for Nack response.

Note this commit changes how names are stored in the database, compliant
to the canonical order.

Change-Id: I9857aaefc1f7da08ff53eff43c8f8c8bd5443953
Refs: #4152
diff --git a/src/daemon/db-mgr.hpp b/src/daemon/db-mgr.hpp
index 04b9672..ff0066e 100644
--- a/src/daemon/db-mgr.hpp
+++ b/src/daemon/db-mgr.hpp
@@ -166,6 +166,20 @@
   find(Rrset& rrset);
 
   /**
+   * @brief get the data from db according to `m_zone`, `m_label`, `m_type`.
+   *
+   * The lower bound rrset is the largest label that is less than rrset's label
+   * If record exists, `m_ttl`, `m_version` and `m_data` is set
+   *
+   * @pre m_rrset.getZone().getId() > 0
+   * @post whatever the previous id is,
+   *       m_rrset.getId() > 0 if record exists, otherwise m_rrset.getId() == 0
+   * @return true if the record exist
+   */
+  bool
+  findLowerBound(Rrset& rrset);
+
+  /**
    * @brief get all the rrsets which is stored at given zone
    * @throw RrsetError() if zone does not exist in the database
    * @note if zone.getId() == 0, the function setId for the zone automatically
@@ -183,6 +197,13 @@
   remove(Rrset& rrset);
 
   /**
+   * @brief remove all records of a specific type in a zone
+   */
+  void
+  removeRrsetsOfZoneByType(Zone& zone,
+                           const name::Component& type);
+
+  /**
    * @brief replace ttl, version, and Data with new values
    * @pre m_rrset.getId() > 0
    */
@@ -199,6 +220,19 @@
   }
 
 private:
+  /**
+   * @brief Save @p name to the database in the internal sortable format
+   *
+   * If @p name is not preserved until @p stmt is executed, @p isStatic must be
+   * set to `false`.
+   */
+  void
+  saveName(const Name& name, sqlite3_stmt* stmt, int iCol, bool isStatic = true);
+
+  Name
+  restoreName(sqlite3_stmt* stmt, int iCol);
+
+private:
   std::string m_dbFile;
   sqlite3* m_conn;
 };