]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2377] Skeleton of the master loader
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Fri, 30 Nov 2012 15:22:45 +0000 (16:22 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Mon, 3 Dec 2012 10:19:49 +0000 (11:19 +0100)
src/lib/dns/master_loader.cc
src/lib/dns/master_loader.h
src/lib/dns/tests/master_loader_unittest.cc

index 9f3b7ea59d7d5f10ef131a1ac22669f925ee6a82..042e2e771517382ccc4ddc795e52f6b278f3b68b 100644 (file)
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <dns/master_loader.h>
+#include <dns/master_lexer.h>
+#include <dns/name.h>
+#include <dns/rrttl.h>
+#include <dns/rrclass.h>
+#include <dns/rrtype.h>
+#include <dns/rrset.h>
+
+using std::string;
 
 namespace isc {
 namespace dns {
@@ -35,13 +43,48 @@ public:
         lexer_.pushSource(master_file);
     }
 
+    // Get a string token. Handle it as error if it is not string.
+    const string getString() {
+        return (lexer_.getNextToken(MasterToken::QSTRING).getString());
+    }
+
     bool loadIncremental(size_t count_limit) {
         size_t count = 0;
         bool done = false;
-        do {
-            // Code goes here
-        } while (!done && (count_limit != 0 && ++count < count_limit));
-        // add remaining rrset that was being built (TODO)
+        // TODO: Replace getNextToken with the wrapper version
+        while (!done && (count < count_limit)) {
+            // Skip all EOLNs and finish on EOF
+            bool empty = true;
+            do {
+                const MasterToken& empty_token(lexer_.getNextToken());
+                if (empty_token.getType() == MasterToken::END_OF_FILE) {
+                    // TODO: Check if this is the last source, possibly pop
+                    return (true);
+                }
+                empty = empty_token.getType() == MasterToken::END_OF_LINE;
+            } while (empty);
+            // Return the last token, as it was not empty
+            lexer_.ungetToken();
+
+            const string name_string(getString());
+            // TODO $ handling
+            const Name name(name_string); // TODO: Origin
+            // TODO: Some more flexibility. We don't allow omitting anything yet
+
+            // The parameters
+            const RRTTL ttl(getString());
+            const RRClass rrclass(getString());
+            const RRType rrtype(getString());
+
+            // Create the RRset. We don't need the RRSIG, so we are good
+            // with the basic one
+            RRsetPtr rrset(new BasicRRset(name, rrclass, rrtype, ttl));
+
+            // TODO: Create the RData
+
+            // OK now, so give the RRset with single RR to the caller
+            add_callback_(rrset);
+        }
         return (false);
     }
 
index 31b04bf822adfbb95e4b2b3b8af3a36680b0fcc9..61ac7aff2fd877e3ec03fed9f9175bd624fe0347 100644 (file)
 #ifndef MASTER_LOADER_H
 #define MASTER_LOADER_H
 
-#include <dns/name.h>
-#include <dns/rrclass.h>
-#include <dns/master_lexer.h>
 #include <dns/master_loader_callbacks.h>
 
 namespace isc {
 namespace dns {
+
+class Name;
+class RRClass;
+
 class MasterLoader {
 public:
     enum Options {
index fa89bf0955dceec4b2850ea14e93d74b9f4205b6..688410ba7bcdd5253f851411a427bfb4122509c4 100644 (file)
@@ -16,6 +16,8 @@
 #include <dns/master_loader.h>
 #include <dns/rrtype.h>
 #include <dns/rrset.h>
+#include <dns/rrclass.h>
+#include <dns/name.h>
 
 #include <gtest/gtest.h>
 #include <boost/bind.hpp>