[Liblas-commits] hg: return program_options as heap-allocated

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Aug 26 22:23:17 EDT 2010


changeset 0f3f66a3a126 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=0f3f66a3a126
summary: return program_options as heap-allocated

diffstat:

 apps/las2las2.cpp  |   9 ++++++---
 apps/las2oci.cpp   |  33 +++++++++++++++++----------------
 apps/laskernel.cpp |  12 ++++++------
 apps/laskernel.hpp |   4 ++--
 4 files changed, 31 insertions(+), 27 deletions(-)

diffs (171 lines):

diff -r 899f8743a42b -r 0f3f66a3a126 apps/las2las2.cpp
--- a/apps/las2las2.cpp	Thu Aug 26 21:11:08 2010 -0500
+++ b/apps/las2las2.cpp	Thu Aug 26 21:23:10 2010 -0500
@@ -217,8 +217,8 @@
     try {
 
         po::options_description file_options("las2las2 options");
-        po::options_description filtering_options = GetFilteringOptions();
-        po::options_description transform_options = GetTransformationOptions() ;
+        po::options_description* filtering_options = GetFilteringOptions();
+        po::options_description* transform_options = GetTransformationOptions() ;
 
         po::positional_options_description p;
         p.add("input", 1);
@@ -237,7 +237,7 @@
 
         po::variables_map vm;
         po::options_description options;
-        options.add(file_options).add(transform_options).add(filtering_options);
+        options.add(file_options).add(*transform_options).add(*filtering_options);
         po::store(po::command_line_parser(argc, argv).
           options(options).positional(p).run(), vm);
 
@@ -289,6 +289,9 @@
         if (!op) {
             return (1);
         }
+        
+        delete filtering_options;
+        delete transform_options;
     }
     catch(std::exception& e) {
         std::cerr << "error: " << e.what() << "\n";
diff -r 899f8743a42b -r 0f3f66a3a126 apps/las2oci.cpp
--- a/apps/las2oci.cpp	Thu Aug 26 21:11:08 2010 -0500
+++ b/apps/las2oci.cpp	Thu Aug 26 21:23:10 2010 -0500
@@ -611,13 +611,13 @@
     return data;
 }
 
-po::options_description GetFileOptions()
+po::options_description* GetFileOptions()
 {
-po::options_description file_options("las2oci options");
+po::options_description* file_options = new po::options_description("las2oci options");
 
 
 
-file_options.add_options()
+file_options->add_options()
     ("help,h", "produce help message")
     ("input,i", po::value< string >(), "input LAS file")
     ("connection,c", po::value< string >(), "OCI connection string")
@@ -647,10 +647,10 @@
 return file_options;
 }
 
