]> git.saurik.com Git - apt.git/commitdiff
add new ClearAll
authorMichael Vogt <michael.vogt@ubuntu.com>
Fri, 28 Sep 2012 12:43:39 +0000 (14:43 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Fri, 28 Sep 2012 12:43:39 +0000 (14:43 +0200)
apt-pkg/contrib/configuration.cc
apt-pkg/contrib/configuration.h
test/libapt/configuration_test.cc

index 36866a35ad2a85e846809f716faccf2d7c5b98b7..43533e5bb03b059f71ecbb8c7ac83470c0013d59 100644 (file)
@@ -403,6 +403,17 @@ void Configuration::Clear(string const &Name, string const &Value)
       }
    }
      
+}
+                                                                       /*}}}*/
+// Configuration::ClearAll - Clear everything                          /*{{{*/
+void Configuration::ClearAll()
+{
+   const Configuration::Item *Top = Tree(0);
+   while( Top != 0 )
+   {
+      Clear(Top->FullTag());
+      Top = Top->Next;
+   }
 }
                                                                        /*}}}*/
 // Configuration::Clear - Clear an entire tree                         /*{{{*/
index 4c2e750413852e32586b73410452d78bded66d04..181ef696b840dc275bc34004bec03bd4e3afa262 100644 (file)
@@ -94,6 +94,7 @@ class Configuration
 
    // clear a whole tree
    void Clear(const std::string &Name);
+   void ClearAll();
 
    // remove a certain value from a list (e.g. the list of "APT::Keep-Fds")
    void Clear(std::string const &List, std::string const &Value);
index 9a3e2c11865c1253b2ccde0afe847e9120d505ae..5ec48834a74400520158771d1a3c0af53ec89b34 100644 (file)
@@ -80,6 +80,10 @@ int main(int argc,const char *argv[]) {
        equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
        equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
 
+        Cnf.Set("Moo::Bar", "1");
+        Cnf.ClearAll();
+        equals(Cnf.Find("Moo::Bar"), "");
+
        //FIXME: Test for configuration file parsing;
        // currently only integration/ tests test them implicitly