On Tue, 2018-02-13 at 16:50 +0100, Olivier Mascia wrote:
> I currently simply do a replace all on each subversion update. I'm
> fine with that. Time passing by, some others might become tired of
> it.

        Hi,
I guess there's not much interest in your issue, because C++17 is too
new. You can always use older C++ and it'll be fine.
The other reason is that its too late now, it's not a good idea to
change the sources in such way just before the release.

Nonetheless, I attached one possible way to deal with it, but it also
changes one public header, one public function, which is bad. The API
might be changed to not expose this, because any library user would end
in the same mess.

I'm not going to commit this to the sources, not now, neither later.
I'll keep the decision (and the API change) to others.

As PoDoFo has opened issue tracker in SourceForge now, maybe you'd open
a request there, thus this doesn't get forgotten.
        Bye,
        zyx
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 1887)
+++ CMakeLists.txt	(working copy)
@@ -20,6 +20,7 @@ SET(PODOFO_LIBVERSION "${PODOFO_SOVERSIO
 #
 # Main includes
 #
+INCLUDE(CheckCXXSourceCompiles)
 INCLUDE(CheckIncludeFile)
 INCLUDE(CheckLibraryExists)
 INCLUDE(TestBigEndian)
@@ -92,6 +93,14 @@ ENDIF(WANT_LIB64)
 ENDIF(DEFINED LIB_SUFFIX)
 MESSAGE("Will install libraries to ${CMAKE_INSTALL_PREFIX}/${LIBDIRNAME}")
 
+CHECK_CXX_SOURCE_COMPILES("#include <memory>
+			class Cls {
+			public:
+			Cls() {}
+			~Cls() {}
+			};
+			int main(void) { std::unique_ptr<Cls> cls; return 0; }" PODOFO_HAVE_UNIQUE_PTR)
+
 # Some headers that tend to vary a bit
 CHECK_INCLUDE_FILE("strings.h" PODOFO_HAVE_STRINGS_H) 
 CHECK_INCLUDE_FILE("arpa/inet.h" PODOFO_HAVE_ARPA_INET_H) 
Index: podofo_config.h.in
===================================================================
--- podofo_config.h.in	(revision 1887)
+++ podofo_config.h.in	(working copy)
@@ -16,6 +16,7 @@
 #cmakedefine PODOFO_MULTI_THREAD
 
 /* somewhat platform-specific headers */
+#cmakedefine PODOFO_HAVE_UNIQUE_PTR 1
 #cmakedefine PODOFO_HAVE_STRINGS_H 1
 #cmakedefine PODOFO_HAVE_ARPA_INET_H 1
 #cmakedefine PODOFO_HAVE_WINSOCK2_H 1
Index: src/base/PdfCompilerCompat.h
===================================================================
--- src/base/PdfCompilerCompat.h	(revision 1887)
+++ src/base/PdfCompilerCompat.h	(working copy)
@@ -113,6 +113,13 @@
 #define NOMINMAX
 #endif
 
+// prefer std::unique_ptr over std::auto_ptr
+#ifdef PODOFO_HAVE_UNIQUE_PTR
+#define PODOFO_UNIQUEU_PTR std::unique_ptr
+#else
+#define PODOFO_UNIQUEU_PTR std::auto_ptr
+#endif
+
 // Integer types - fixed size types guaranteed to work anywhere
 // because we detect the right underlying type name to use with
 // CMake. Use typedefs rather than macros for saner error messages
Index: src/base/PdfFilter.cpp
===================================================================
--- src/base/PdfFilter.cpp	(revision 1887)
+++ src/base/PdfFilter.cpp	(working copy)
@@ -131,7 +131,7 @@ class PdfFilteredEncodeStream : public P
 
 private:
     PdfOutputStream*         m_pOutputStream;
-    std::auto_ptr<PdfFilter> m_filter;
+    PODOFO_UNIQUEU_PTR<PdfFilter> m_filter;
 };
 
 /** Create a filter that is a PdfOutputStream.
@@ -206,7 +206,7 @@ class PdfFilteredDecodeStream : public P
 
 private:
     PdfOutputStream*         m_pOutputStream;
-    std::auto_ptr<PdfFilter> m_filter;
+    PODOFO_UNIQUEU_PTR<PdfFilter> m_filter;
     bool                     m_bFilterFailed;
 };
 
@@ -264,7 +264,7 @@ PdfFilterFactory::PdfFilterFactory()
 {
 }
 
-std::auto_ptr<PdfFilter> PdfFilterFactory::Create( const EPdfFilter eFilter ) 
+PODOFO_UNIQUEU_PTR<PdfFilter> PdfFilterFactory::Create( const EPdfFilter eFilter ) 
 {
     PdfFilter* pFilter = NULL;
     switch( eFilter )
@@ -316,7 +316,7 @@ std::auto_ptr<PdfFilter> PdfFilterFactor
             break;
     }
 
-    return std::auto_ptr<PdfFilter>(pFilter);
+    return PODOFO_UNIQUEU_PTR<PdfFilter>(pFilter);
 }
 
 PdfOutputStream* PdfFilterFactory::CreateEncodeStream( const TVecFilters & filters, PdfOutputStream* pStream ) 
Index: src/base/PdfFilter.h
===================================================================
--- src/base/PdfFilter.h	(revision 1887)
+++ src/base/PdfFilter.h	(working copy)
@@ -454,7 +454,7 @@ class PODOFO_API PdfFilterFactory {
  public:
     /** Create a filter from an enum.
      *
-     *  Ownership is transferred to the caller, who should let the auto_ptr
+     *  Ownership is transferred to the caller, who should let the auto_ptr/unique_ptr
      *  the filter is returned in take care of freeing it when they're done
      *  with it.
      *
@@ -463,7 +463,7 @@ class PODOFO_API PdfFilterFactory {
      *  \returns a new PdfFilter allocated using new, or NULL if no
      *           filter is available for this type.
      */
-    static std::auto_ptr<PdfFilter> Create( const EPdfFilter eFilter );
+    static PODOFO_UNIQUEU_PTR<PdfFilter> Create( const EPdfFilter eFilter );
 
     /** Create a PdfOutputStream that applies a list of filters 
      *  on all data written to it.
Index: src/base/PdfMemStream.cpp
===================================================================
--- src/base/PdfMemStream.cpp	(revision 1887)
+++ src/base/PdfMemStream.cpp	(working copy)
@@ -245,7 +245,7 @@ void PdfMemStream::FlateCompressStreamDa
     if( !m_lLength )
         return;
 
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_FlateDecode );
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_FlateDecode );
     if( pFilter.get() )
     {
         pFilter->Encode( m_buffer.GetBuffer(), m_buffer.GetSize(), &pBuffer, &lLen );
Index: src/base/PdfStream.cpp
===================================================================
--- src/base/PdfStream.cpp	(revision 1887)
+++ src/base/PdfStream.cpp	(working copy)
@@ -91,9 +91,9 @@ void PdfStream::GetFilteredCopy( char**
     PdfMemoryOutputStream  stream;
     if( vecFilters.size() )
     {
-        // Use std::auto_ptr so that pDecodeStream is deleted 
+        // Use PODOFO_UNIQUEU_PTR so that pDecodeStream is deleted 
         // even in the case of an exception 
-        std::auto_ptr<PdfOutputStream> pDecodeStream( PdfFilterFactory::CreateDecodeStream( vecFilters, &stream, 
+        PODOFO_UNIQUEU_PTR<PdfOutputStream> pDecodeStream( PdfFilterFactory::CreateDecodeStream( vecFilters, &stream, 
                                                                                             m_pParent ? 
                                                                                             &(m_pParent->GetDictionary()) : NULL  ) );
 
Index: src/base/PdfString.cpp
===================================================================
--- src/base/PdfString.cpp	(revision 1887)
+++ src/base/PdfString.cpp	(working copy)
@@ -673,7 +673,7 @@ PdfString PdfString::HexEncode() const
         return *this;
     else
     {
-        std::auto_ptr<PdfFilter> pFilter;
+        PODOFO_UNIQUEU_PTR<PdfFilter> pFilter;
 
         pdf_long                  lLen  = (m_buffer.GetSize() - 1) << 1;
         PdfString             str;
@@ -702,7 +702,7 @@ PdfString PdfString::HexDecode() const
         return *this;
     else
     {
-        std::auto_ptr<PdfFilter> pFilter;
+        PODOFO_UNIQUEU_PTR<PdfFilter> pFilter;
 
         pdf_long                  lLen = m_buffer.GetSize() >> 1;
         PdfString             str;
Index: src/doc/PdfFont.cpp
===================================================================
--- src/doc/PdfFont.cpp	(revision 1887)
+++ src/doc/PdfFont.cpp	(working copy)
@@ -145,7 +145,7 @@ void PdfFont::WriteStringToStream( const
     pdf_long  lLen    = 0;
     char* pBuffer = NULL;
 
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );    
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );    
     pFilter->Encode( buffer.GetBuffer(), buffer.GetSize(), &pBuffer, &lLen );
 
     pStream->Append( "<", 1 );
Index: src/doc/PdfPainter.cpp
===================================================================
--- src/doc/PdfPainter.cpp	(revision 1887)
+++ src/doc/PdfPainter.cpp	(working copy)
@@ -827,7 +827,7 @@ void PdfPainter::DrawText( double dX, do
 
     /*
     char* pBuffer;
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
     pFilter->Encode( sString.GetString(), sString.GetLength(), &pBuffer, &lLen );
 
     m_pCanvas->Append( pBuffer, lLen );
Index: test/CreationTest/CreationTest.cpp
===================================================================
--- test/CreationTest/CreationTest.cpp	(revision 1887)
+++ test/CreationTest/CreationTest.cpp	(working copy)
@@ -37,7 +37,7 @@ void WriteStringToStream( const PdfStrin
     pdf_long  lLen    = 0;
     char* pBuffer = NULL;
 
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
     pFilter->Encode( buffer.GetBuffer(), buffer.GetSize(), &pBuffer, &lLen );
 
     oss << "<";
Index: test/FilterTest/FilterTest.cpp
===================================================================
--- test/FilterTest/FilterTest.cpp	(revision 1887)
+++ test/FilterTest/FilterTest.cpp	(working copy)
@@ -57,7 +57,7 @@ void test_filter( EPdfFilter eFilter, co
     pdf_long   lEncoded;
     pdf_long   lDecoded;
 
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( eFilter );
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( eFilter );
     if( !pFilter.get() )
     {
         printf("!!! Filter %i not implemented.\n", eFilter);
@@ -256,7 +256,7 @@ int main()
     char*    pLargeBuffer2 = static_cast<char*>(malloc( strlen(pszInputAscii85Lzw) * 6 ));
 
     try {
-        std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCII85Decode );
+        PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCII85Decode );
         pFilter->Decode( pszInputAscii85Lzw, strlen(pszInputAscii85Lzw),
                          &pLargeBuffer1, &lLargeBufer1 );
         pFilter->Encode( pLargeBuffer1, lLargeBufer1,
Index: test/VariantTest/VariantTest.cpp
===================================================================
--- test/VariantTest/VariantTest.cpp	(revision 1887)
+++ test/VariantTest/VariantTest.cpp	(working copy)
@@ -124,7 +124,7 @@ int main()
     printf("This test tests the PdfVariant class.\n");
     printf("---\n");
 
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
 
     // testing strings
     TEST_SAFE_OP( Test( "(Hallo Welt!)", ePdfDataType_String ) );
Index: test/unit/FilterTest.cpp
===================================================================
--- test/unit/FilterTest.cpp	(revision 1887)
+++ test/unit/FilterTest.cpp	(working copy)
@@ -59,7 +59,7 @@ void FilterTest::TestFilter( EPdfFilter
     pdf_long   lEncoded;
     pdf_long   lDecoded;
    
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( eFilter );
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( eFilter );
     if( !pFilter.get() )
     {
         printf("!!! Filter %i not implemented.\n", eFilter);
@@ -123,7 +123,7 @@ void FilterTest::testFilters()
 
 void FilterTest::testCCITT()
 {
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_CCITTFaxDecode );
+    PODOFO_UNIQUEU_PTR<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_CCITTFaxDecode );
     if( !pFilter.get() )
     {
         printf("!!! ePdfFilter_CCITTFaxDecode not implemented skipping test!\n");
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to