Pārlūkot izejas kodu

add new ClearAll

Michael Vogt 13 gadi atpakaļ
vecāks
revīzija
d016834e39

+ 11 - 0
apt-pkg/contrib/configuration.cc

@@ -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				/*{{{*/
 // Configuration::Clear - Clear an entire tree				/*{{{*/

+ 1 - 0
apt-pkg/contrib/configuration.h

@@ -94,6 +94,7 @@ class Configuration
 
 
    // clear a whole tree
    // clear a whole tree
    void Clear(const std::string &Name);
    void Clear(const std::string &Name);
+   void ClearAll();
 
 
    // remove a certain value from a list (e.g. the list of "APT::Keep-Fds")
    // 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);
    void Clear(std::string const &List, std::string const &Value);

+ 4 - 0
test/libapt/configuration_test.cc

@@ -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::State"), "/srv/sid/var/lib/apt");
 	equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
 	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;
 	//FIXME: Test for configuration file parsing;
 	// currently only integration/ tests test them implicitly
 	// currently only integration/ tests test them implicitly