-po::options_description GetHiddenOptions()
+po::options_description* GetHiddenOptions()
 {
-    po::options_description hidden_options("hidden options");
-hidden_options.add_options()
+    po::options_description* hidden_options = new po::options_description("hidden options");
+hidden_options->add_options()
     ("xmin", po::value< double >(), "global-extent minx value")
     ("ymin", po::value< double >(), "global-extent miny value")
     ("zmin", po::value< double >(), "global-extent minz value")
@@ -699,10 +699,7 @@
     
     liblas::Bounds<double> global_extent;
     
-    bool bSetExtents = false;
-    
-    int nCommitInterval = 100;
-    
+    bool bSetExtents = false;    
     
     bool verbose = false;
     bool debug = false;
@@ -714,10 +711,10 @@
 
     try {
 
-        po::options_description file_options = GetFileOptions();
-        po::options_description filtering_options = GetFilteringOptions();
-        po::options_description transform_options = GetTransformationOptions() ;
-        po::options_description hidden_options = GetHiddenOptions();
+        po::options_description* file_options = GetFileOptions();
+        po::options_description* filtering_options = GetFilteringOptions();
+        po::options_description* transform_options = GetTransformationOptions() ;
+        po::options_description* hidden_options = GetHiddenOptions();
         po::positional_options_description p;
         p.add("input", 1);
         p.add("connection", 1);
@@ -727,7 +724,7 @@
 
         po::variables_map vm;
         po::options_description options;
-        options.add(file_options).add(transform_options).add(filtering_options).add(hidden_options);
+        options.add(*file_options).add(*transform_options).add(*filtering_options).add(*hidden_options);
         po::store(po::command_line_parser(argc, argv).
         options(options).positional(p).run(), vm);
 
@@ -735,7 +732,7 @@
 
         if (vm.count("help")) 
         {
-            std::cout << GetInvocationHeader()<<file_options<<"\n"<<transform_options<<"\n"<<filtering_options<<"\n";
+            std::cout << GetInvocationHeader()<<*file_options<<"\n"<<*transform_options<<"\n"<<*filtering_options<<"\n";
             std::cout <<"\nFor more information, see the full documentation for las2oci at:\n";
             
             std::cout << " http://liblas.org/utilities/las2oci.html\n";
@@ -1256,6 +1253,10 @@
         delete reader2;
         delete istrm2;
         delete con;
+        delete filtering_options;
+        delete transform_options;
+        delete file_options;
+        delete hidden_options;
     }
     catch(std::exception& e) {
         std::cerr << "error: " << e.what() << "\n";
diff -r 899f8743a42b -r 0f3f66a3a126 apps/laskernel.cpp
--- a/apps/laskernel.cpp	Thu Aug 26 21:11:08 2010 -0500
+++ b/apps/laskernel.cpp	Thu Aug 26 21:23:10 2010 -0500
@@ -108,12 +108,12 @@
     return filter;
 }
 
-po::options_description GetFilteringOptions() 
+po::options_description* GetFilteringOptions() 
 {
 
-po::options_description filtering_options("Filtering options");
+po::options_description* filtering_options = new po::options_description("Filtering options");
 
-filtering_options.add_options()
+filtering_options->add_options()
     ("extent,e", po::value< string >(), "Extent window that points must fall within to keep.\nUse a comma-separated list, for example, \n  -e minx, miny, maxx, maxy\n  or \n  -e minx, miny, minz, maxx, maxy, maxz")
     ("thin,t", po::value<boost::uint32_t>()->default_value(0), "Simple decimation-style thinning.\nThin the file by removing every t'th point from the file.")
     ("last_return_only", po::value<bool>()->zero_tokens(), "Keep last returns (cannot be used with --first_return_only)")
@@ -135,11 +135,11 @@
 return filtering_options;    
 }
 
-po::options_description GetTransformationOptions() 
+po::options_description* GetTransformationOptions() 
 {
-    po::options_description transform_options("Transformation options");
+    po::options_description* transform_options= new po::options_description("Transformation options");
 
-    transform_options.add_options()
+    transform_options->add_options()
         ("a_srs", po::value< string >(), "Coordinate system to assign to input LAS file")
         ("t_srs", po::value< string >(), "Coordinate system to reproject output LAS file to.  Use --a_srs or verify that your input LAS file has a coordinate system according to lasinfo")   
         ("offset", po::value< string >(), "A comma-separated list of offsets to set on the output file: \n--offset 0,0,0 \n--offset  min,min,min")
diff -r 899f8743a42b -r 0f3f66a3a126 apps/laskernel.hpp
--- a/apps/laskernel.hpp	Thu Aug 26 21:11:08 2010 -0500
+++ b/apps/laskernel.hpp	Thu Aug 26 21:23:10 2010 -0500
@@ -78,8 +78,8 @@
 liblas::FilterI* MakeColorFilter(liblas::Color const& low, liblas::Color const& high, liblas::FilterI::FilterType ftype); 
 
 
-po::options_description GetFilteringOptions();
-po::options_description GetTransformationOptions();
+po::options_description* GetFilteringOptions();
+po::options_description* GetTransformationOptions();
 
 std::vector<liblas::FilterI*> GetFilters(po::variables_map vm, bool verbose);
 std::vector<liblas::TransformI*> GetTransforms(po::variables_map vm, bool verbose, liblas::Header& header);


More information about the Liblas-commits mailing list