std::shared_ptr
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Dec 2020 13:11:13 +0000 (14:11 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 5 Jan 2021 01:09:49 +0000 (02:09 +0100)
13 files changed:
cscript
src/dcp_reader.cc
src/reader_factory.cc
src/reader_factory.h
src/stl_binary_reader.cc
src/stl_binary_reader.h
src/util.cc
src/util.h
src/xml.h
test/dcp_reader_test.cc
test/stl_binary_reader_test.cc
tools/dumpsubs.cc
wscript

diff --git a/cscript b/cscript
index 367bebe57434f07d8846fd38c4d18d963a2c9981..a420b98a35912da28d9ebd3d6cb50bc7b338ceba 100644 (file)
--- a/cscript
+++ b/cscript
@@ -22,8 +22,8 @@ import os
 option_defaults = { 'force-cpp11': False }
 
 def dependencies(target, options):
-    libdcp =  ('libdcp', 'c6665c1', { 'force-cpp11': options['force-cpp11'] })
-    libcxml = ('libcxml', 'c333199', { 'force-cpp11': options['force-cpp11'] })
+    libdcp =  ('libdcp', '0f1034f')
+    libcxml = ('libcxml', 'c336f86')
     return (('asdcplib', 'carl'), libcxml, libdcp)
 
 def build(target, options):
@@ -37,20 +37,6 @@ def build(target, options):
     if target.platform == 'windows':
         cmd += ' --target-windows --disable-tests'
 
-    # Centos 7 ships with glibmm 2.50.0 which requires C++11
-    # but its compiler (gcc 4.8.5) defaults to C++97.  Go figure.
-    # I worry that this will cause ABI problems but I don't have
-    # a better solution.  Mageia 6 pulls the same stunt except it's
-    # libxml++ that requires C++11
-    force_cpp11 = False
-    if target.platform == 'linux':
-        if target.distro == 'centos' and target.version == '7':
-            force_cpp11 = True
-        if target.distro == 'mageia' and target.version == '6':
-            force_cpp11 = True
-    if force_cpp11 or options['force-cpp11']:
-        cmd += ' --force-cpp11'
-
     target.command(cmd)
     target.command('./waf build install')
 
index a3ee8e54753e568d87a2c47343de1680abd7e1a7..5784ad0fb52c4f23409865ecf863ff4c44ef0669 100644 (file)
@@ -30,9 +30,9 @@ using std::list;
 using std::cout;
 using std::string;
 using std::exception;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
 using namespace sub;
 
 static Time
index 759abff53ca898befc44523a2b6747ffbb689e51..fb717eac703ed1b475e06639d7afcfec11d7fb2c 100644 (file)
@@ -30,7 +30,7 @@
 using std::string;
 using std::ifstream;
 using boost::algorithm::ends_with;
-using boost::shared_ptr;
+using std::shared_ptr;
 using namespace sub;
 
 shared_ptr<Reader>
index e7c349bd629c6f33138242ce750724da5bb14539..e519468888354092d23a48f1b9fd040809a2ce04 100644 (file)
 
 */
 
-#include <boost/shared_ptr.hpp>
+#include <memory>
 #include <boost/filesystem.hpp>
 
 namespace sub {
 
 class Reader;
 
-extern boost::shared_ptr<Reader>
+extern std::shared_ptr<Reader>
 reader_factory (boost::filesystem::path);
 
 }
index 467830c3758169580e27c4cf03e5adb5c8f0b5e9..f441aec09a89a9f68d8ae5598e07c3219af950e9 100644 (file)
@@ -36,7 +36,7 @@ using boost::lexical_cast;
 using boost::algorithm::replace_all;
 using boost::is_any_of;
 using boost::locale::conv::utf_to_utf;
-using boost::shared_ptr;
+using std::shared_ptr;
 using namespace sub;
 
 namespace sub {
index fd85a3c95bdf63e55ddb1f8d7a6f32bd3c01559c..94d68b36686f3b5629ef86d1386ec42563ad04b8 100644 (file)
@@ -70,7 +70,7 @@ public:
        std::string editor_contact_details;
 
 private:
-       void read (boost::shared_ptr<InputReader> reader);
+       void read (std::shared_ptr<InputReader> reader);
 
        STLBinaryTables _tables;
 };
index 89af13fb0d33dd8820e338ebc9ec38b8d2f61d9c..c34737595070e90b63afb27769891cb4f541cbb4 100644 (file)
@@ -21,7 +21,7 @@
 #include "reader.h"
 #include "subtitle.h"
 #include "collect.h"
-#include <boost/shared_ptr.hpp>
+#include <memory>
 #include <string>
 #include <iostream>
 #include <cstdio>
@@ -33,7 +33,7 @@ using std::ostream;
 using std::map;
 using std::list;
 using boost::optional;
-using boost::shared_ptr;
+using std::shared_ptr;
 using namespace sub;
 
 /** @param s A string.
index fbf0fa6ed529a6fa85a44f139809f0608751902e..28da387f2ba8327c5da4ee6be4171baf9cf70617 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
+#include <memory>
 #include <string>
 
 #define LIBSUB_UNUSED(x) (void)(x)
@@ -35,6 +35,6 @@ extern bool empty_or_white_space (std::string s);
 extern void remove_unicode_bom (boost::optional<std::string>& line);
 extern boost::optional<std::string> get_line_file (FILE* f);
 extern boost::optional<std::string> get_line_string (std::string* s);
-extern void dump (boost::shared_ptr<const Reader> read, std::ostream& os);
+extern void dump (std::shared_ptr<const Reader> read, std::ostream& os);
 
 }
index d07188fd448a9273ff24b3a509e03e7383276f2a..bf1477b4edea1c3b0275bb4d976479b4535490f1 100644 (file)
--- a/src/xml.h
+++ b/src/xml.h
@@ -31,61 +31,61 @@ namespace sub
 {
 
 template <class T>
-boost::shared_ptr<T>
+std::shared_ptr<T>
 optional_type_child (cxml::Node const & node, std::string name)
 {
-       std::list<boost::shared_ptr<cxml::Node> > n = node.node_children (name);
+       std::list<std::shared_ptr<cxml::Node> > n = node.node_children (name);
        if (n.size() > 1) {
                throw XMLError ("duplicate XML tag");
        } else if (n.empty ()) {
-               return boost::shared_ptr<T> ();
+               return std::shared_ptr<T> ();
        }
 
-       return boost::shared_ptr<T> (new T (n.front ()));
+       return std::shared_ptr<T> (new T (n.front ()));
 }
 
 template <class T>
-boost::shared_ptr<T> type_child (boost::shared_ptr<const cxml::Node> node, std::string name) {
-       return boost::shared_ptr<T> (new T (node->node_child (name)));
+std::shared_ptr<T> type_child (std::shared_ptr<const cxml::Node> node, std::string name) {
+       return std::shared_ptr<T> (new T (node->node_child (name)));
 }
 
 template <class T>
-boost::shared_ptr<T>
-optional_type_child (boost::shared_ptr<const cxml::Node> node, std::string name)
+std::shared_ptr<T>
+optional_type_child (std::shared_ptr<const cxml::Node> node, std::string name)
 {
        return optional_type_child<T> (*node.get(), name);
 }
 
 template <class T>
-std::list<boost::shared_ptr<T> >
+std::list<std::shared_ptr<T> >
 type_children (cxml::Node const & node, std::string name)
 {
-       std::list<boost::shared_ptr<cxml::Node> > n = node.node_children (name);
-        std::list<boost::shared_ptr<T> > r;
-        for (typename std::list<boost::shared_ptr<cxml::Node> >::iterator i = n.begin(); i != n.end(); ++i) {
-               r.push_back (boost::shared_ptr<T> (new T (*i)));
+       std::list<std::shared_ptr<cxml::Node> > n = node.node_children (name);
+        std::list<std::shared_ptr<T> > r;
+        for (typename std::list<std::shared_ptr<cxml::Node> >::iterator i = n.begin(); i != n.end(); ++i) {
+               r.push_back (std::shared_ptr<T> (new T (*i)));
        }
        return r;
 }
 
 template <class T>
-std::list<boost::shared_ptr<T> >
-type_children (boost::shared_ptr<const cxml::Node> node, std::string name)
+std::list<std::shared_ptr<T> >
+type_children (std::shared_ptr<const cxml::Node> node, std::string name)
 {
        return type_children<T> (*node.get(), name);
 }
 
 template <class T>
-std::list<boost::shared_ptr<T> >
+std::list<std::shared_ptr<T> >
 type_grand_children (cxml::Node const & node, std::string name, std::string sub)
 {
-       boost::shared_ptr<const cxml::Node> p = node.node_child (name);
+       std::shared_ptr<const cxml::Node> p = node.node_child (name);
        return type_children<T> (p, sub);
 }
 
 template <class T>
-std::list<boost::shared_ptr<T> >
-type_grand_children (boost::shared_ptr<const cxml::Node> node, std::string name, std::string sub)
+std::list<std::shared_ptr<T> >
+type_grand_children (std::shared_ptr<const cxml::Node> node, std::string name, std::string sub)
 {
        return type_grand_children<T> (*node.get(), name, sub);
 }
index 57d3d6616df26cc209489157bd06c8c37cfe3769..e6a53e6a3c05814c62f8a5787ed20d0cad25be9f 100644 (file)
@@ -23,7 +23,7 @@
 #include <boost/optional/optional_io.hpp>
 
 using std::list;
-using boost::shared_ptr;
+using std::shared_ptr;
 
 /* Test reading of a DCP XML file */
 BOOST_AUTO_TEST_CASE (dcp_reader_test1)
index 3dcddb2dc7103bb8b0d1ebaa27e0ebcb6c99dd73..bad4bc43eda493c49f31083712f5fa299e3c4dac 100644 (file)
@@ -27,7 +27,7 @@
 using std::list;
 using std::ifstream;
 using std::ofstream;
-using boost::shared_ptr;
+using std::shared_ptr;
 
 /* Test reading of a binary STL file */
 BOOST_AUTO_TEST_CASE (stl_binary_reader_test1)
index de1f13ce81bb2eae289d5bd6b2e48c03f43dcbb3..94470e8e958ac363491714a871e82f56782939a2 100644 (file)
@@ -31,7 +31,7 @@ using std::cerr;
 using std::cout;
 using std::map;
 using std::list;
-using boost::shared_ptr;
+using std::shared_ptr;
 using namespace sub;
 
 static void
diff --git a/wscript b/wscript
index c5b8019644eab443b7bd1acb5ef7354927dfe0a3..dbc8411555075953f02d98afa91bc2ca9f63afd6 100644 (file)
--- a/wscript
+++ b/wscript
@@ -78,14 +78,11 @@ def options(opt):
     opt.add_option('--static', action='store_true', default=False, help='build libsub statically and link statically to cxml and dcp')
     opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to make a Windows package')
     opt.add_option('--disable-tests', action='store_true', default=False, help='disable building of tests')
-    opt.add_option('--force-cpp11', action='store_true', default=False, help='force use of C++11')
 
 def configure(conf):
     conf.load('compiler_cxx')
     conf.load('clang_compilation_database', tooldir=['waf-tools'])
-    conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
-    if conf.options.force_cpp11:
-        conf.env.append_value('CXXFLAGS', ['-std=c++11', '-DBOOST_NO_CXX11_SCOPED_ENUMS'])
+    conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS', '-std=c++11', '-DBOOST_NO_CXX11_SCOPED_ENUMS'])
     conf.env.append_value('CXXFLAGS', ['-DLIBSUB_VERSION="%s"' % VERSION])
 
     conf.env.ENABLE_DEBUG = conf.options.enable_debug