]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- updated examples 1045/head
authorArvin Schnell <aschnell@suse.de>
Wed, 6 Aug 2025 07:30:21 +0000 (09:30 +0200)
committerArvin Schnell <aschnell@suse.de>
Wed, 6 Aug 2025 07:30:21 +0000 (09:30 +0200)
examples/c++-lib/CmpDirs.cc
examples/c++-lib/Create.cc
examples/c++-lib/CreateNumber.cc
examples/c++-lib/CreateTimeline.cc
examples/c++-lib/List.cc
examples/c++-lib/ListAll.cc

index 69519ea184faff7ac4208a7e376a281e8c8d85f4..76c9b7dde0480ea14af5319ea06cac51110566ac 100644 (file)
@@ -1,5 +1,5 @@
 
-#include <stdlib.h>
+#include <cstdlib>
 #include <iostream>
 
 #include <snapper/Compare.h>
index 7e3bfbf5bd32cfa180da045eb13bdad0265cc8fe..ccd343747b8cce82f8521fae0f928ee25c601bfd 100644 (file)
@@ -1,7 +1,5 @@
 
-#include <unistd.h>
-#include <sys/types.h>
-#include <stdlib.h>
+#include <cstdlib>
 #include <iostream>
 
 #include <snapper/Snapper.h>
@@ -9,10 +7,11 @@
 using namespace snapper;
 using namespace std;
 
+
 int
 main(int argc, char** argv)
 {
-    Snapper* sh = new Snapper("root", "/");
+    Snapper snapper("root", "/");
 
     SCD scd;
     scd.uid = getuid();
@@ -21,9 +20,7 @@ main(int argc, char** argv)
 
     Plugins::Report report;
 
-    sh->createSingleSnapshot(scd, report);
-
-    delete sh;
+    snapper.createSingleSnapshot(scd, report);
 
     exit(EXIT_SUCCESS);
 }
index a8149f2f86dd2f000fe3dbccd5f54deb4d99703f..b36754105490baa074d28cea2e5e84f2634e9ee0 100644 (file)
@@ -1,7 +1,5 @@
 
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
+#include <cstdlib>
 #include <vector>
 #include <iostream>
 
index b5d3a753efcf8c9c1f7cae56864b10cb387d3268..5424a9e130afdee9f8ba2dff2ee225a1bc6aefa1 100644 (file)
@@ -1,7 +1,5 @@
 
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
+#include <cstdlib>
 #include <vector>
 #include <iostream>
 
index 0272d74757d9e6728db70792fa9e50a2e33798fa..0c0f2755815e16a8fc107a8596a750f3b6fd847b 100644 (file)
@@ -1,5 +1,5 @@
 
-#include <stdlib.h>
+#include <cstdlib>
 #include <iostream>
 
 #include <snapper/Snapper.h>
@@ -7,18 +7,16 @@
 using namespace snapper;
 using namespace std;
 
+
 int
 main(int argc, char** argv)
 {
-    Snapper* sh = new Snapper("root", "/");
+    Snapper snapper("root", "/");
 
-    const Snapshots& snapshots = sh->getSnapshots();
-    for (Snapshots::const_iterator it = snapshots.begin(); it != snapshots.end(); ++it)
-    {
-       cout << *it << endl;
-    }
+    const Snapshots& snapshots = snapper.getSnapshots();
 
-    delete sh;
+    for (const Snapshot& snapshot : snapshots)
+       cout << snapshot << '\n';
 
     exit(EXIT_SUCCESS);
 }
index 8ee8fdad74c4f003b52d96b080f635c401b885fe..0f19b09e53bf986fe595d706d19bfc6be55c2c05 100644 (file)
@@ -1,28 +1,27 @@
 
-#include <stdlib.h>
+#include <cstdlib>
 #include <iostream>
+#include <memory>
 
 #include <snapper/Snapper.h>
 
 using namespace snapper;
 using namespace std;
 
+
 int
 main(int argc, char** argv)
 {
     list<ConfigInfo> config_infos = Snapper::getConfigs("/");
 
-    list<Snapper*> sh;
-
-    for (list<ConfigInfo>::const_iterator it = config_infos.begin(); it != config_infos.end(); ++it)
-       sh.push_back(new Snapper(it->get_config_name(), "/"));
+    list<unique_ptr<Snapper>> snappers;
 
-    for (list<Snapper*>::const_iterator it = sh.begin(); it != sh.end(); ++it)
-       cout << (*it)->configName() << " " << (*it)->subvolumeDir() << " "
-            << (*it)->getSnapshots().size() << endl;
+    for (const ConfigInfo& config_info : config_infos)
+       snappers.push_back(make_unique<Snapper>(config_info.get_config_name(), "/"));
 
-    for (list<Snapper*>::const_iterator it = sh.begin(); it != sh.end(); ++it)
-       delete *it;
+    for (const unique_ptr<Snapper>& snapper : snappers)
+       cout << snapper->configName() << " " << snapper->subvolumeDir() << " "
+            << snapper->getSnapshots().size() << endl;
 
     exit(EXIT_SUCCESS);
 }