mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Replace PointerHolder with std::shared_ptr in library sources only
(patrepl and cleanpatch are my own utilities) patrepl s/PointerHolder/std::shared_ptr/g {include,libqpdf}/qpdf/*.hh patrepl s/PointerHolder/std::shared_ptr/g libqpdf/*.cc patrepl s/make_pointer_holder/std::make_shared/g libqpdf/*.cc patrepl s/make_array_pointer_holder/QUtil::make_shared_array/g libqpdf/*.cc patrepl s,qpdf/std::shared_ptr,qpdf/PointerHolder, **/*.cc **/*.hh git restore include/qpdf/PointerHolder.hh cleanpatch ./format-code
This commit is contained in:
parent
ae819b5318
commit
a68703b07e
@ -75,7 +75,7 @@ class Buffer
|
||||
|
||||
void copy(Buffer const&);
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // BUFFER_HH
|
||||
|
@ -73,7 +73,7 @@ class BufferInputSource: public InputSource
|
||||
qpdf_offset_t max_offset;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDF_BUFFERINPUTSOURCE_HH
|
||||
|
@ -84,10 +84,10 @@ class ClosedFileInputSource: public InputSource
|
||||
|
||||
std::string filename;
|
||||
qpdf_offset_t offset;
|
||||
PointerHolder<FileInputSource> fis;
|
||||
std::shared_ptr<FileInputSource> fis;
|
||||
bool stay_open;
|
||||
};
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDF_CLOSEDFILEINPUTSOURCE_HH
|
||||
|
@ -71,7 +71,7 @@ class FileInputSource: public InputSource
|
||||
FILE* file;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDF_FILEINPUTSOURCE_HH
|
||||
|
@ -114,7 +114,7 @@ class QPDF_DLL_CLASS InputSource
|
||||
Members(Members const&);
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDF_INPUTSOURCE_HH
|
||||
|
@ -219,7 +219,7 @@ class JSON
|
||||
std::shared_ptr<JSON_value> value;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // JSON_HH
|
||||
|
@ -59,7 +59,7 @@ class Pl_Buffer: public Pipeline
|
||||
|
||||
// Same as getBuffer but wraps the result in a shared pointer.
|
||||
QPDF_DLL
|
||||
PointerHolder<Buffer> getBufferSharedPointer();
|
||||
std::shared_ptr<Buffer> getBufferSharedPointer();
|
||||
|
||||
// getMallocBuffer behaves in the same was as getBuffer except the
|
||||
// buffer is allocated with malloc(), making it suitable for use
|
||||
@ -84,11 +84,11 @@ class Pl_Buffer: public Pipeline
|
||||
Members(Members const&);
|
||||
|
||||
bool ready;
|
||||
PointerHolder<Buffer> data;
|
||||
std::shared_ptr<Buffer> data;
|
||||
size_t total_size;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_BUFFER_HH
|
||||
|
@ -63,7 +63,7 @@ class Pl_Concatenate: public Pipeline
|
||||
Members(Members const&);
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_CONCATENATE_HH
|
||||
|
@ -66,7 +66,7 @@ class Pl_Count: public Pipeline
|
||||
unsigned char last_char;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_COUNT_HH
|
||||
|
@ -106,7 +106,7 @@ class Pl_DCT: public Pipeline
|
||||
CompressConfig* config_callback;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_DCT_HH
|
||||
|
@ -56,7 +56,7 @@ class Pl_Discard: public Pipeline
|
||||
Members(Members const&);
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_DISCARD_HH
|
||||
|
@ -85,7 +85,7 @@ class Pl_Flate: public Pipeline
|
||||
std::function<void(char const*, int)> callback;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_FLATE_HH
|
||||
|
@ -76,7 +76,7 @@ class Pl_QPDFTokenizer: public Pipeline
|
||||
QPDFTokenizer tokenizer;
|
||||
Pl_Buffer buf;
|
||||
};
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_QPDFTOKENIZER_HH
|
||||
|
@ -64,7 +64,7 @@ class Pl_RunLength: public Pipeline
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_RUNLENGTH_HH
|
||||
|
@ -63,7 +63,7 @@ class Pl_StdioFile: public Pipeline
|
||||
FILE* file;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // PL_STDIOFILE_HH
|
||||
|
@ -108,7 +108,7 @@ class QPDF
|
||||
// InputSource and use this method.
|
||||
QPDF_DLL
|
||||
void
|
||||
processInputSource(PointerHolder<InputSource>, char const* password = 0);
|
||||
processInputSource(std::shared_ptr<InputSource>, char const* password = 0);
|
||||
|
||||
// Close or otherwise release the input source. Once this has been
|
||||
// called, no other methods of qpdf can be called safely except
|
||||
@ -714,7 +714,7 @@ class QPDF
|
||||
std::map<int, QPDFXRefEntry> const& xref,
|
||||
std::map<int, qpdf_offset_t> const& lengths,
|
||||
std::map<int, int> const& obj_renumber,
|
||||
PointerHolder<Buffer>& hint_stream,
|
||||
std::shared_ptr<Buffer>& hint_stream,
|
||||
int& S,
|
||||
int& O)
|
||||
{
|
||||
@ -742,14 +742,14 @@ class QPDF
|
||||
friend class QPDFObjectHandle;
|
||||
|
||||
private:
|
||||
static PointerHolder<QPDFObject>
|
||||
static std::shared_ptr<QPDFObject>
|
||||
resolve(QPDF* qpdf, int objid, int generation)
|
||||
{
|
||||
return qpdf->resolve(objid, generation);
|
||||
}
|
||||
static bool
|
||||
objectChanged(
|
||||
QPDF* qpdf, QPDFObjGen const& og, PointerHolder<QPDFObject>& oph)
|
||||
QPDF* qpdf, QPDFObjGen const& og, std::shared_ptr<QPDFObject>& oph)
|
||||
{
|
||||
return qpdf->objectChanged(og, oph);
|
||||
}
|
||||
@ -841,7 +841,7 @@ class QPDF
|
||||
{
|
||||
}
|
||||
ObjCache(
|
||||
PointerHolder<QPDFObject> object,
|
||||
std::shared_ptr<QPDFObject> object,
|
||||
qpdf_offset_t end_before_space,
|
||||
qpdf_offset_t end_after_space) :
|
||||
object(object),
|
||||
@ -850,7 +850,7 @@ class QPDF
|
||||
{
|
||||
}
|
||||
|
||||
PointerHolder<QPDFObject> object;
|
||||
std::shared_ptr<QPDFObject> object;
|
||||
qpdf_offset_t end_before_space;
|
||||
qpdf_offset_t end_after_space;
|
||||
};
|
||||
@ -896,8 +896,8 @@ class QPDF
|
||||
|
||||
public:
|
||||
ForeignStreamData(
|
||||
PointerHolder<EncryptionParameters> encp,
|
||||
PointerHolder<InputSource> file,
|
||||
std::shared_ptr<EncryptionParameters> encp,
|
||||
std::shared_ptr<InputSource> file,
|
||||
int foreign_objid,
|
||||
int foreign_generation,
|
||||
qpdf_offset_t offset,
|
||||
@ -905,8 +905,8 @@ class QPDF
|
||||
QPDFObjectHandle local_dict);
|
||||
|
||||
private:
|
||||
PointerHolder<EncryptionParameters> encp;
|
||||
PointerHolder<InputSource> file;
|
||||
std::shared_ptr<EncryptionParameters> encp;
|
||||
std::shared_ptr<InputSource> file;
|
||||
int foreign_objid;
|
||||
int foreign_generation;
|
||||
qpdf_offset_t offset;
|
||||
@ -930,12 +930,12 @@ class QPDF
|
||||
void registerForeignStream(
|
||||
QPDFObjGen const& local_og, QPDFObjectHandle foreign_stream);
|
||||
void registerForeignStream(
|
||||
QPDFObjGen const& local_og, PointerHolder<ForeignStreamData>);
|
||||
QPDFObjGen const& local_og, std::shared_ptr<ForeignStreamData>);
|
||||
|
||||
private:
|
||||
QPDF& destination_qpdf;
|
||||
std::map<QPDFObjGen, QPDFObjectHandle> foreign_streams;
|
||||
std::map<QPDFObjGen, PointerHolder<ForeignStreamData>>
|
||||
std::map<QPDFObjGen, std::shared_ptr<ForeignStreamData>>
|
||||
foreign_stream_data;
|
||||
};
|
||||
|
||||
@ -994,18 +994,18 @@ class QPDF
|
||||
void setLastObjectDescription(
|
||||
std::string const& description, int objid, int generation);
|
||||
QPDFObjectHandle readObject(
|
||||
PointerHolder<InputSource>,
|
||||
std::shared_ptr<InputSource>,
|
||||
std::string const& description,
|
||||
int objid,
|
||||
int generation,
|
||||
bool in_object_stream);
|
||||
size_t recoverStreamLength(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
int objid,
|
||||
int generation,
|
||||
qpdf_offset_t stream_offset);
|
||||
QPDFTokenizer::Token
|
||||
readToken(PointerHolder<InputSource>, size_t max_len = 0);
|
||||
readToken(std::shared_ptr<InputSource>, size_t max_len = 0);
|
||||
|
||||
QPDFObjectHandle readObjectAtOffset(
|
||||
bool attempt_recovery,
|
||||
@ -1015,8 +1015,8 @@ class QPDF
|
||||
int exp_generation,
|
||||
int& act_objid,
|
||||
int& act_generation);
|
||||
bool objectChanged(QPDFObjGen const& og, PointerHolder<QPDFObject>& oph);
|
||||
PointerHolder<QPDFObject> resolve(int objid, int generation);
|
||||
bool objectChanged(QPDFObjGen const& og, std::shared_ptr<QPDFObject>& oph);
|
||||
std::shared_ptr<QPDFObject> resolve(int objid, int generation);
|
||||
void resolveObjectsInStream(int obj_stream_number);
|
||||
void stopOnError(std::string const& message);
|
||||
|
||||
@ -1031,13 +1031,13 @@ class QPDF
|
||||
bool suppress_warnings,
|
||||
bool will_retry);
|
||||
bool pipeForeignStreamData(
|
||||
PointerHolder<ForeignStreamData>,
|
||||
std::shared_ptr<ForeignStreamData>,
|
||||
Pipeline*,
|
||||
bool suppress_warnings,
|
||||
bool will_retry);
|
||||
static bool pipeStreamData(
|
||||
PointerHolder<QPDF::EncryptionParameters> encp,
|
||||
PointerHolder<InputSource> file,
|
||||
std::shared_ptr<QPDF::EncryptionParameters> encp,
|
||||
std::shared_ptr<InputSource> file,
|
||||
QPDF& qpdf_for_warning,
|
||||
int objid,
|
||||
int generation,
|
||||
@ -1064,7 +1064,7 @@ class QPDF
|
||||
std::map<int, QPDFXRefEntry> const& xref,
|
||||
std::map<int, qpdf_offset_t> const& lengths,
|
||||
std::map<int, int> const& obj_renumber,
|
||||
PointerHolder<Buffer>& hint_stream,
|
||||
std::shared_ptr<Buffer>& hint_stream,
|
||||
int& S,
|
||||
int& O);
|
||||
|
||||
@ -1089,10 +1089,10 @@ class QPDF
|
||||
|
||||
// methods to support encryption -- implemented in QPDF_encryption.cc
|
||||
static encryption_method_e
|
||||
interpretCF(PointerHolder<EncryptionParameters> encp, QPDFObjectHandle);
|
||||
interpretCF(std::shared_ptr<EncryptionParameters> encp, QPDFObjectHandle);
|
||||
void initializeEncryption();
|
||||
static std::string getKeyForObject(
|
||||
PointerHolder<EncryptionParameters> encp,
|
||||
std::shared_ptr<EncryptionParameters> encp,
|
||||
int objid,
|
||||
int generation,
|
||||
bool use_aes);
|
||||
@ -1106,8 +1106,8 @@ class QPDF
|
||||
EncryptionData const& data,
|
||||
bool& perms_valid);
|
||||
static void decryptStream(
|
||||
PointerHolder<EncryptionParameters> encp,
|
||||
PointerHolder<InputSource> file,
|
||||
std::shared_ptr<EncryptionParameters> encp,
|
||||
std::shared_ptr<InputSource> file,
|
||||
QPDF& qpdf_for_warning,
|
||||
Pipeline*& pipeline,
|
||||
int objid,
|
||||
@ -1522,7 +1522,7 @@ class QPDF
|
||||
|
||||
unsigned long long unique_id;
|
||||
QPDFTokenizer tokenizer;
|
||||
PointerHolder<InputSource> file;
|
||||
std::shared_ptr<InputSource> file;
|
||||
std::string last_object_description;
|
||||
bool provided_password_is_hex_key;
|
||||
bool ignore_xref_streams;
|
||||
@ -1530,7 +1530,7 @@ class QPDF
|
||||
std::ostream* out_stream;
|
||||
std::ostream* err_stream;
|
||||
bool attempt_recovery;
|
||||
PointerHolder<EncryptionParameters> encp;
|
||||
std::shared_ptr<EncryptionParameters> encp;
|
||||
std::string pdf_version;
|
||||
std::map<QPDFObjGen, QPDFXRefEntry> xref_table;
|
||||
std::set<int> deleted_objects;
|
||||
@ -1542,7 +1542,7 @@ class QPDF
|
||||
bool pushed_inherited_attributes_to_pages;
|
||||
std::vector<QPDFExc> warnings;
|
||||
std::map<unsigned long long, ObjCopier> object_copiers;
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> copied_streams;
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> copied_streams;
|
||||
// copied_stream_data_provider is owned by copied_streams
|
||||
CopiedStreamDataProvider* copied_stream_data_provider;
|
||||
bool reconstructed_xref;
|
||||
@ -1590,7 +1590,7 @@ class QPDF
|
||||
// Keep all member variables inside the Members object, which we
|
||||
// dynamically allocate. This makes it possible to add new private
|
||||
// members without breaking binary compatibility.
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDF_HH
|
||||
|
@ -305,7 +305,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
|
||||
std::map<std::string, std::set<QPDFObjGen>> name_to_fields;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFACROFORMDOCUMENTHELPER_HH
|
||||
|
@ -115,7 +115,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
|
||||
Members(Members const&);
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFANNOTATIONOBJECTHELPER_HH
|
||||
|
@ -74,7 +74,7 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper
|
||||
// parameters may be supplied using setters defined below.
|
||||
QPDF_DLL
|
||||
static QPDFEFStreamObjectHelper
|
||||
createEFStream(QPDF& qpdf, PointerHolder<Buffer> data);
|
||||
createEFStream(QPDF& qpdf, std::shared_ptr<Buffer> data);
|
||||
QPDF_DLL
|
||||
static QPDFEFStreamObjectHelper
|
||||
createEFStream(QPDF& qpdf, std::string const& data);
|
||||
@ -116,7 +116,7 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper
|
||||
Members(Members const&) = delete;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFEFSTREAMOBJECTHELPER_HH
|
||||
|
@ -91,7 +91,7 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper
|
||||
std::shared_ptr<QPDFNameTreeObjectHelper> embedded_files;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFEMBEDDEDFILEDOCUMENTHELPER_HH
|
||||
|
@ -113,7 +113,7 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
|
||||
Members(Members const&) = delete;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFFILESPECOBJECTHELPER_HH
|
||||
|
@ -236,7 +236,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
|
||||
Members(Members const&);
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFFORMFIELDOBJECTHELPER_HH
|
||||
|
@ -453,7 +453,7 @@ class QPDFJob
|
||||
std::shared_ptr<QPDF> processFile(
|
||||
char const* filename, char const* password, bool used_for_input);
|
||||
std::shared_ptr<QPDF> processInputSource(
|
||||
PointerHolder<InputSource> is,
|
||||
std::shared_ptr<InputSource> is,
|
||||
char const* password,
|
||||
bool used_for_input);
|
||||
std::shared_ptr<QPDF> doProcess(
|
||||
|
@ -204,7 +204,7 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
|
||||
std::shared_ptr<NNTreeImpl> impl;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFNAMETREEOBJECTHELPER_HH
|
||||
|
@ -226,7 +226,7 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
|
||||
std::shared_ptr<NNTreeImpl> impl;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFNUMBERTREEOBJECTHELPER_HH
|
||||
|
@ -434,7 +434,7 @@ class QPDFObjectHandle
|
||||
// objects that are ready from the object's input stream.
|
||||
QPDF_DLL
|
||||
static QPDFObjectHandle parse(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
std::string const& object_description,
|
||||
QPDFTokenizer&,
|
||||
bool& empty,
|
||||
@ -490,7 +490,7 @@ class QPDFObjectHandle
|
||||
// handle the case of pages whose contents are split across
|
||||
// multiple streams.
|
||||
QPDF_DLL
|
||||
void addTokenFilter(PointerHolder<TokenFilter> token_filter);
|
||||
void addTokenFilter(std::shared_ptr<TokenFilter> token_filter);
|
||||
|
||||
// Legacy helpers for parsing content streams. These methods are
|
||||
// not going away, but newer code should call the correspond
|
||||
@ -506,7 +506,7 @@ class QPDFObjectHandle
|
||||
QPDF_DLL
|
||||
void pipePageContents(Pipeline* p);
|
||||
QPDF_DLL
|
||||
void addContentTokenFilter(PointerHolder<TokenFilter> token_filter);
|
||||
void addContentTokenFilter(std::shared_ptr<TokenFilter> token_filter);
|
||||
// End legacy content stream helpers
|
||||
|
||||
// Called on a stream to filter the stream as if it were page
|
||||
@ -618,11 +618,11 @@ class QPDFObjectHandle
|
||||
// uncompressed stream data. Example programs are provided that
|
||||
// illustrate this.
|
||||
QPDF_DLL
|
||||
static QPDFObjectHandle newStream(QPDF* qpdf, PointerHolder<Buffer> data);
|
||||
static QPDFObjectHandle newStream(QPDF* qpdf, std::shared_ptr<Buffer> data);
|
||||
|
||||
// Create new stream with data from string. This method will
|
||||
// create a copy of the data rather than using the user-provided
|
||||
// buffer as in the PointerHolder<Buffer> version of newStream.
|
||||
// buffer as in the std::shared_ptr<Buffer> version of newStream.
|
||||
QPDF_DLL
|
||||
static QPDFObjectHandle newStream(QPDF* qpdf, std::string const& data);
|
||||
|
||||
@ -1089,12 +1089,12 @@ class QPDFObjectHandle
|
||||
// Returns filtered (uncompressed) stream data. Throws an
|
||||
// exception if the stream is filtered and we can't decode it.
|
||||
QPDF_DLL
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
getStreamData(qpdf_stream_decode_level_e level = qpdf_dl_generalized);
|
||||
|
||||
// Returns unfiltered (raw) stream data.
|
||||
QPDF_DLL
|
||||
PointerHolder<Buffer> getRawStreamData();
|
||||
std::shared_ptr<Buffer> getRawStreamData();
|
||||
|
||||
// Write stream data through the given pipeline. A null pipeline
|
||||
// value may be used if all you want to do is determine whether a
|
||||
@ -1201,13 +1201,13 @@ class QPDFObjectHandle
|
||||
// decryption filters have been applied, is as presented.
|
||||
QPDF_DLL
|
||||
void replaceStreamData(
|
||||
PointerHolder<Buffer> data,
|
||||
std::shared_ptr<Buffer> data,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms);
|
||||
|
||||
// Replace the stream's stream data with the given string.
|
||||
// This method will create a copy of the data rather than using
|
||||
// the user-provided buffer as in the PointerHolder<Buffer> version
|
||||
// the user-provided buffer as in the std::shared_ptr<Buffer> version
|
||||
// of replaceStreamData.
|
||||
QPDF_DLL
|
||||
void replaceStreamData(
|
||||
@ -1242,7 +1242,7 @@ class QPDFObjectHandle
|
||||
// compute the length in advance.
|
||||
QPDF_DLL
|
||||
void replaceStreamData(
|
||||
PointerHolder<StreamDataProvider> provider,
|
||||
std::shared_ptr<StreamDataProvider> provider,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms);
|
||||
|
||||
@ -1373,7 +1373,7 @@ class QPDFObjectHandle
|
||||
friend class QPDF;
|
||||
|
||||
private:
|
||||
static PointerHolder<QPDFObject>
|
||||
static std::shared_ptr<QPDFObject>
|
||||
getObject(QPDFObjectHandle& o)
|
||||
{
|
||||
o.dereference();
|
||||
@ -1496,10 +1496,10 @@ class QPDFObjectHandle
|
||||
QPDFObjectHandle,
|
||||
QPDF*,
|
||||
std::string const&,
|
||||
PointerHolder<InputSource>,
|
||||
std::shared_ptr<InputSource>,
|
||||
qpdf_offset_t);
|
||||
static QPDFObjectHandle parseInternal(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
std::string const& object_description,
|
||||
QPDFTokenizer& tokenizer,
|
||||
bool& empty,
|
||||
@ -1510,7 +1510,7 @@ class QPDFObjectHandle
|
||||
void parseContentStream_internal(
|
||||
std::string const& description, ParserCallbacks* callbacks);
|
||||
static void parseContentStream_data(
|
||||
PointerHolder<Buffer>,
|
||||
std::shared_ptr<Buffer>,
|
||||
std::string const& description,
|
||||
ParserCallbacks* callbacks,
|
||||
QPDF* context);
|
||||
@ -1527,7 +1527,7 @@ class QPDFObjectHandle
|
||||
QPDF* qpdf;
|
||||
int objid; // 0 for direct object
|
||||
int generation;
|
||||
PointerHolder<QPDFObject> obj;
|
||||
std::shared_ptr<QPDFObject> obj;
|
||||
bool reserved;
|
||||
};
|
||||
|
||||
@ -1629,7 +1629,7 @@ class QPDFObjectHandle::QPDFDictItems
|
||||
std::set<std::string>::iterator iter;
|
||||
bool is_end;
|
||||
};
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
value_type ivalue;
|
||||
};
|
||||
|
||||
@ -1727,7 +1727,7 @@ class QPDFObjectHandle::QPDFArrayItems
|
||||
int item_number;
|
||||
bool is_end;
|
||||
};
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
value_type ivalue;
|
||||
};
|
||||
|
||||
|
@ -97,11 +97,11 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper
|
||||
std::vector<QPDFOutlineObjectHelper> outlines;
|
||||
std::set<QPDFObjGen> seen;
|
||||
QPDFObjectHandle dest_dict;
|
||||
PointerHolder<QPDFNameTreeObjectHelper> names_dest;
|
||||
std::shared_ptr<QPDFNameTreeObjectHelper> names_dest;
|
||||
std::map<QPDFObjGen, std::vector<QPDFOutlineObjectHelper>> by_page;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFOUTLINEDOCUMENTHELPER_HH
|
||||
|
@ -51,7 +51,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
|
||||
// Return parent pointer. Returns a null pointer if this is a
|
||||
// top-level outline.
|
||||
QPDF_DLL
|
||||
PointerHolder<QPDFOutlineObjectHelper> getParent();
|
||||
std::shared_ptr<QPDFOutlineObjectHelper> getParent();
|
||||
|
||||
// Return children as a list.
|
||||
QPDF_DLL
|
||||
@ -112,11 +112,11 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
|
||||
Members(Members const&);
|
||||
|
||||
QPDFOutlineDocumentHelper& dh;
|
||||
PointerHolder<QPDFOutlineObjectHelper> parent;
|
||||
std::shared_ptr<QPDFOutlineObjectHelper> parent;
|
||||
std::vector<QPDFOutlineObjectHelper> kids;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFOUTLINEOBJECTHELPER_HH
|
||||
|
@ -151,7 +151,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
|
||||
Members(Members const&);
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFPAGEDOCUMENTHELPER_HH
|
||||
|
@ -96,10 +96,10 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper
|
||||
Members();
|
||||
Members(Members const&);
|
||||
|
||||
PointerHolder<QPDFNumberTreeObjectHelper> labels;
|
||||
std::shared_ptr<QPDFNumberTreeObjectHelper> labels;
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFPAGELABELDOCUMENTHELPER_HH
|
||||
|
@ -225,7 +225,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
|
||||
// stream. Also works on form XObjects.
|
||||
QPDF_DLL
|
||||
void addContentTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter> token_filter);
|
||||
std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter);
|
||||
|
||||
// A page's resources dictionary maps names to objects elsewhere
|
||||
// in the file. This method walks through a page's contents and
|
||||
@ -397,7 +397,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
|
||||
Members(Members const&);
|
||||
};
|
||||
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFPAGEOBJECTHELPER_HH
|
||||
|
@ -173,7 +173,7 @@ class QPDFTokenizer
|
||||
// beginning of the token.
|
||||
QPDF_DLL
|
||||
Token readToken(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
std::string const& context,
|
||||
bool allow_bad = false,
|
||||
size_t max_len = 0);
|
||||
@ -187,7 +187,7 @@ class QPDFTokenizer
|
||||
// tt_inline_image or tt_bad. This is the only way readToken
|
||||
// returns a tt_inline_image token.
|
||||
QPDF_DLL
|
||||
void expectInlineImage(PointerHolder<InputSource> input);
|
||||
void expectInlineImage(std::shared_ptr<InputSource> input);
|
||||
|
||||
private:
|
||||
QPDFTokenizer(QPDFTokenizer const&) = delete;
|
||||
@ -196,7 +196,7 @@ class QPDFTokenizer
|
||||
void resolveLiteral();
|
||||
bool isSpace(char);
|
||||
bool isDelimiter(char);
|
||||
void findEI(PointerHolder<InputSource> input);
|
||||
void findEI(std::shared_ptr<InputSource> input);
|
||||
|
||||
enum state_e {
|
||||
st_top,
|
||||
@ -246,7 +246,7 @@ class QPDFTokenizer
|
||||
bool last_char_was_bs;
|
||||
bool last_char_was_cr;
|
||||
};
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFTOKENIZER_HH
|
||||
|
@ -128,7 +128,7 @@ class QPDFWriter
|
||||
|
||||
// Return getBuffer() in a shared pointer.
|
||||
QPDF_DLL
|
||||
PointerHolder<Buffer> getBufferSharedPointer();
|
||||
std::shared_ptr<Buffer> getBufferSharedPointer();
|
||||
|
||||
// Supply your own pipeline object. Output will be written to
|
||||
// this pipeline, and QPDFWriter will call finish() on the
|
||||
@ -499,7 +499,7 @@ class QPDFWriter
|
||||
// If you want to be notified of progress, derive a class from
|
||||
// ProgressReporter and override the reportProgress method.
|
||||
QPDF_DLL
|
||||
void registerProgressReporter(PointerHolder<ProgressReporter>);
|
||||
void registerProgressReporter(std::shared_ptr<ProgressReporter>);
|
||||
|
||||
// Return the PDF version that will be written into the header.
|
||||
// Calling this method does all the preparation for writing, so it
|
||||
@ -550,7 +550,7 @@ class QPDFWriter
|
||||
friend class QPDFWriter;
|
||||
|
||||
public:
|
||||
PipelinePopper(QPDFWriter* qw, PointerHolder<Buffer>* bp = 0) :
|
||||
PipelinePopper(QPDFWriter* qw, std::shared_ptr<Buffer>* bp = 0) :
|
||||
qw(qw),
|
||||
bp(bp)
|
||||
{
|
||||
@ -559,7 +559,7 @@ class QPDFWriter
|
||||
|
||||
private:
|
||||
QPDFWriter* qw;
|
||||
PointerHolder<Buffer>* bp;
|
||||
std::shared_ptr<Buffer>* bp;
|
||||
std::string stack_id;
|
||||
};
|
||||
friend class PipelinePopper;
|
||||
@ -567,7 +567,7 @@ class QPDFWriter
|
||||
unsigned int bytesNeeded(long long n);
|
||||
void writeBinary(unsigned long long val, unsigned int bytes);
|
||||
void writeString(std::string const& str);
|
||||
void writeBuffer(PointerHolder<Buffer>&);
|
||||
void writeBuffer(std::shared_ptr<Buffer>&);
|
||||
void writeStringQDF(std::string const& str);
|
||||
void writeStringNoQDF(std::string const& str);
|
||||
void writePad(int nspaces);
|
||||
@ -587,7 +587,7 @@ class QPDFWriter
|
||||
QPDFObjectHandle stream,
|
||||
bool& compress_stream,
|
||||
bool& is_metadata,
|
||||
PointerHolder<Buffer>* stream_data);
|
||||
std::shared_ptr<Buffer>* stream_data);
|
||||
void unparseObject(
|
||||
QPDFObjectHandle object,
|
||||
int level,
|
||||
@ -791,7 +791,7 @@ class QPDFWriter
|
||||
std::map<int, int> object_to_object_stream_no_gen;
|
||||
|
||||
// For progress reporting
|
||||
PointerHolder<ProgressReporter> progress_reporter;
|
||||
std::shared_ptr<ProgressReporter> progress_reporter;
|
||||
int events_expected;
|
||||
int events_seen;
|
||||
int next_progress_report;
|
||||
@ -800,7 +800,7 @@ class QPDFWriter
|
||||
// Keep all member variables inside the Members object, which we
|
||||
// dynamically allocate. This makes it possible to add new private
|
||||
// members without breaking binary compatibility.
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // QPDFWRITER_HH
|
||||
|
@ -420,7 +420,7 @@ namespace QUtil
|
||||
|
||||
QPDF_DLL
|
||||
void read_file_into_memory(
|
||||
char const* filename, PointerHolder<char>& file_buf, size_t& size);
|
||||
char const* filename, std::shared_ptr<char>& file_buf, size_t& size);
|
||||
|
||||
// This used to be called strcasecmp, but that is a macro on some
|
||||
// platforms, so we have to give it a name that is not likely to
|
||||
|
@ -52,7 +52,7 @@ void
|
||||
Buffer::copy(Buffer const& rhs)
|
||||
{
|
||||
if (this != &rhs) {
|
||||
this->m = PointerHolder<Members>(new Members(rhs.m->size, 0, true));
|
||||
this->m = std::shared_ptr<Members>(new Members(rhs.m->size, 0, true));
|
||||
if (this->m->size) {
|
||||
memcpy(this->m->buf, rhs.m->buf, this->m->size);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ void
|
||||
ClosedFileInputSource::before()
|
||||
{
|
||||
if (0 == this->m->fis.get()) {
|
||||
this->m->fis = make_pointer_holder<FileInputSource>();
|
||||
this->m->fis = std::make_shared<FileInputSource>();
|
||||
this->m->fis->setFilename(this->m->filename.c_str());
|
||||
this->m->fis->seek(this->m->offset, SEEK_SET);
|
||||
this->m->fis->setLastOffset(this->last_offset);
|
||||
|
@ -26,7 +26,7 @@ FileInputSource::FileInputSource() :
|
||||
void
|
||||
FileInputSource::setFilename(char const* filename)
|
||||
{
|
||||
this->m = PointerHolder<Members>(new Members(true));
|
||||
this->m = std::shared_ptr<Members>(new Members(true));
|
||||
this->m->filename = filename;
|
||||
this->m->file = QUtil::safe_fopen(filename, "rb");
|
||||
}
|
||||
@ -34,7 +34,7 @@ FileInputSource::setFilename(char const* filename)
|
||||
void
|
||||
FileInputSource::setFile(char const* description, FILE* filep, bool close_file)
|
||||
{
|
||||
this->m = PointerHolder<Members>(new Members(close_file));
|
||||
this->m = std::shared_ptr<Members>(new Members(close_file));
|
||||
this->m->filename = description;
|
||||
this->m->file = filep;
|
||||
this->seek(0, SEEK_SET);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
OffsetInputSource::OffsetInputSource(
|
||||
PointerHolder<InputSource> proxied, qpdf_offset_t global_offset) :
|
||||
std::shared_ptr<InputSource> proxied, qpdf_offset_t global_offset) :
|
||||
proxied(proxied),
|
||||
global_offset(global_offset)
|
||||
{
|
||||
|
@ -30,13 +30,13 @@ void
|
||||
Pl_Buffer::write(unsigned char* buf, size_t len)
|
||||
{
|
||||
if (this->m->data.get() == 0) {
|
||||
this->m->data = make_pointer_holder<Buffer>(len);
|
||||
this->m->data = std::make_shared<Buffer>(len);
|
||||
}
|
||||
size_t cur_size = this->m->data->getSize();
|
||||
size_t left = cur_size - this->m->total_size;
|
||||
if (left < len) {
|
||||
size_t new_size = std::max(this->m->total_size + len, 2 * cur_size);
|
||||
auto b = make_pointer_holder<Buffer>(new_size);
|
||||
auto b = std::make_shared<Buffer>(new_size);
|
||||
memcpy(b->getBuffer(), this->m->data->getBuffer(), this->m->total_size);
|
||||
this->m->data = b;
|
||||
}
|
||||
@ -72,14 +72,14 @@ Pl_Buffer::getBuffer()
|
||||
unsigned char* p = b->getBuffer();
|
||||
memcpy(p, this->m->data->getBuffer(), this->m->total_size);
|
||||
}
|
||||
this->m = PointerHolder<Members>(new Members());
|
||||
this->m = std::shared_ptr<Members>(new Members());
|
||||
return b;
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
Pl_Buffer::getBufferSharedPointer()
|
||||
{
|
||||
return PointerHolder<Buffer>(getBuffer());
|
||||
return std::shared_ptr<Buffer>(getBuffer());
|
||||
}
|
||||
|
||||
void
|
||||
@ -97,5 +97,5 @@ Pl_Buffer::getMallocBuffer(unsigned char** buf, size_t* len)
|
||||
} else {
|
||||
*buf = nullptr;
|
||||
}
|
||||
this->m = PointerHolder<Members>(new Members());
|
||||
this->m = std::shared_ptr<Members>(new Members());
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ Pl_DCT::finish()
|
||||
{
|
||||
this->m->buf.finish();
|
||||
|
||||
// Using a PointerHolder<Buffer> here and passing it into compress
|
||||
// Using a std::shared_ptr<Buffer> here and passing it into compress
|
||||
// and decompress causes a memory leak with setjmp/longjmp. Just
|
||||
// use a pointer and delete it.
|
||||
Buffer* b = this->m->buf.getBuffer();
|
||||
|
@ -48,9 +48,9 @@ Pl_PNGFilter::Pl_PNGFilter(
|
||||
}
|
||||
this->bytes_per_row = bpr & UINT_MAX;
|
||||
this->buf1 =
|
||||
make_array_pointer_holder<unsigned char>(this->bytes_per_row + 1);
|
||||
QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
|
||||
this->buf2 =
|
||||
make_array_pointer_holder<unsigned char>(this->bytes_per_row + 1);
|
||||
QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
|
||||
memset(this->buf1.get(), 0, this->bytes_per_row + 1);
|
||||
memset(this->buf2.get(), 0, this->bytes_per_row + 1);
|
||||
this->cur_row = this->buf1.get();
|
||||
|
@ -44,7 +44,7 @@ void
|
||||
Pl_QPDFTokenizer::finish()
|
||||
{
|
||||
this->m->buf.finish();
|
||||
auto input = PointerHolder<InputSource>(
|
||||
auto input = std::shared_ptr<InputSource>(
|
||||
// line-break
|
||||
new BufferInputSource(
|
||||
"tokenizer data", this->m->buf.getBuffer(), true));
|
||||
|
@ -12,7 +12,7 @@ Pl_RC4::Pl_RC4(
|
||||
out_bufsize(out_bufsize),
|
||||
rc4(key_data, key_len)
|
||||
{
|
||||
this->outbuf = make_array_pointer_holder<unsigned char>(out_bufsize);
|
||||
this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize);
|
||||
}
|
||||
|
||||
Pl_RC4::~Pl_RC4()
|
||||
|
@ -41,7 +41,7 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(
|
||||
}
|
||||
this->bytes_per_row = bpr & UINT_MAX;
|
||||
this->cur_row =
|
||||
make_array_pointer_holder<unsigned char>(this->bytes_per_row);
|
||||
QUtil::make_shared_array<unsigned char>(this->bytes_per_row);
|
||||
memset(this->cur_row.get(), 0, this->bytes_per_row);
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,8 @@ class InvalidInputSource: public InputSource
|
||||
};
|
||||
|
||||
QPDF::ForeignStreamData::ForeignStreamData(
|
||||
PointerHolder<EncryptionParameters> encp,
|
||||
PointerHolder<InputSource> file,
|
||||
std::shared_ptr<EncryptionParameters> encp,
|
||||
std::shared_ptr<InputSource> file,
|
||||
int foreign_objid,
|
||||
int foreign_generation,
|
||||
qpdf_offset_t offset,
|
||||
@ -138,7 +138,7 @@ QPDF::CopiedStreamDataProvider::provideStreamData(
|
||||
bool suppress_warnings,
|
||||
bool will_retry)
|
||||
{
|
||||
PointerHolder<ForeignStreamData> foreign_data =
|
||||
std::shared_ptr<ForeignStreamData> foreign_data =
|
||||
this->foreign_stream_data[QPDFObjGen(objid, generation)];
|
||||
bool result = false;
|
||||
if (foreign_data.get()) {
|
||||
@ -165,7 +165,8 @@ QPDF::CopiedStreamDataProvider::registerForeignStream(
|
||||
|
||||
void
|
||||
QPDF::CopiedStreamDataProvider::registerForeignStream(
|
||||
QPDFObjGen const& local_og, PointerHolder<ForeignStreamData> foreign_stream)
|
||||
QPDFObjGen const& local_og,
|
||||
std::shared_ptr<ForeignStreamData> foreign_stream)
|
||||
{
|
||||
this->foreign_stream_data[local_og] = foreign_stream;
|
||||
}
|
||||
@ -249,7 +250,7 @@ QPDF::~QPDF()
|
||||
// If two objects are mutually referential (through each object
|
||||
// having an array or dictionary that contains an indirect
|
||||
// reference to the other), the circular references in the
|
||||
// PointerHolder objects will prevent the objects from being
|
||||
// std::shared_ptr objects will prevent the objects from being
|
||||
// deleted. Walk through all objects in the object cache, which
|
||||
// is those objects that we read from the file, and break all
|
||||
// resolved references. At this point, obviously no one is still
|
||||
@ -274,7 +275,7 @@ QPDF::processFile(char const* filename, char const* password)
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource();
|
||||
fi->setFilename(filename);
|
||||
processInputSource(PointerHolder<InputSource>(fi), password);
|
||||
processInputSource(std::shared_ptr<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
void
|
||||
@ -283,7 +284,7 @@ QPDF::processFile(
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource();
|
||||
fi->setFile(description, filep, close_file);
|
||||
processInputSource(PointerHolder<InputSource>(fi), password);
|
||||
processInputSource(std::shared_ptr<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
void
|
||||
@ -294,7 +295,7 @@ QPDF::processMemoryFile(
|
||||
char const* password)
|
||||
{
|
||||
processInputSource(
|
||||
PointerHolder<InputSource>(
|
||||
std::shared_ptr<InputSource>(
|
||||
// line-break
|
||||
new BufferInputSource(
|
||||
description,
|
||||
@ -305,7 +306,7 @@ QPDF::processMemoryFile(
|
||||
|
||||
void
|
||||
QPDF::processInputSource(
|
||||
PointerHolder<InputSource> source, char const* password)
|
||||
std::shared_ptr<InputSource> source, char const* password)
|
||||
{
|
||||
this->m->file = source;
|
||||
parse(password);
|
||||
@ -314,7 +315,7 @@ QPDF::processInputSource(
|
||||
void
|
||||
QPDF::closeInputSource()
|
||||
{
|
||||
this->m->file = PointerHolder<InputSource>(new InvalidInputSource());
|
||||
this->m->file = std::shared_ptr<InputSource>(new InvalidInputSource());
|
||||
}
|
||||
|
||||
void
|
||||
@ -425,7 +426,7 @@ QPDF::findHeader()
|
||||
// offsets in the file are such that 0 points to the
|
||||
// beginning of the header.
|
||||
QTC::TC("qpdf", "QPDF global offset");
|
||||
this->m->file = PointerHolder<InputSource>(
|
||||
this->m->file = std::shared_ptr<InputSource>(
|
||||
new OffsetInputSource(this->m->file, global_offset));
|
||||
}
|
||||
}
|
||||
@ -1182,7 +1183,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj)
|
||||
// that this multiplication does not cause an overflow.
|
||||
size_t expected_size = entry_size * num_entries;
|
||||
|
||||
PointerHolder<Buffer> bp = xref_obj.getStreamData(qpdf_dl_specialized);
|
||||
std::shared_ptr<Buffer> bp = xref_obj.getStreamData(qpdf_dl_specialized);
|
||||
size_t actual_size = bp->getSize();
|
||||
|
||||
if (expected_size != actual_size) {
|
||||
@ -1516,7 +1517,7 @@ QPDF::setLastObjectDescription(
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDF::readObject(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
std::string const& description,
|
||||
int objid,
|
||||
int generation,
|
||||
@ -1526,11 +1527,11 @@ QPDF::readObject(
|
||||
qpdf_offset_t offset = input->tell();
|
||||
|
||||
bool empty = false;
|
||||
PointerHolder<StringDecrypter> decrypter_ph;
|
||||
std::shared_ptr<StringDecrypter> decrypter_ph;
|
||||
StringDecrypter* decrypter = 0;
|
||||
if (this->m->encp->encrypted && (!in_object_stream)) {
|
||||
decrypter_ph =
|
||||
make_pointer_holder<StringDecrypter>(this, objid, generation);
|
||||
std::make_shared<StringDecrypter>(this, objid, generation);
|
||||
decrypter = decrypter_ph.get();
|
||||
}
|
||||
QPDFObjectHandle object = QPDFObjectHandle::parse(
|
||||
@ -1706,7 +1707,7 @@ QPDF::findEndstream()
|
||||
|
||||
size_t
|
||||
QPDF::recoverStreamLength(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
int objid,
|
||||
int generation,
|
||||
qpdf_offset_t stream_offset)
|
||||
@ -1784,7 +1785,7 @@ QPDF::recoverStreamLength(
|
||||
}
|
||||
|
||||
QPDFTokenizer::Token
|
||||
QPDF::readToken(PointerHolder<InputSource> input, size_t max_len)
|
||||
QPDF::readToken(std::shared_ptr<InputSource> input, size_t max_len)
|
||||
{
|
||||
return this->m->tokenizer.readToken(
|
||||
input, this->m->last_object_description, true, max_len);
|
||||
@ -1971,7 +1972,7 @@ QPDF::readObjectAtOffset(
|
||||
}
|
||||
|
||||
bool
|
||||
QPDF::objectChanged(QPDFObjGen const& og, PointerHolder<QPDFObject>& oph)
|
||||
QPDF::objectChanged(QPDFObjGen const& og, std::shared_ptr<QPDFObject>& oph)
|
||||
{
|
||||
// See if the object cached at og, if any, is the one passed in.
|
||||
// QPDFObjectHandle uses this to detect outdated handles to
|
||||
@ -1992,7 +1993,7 @@ QPDF::objectChanged(QPDFObjGen const& og, PointerHolder<QPDFObject>& oph)
|
||||
return (c->second.object.get() != oph.get());
|
||||
}
|
||||
|
||||
PointerHolder<QPDFObject>
|
||||
std::shared_ptr<QPDFObject>
|
||||
QPDF::resolve(int objid, int generation)
|
||||
{
|
||||
// Check object cache before checking xref table. This allows us
|
||||
@ -2011,7 +2012,7 @@ QPDF::resolve(int objid, int generation)
|
||||
this->m->file->getLastOffset(),
|
||||
("loop detected resolving object " + QUtil::int_to_string(objid) +
|
||||
" " + QUtil::int_to_string(generation))));
|
||||
return PointerHolder<QPDFObject>(new QPDF_Null);
|
||||
return std::shared_ptr<QPDFObject>(new QPDF_Null);
|
||||
}
|
||||
ResolveRecorder rr(this, og);
|
||||
|
||||
@ -2071,7 +2072,7 @@ QPDF::resolve(int objid, int generation)
|
||||
ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
|
||||
}
|
||||
|
||||
PointerHolder<QPDFObject> result(this->m->obj_cache[og].object);
|
||||
std::shared_ptr<QPDFObject> result(this->m->obj_cache[og].object);
|
||||
if (!result->hasDescription()) {
|
||||
result->setDescription(
|
||||
this,
|
||||
@ -2135,8 +2136,8 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
|
||||
|
||||
std::map<int, int> offsets;
|
||||
|
||||
PointerHolder<Buffer> bp = obj_stream.getStreamData(qpdf_dl_specialized);
|
||||
auto input = PointerHolder<InputSource>(
|
||||
std::shared_ptr<Buffer> bp = obj_stream.getStreamData(qpdf_dl_specialized);
|
||||
auto input = std::shared_ptr<InputSource>(
|
||||
// line-break
|
||||
new BufferInputSource(
|
||||
(this->m->file->getName() + " object stream " +
|
||||
@ -2496,7 +2497,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||
this->m->copied_stream_data_provider =
|
||||
new CopiedStreamDataProvider(*this);
|
||||
this->m->copied_streams =
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider>(
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(
|
||||
this->m->copied_stream_data_provider);
|
||||
}
|
||||
QPDFObjGen local_og(result.getObjGen());
|
||||
@ -2513,7 +2514,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||
throw std::logic_error("unable to retrieve underlying"
|
||||
" stream object from foreign stream");
|
||||
}
|
||||
PointerHolder<Buffer> stream_buffer = stream->getStreamDataBuffer();
|
||||
std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer();
|
||||
if ((foreign_stream_qpdf->m->immediate_copy_from) &&
|
||||
(stream_buffer.get() == 0)) {
|
||||
// Pull the stream data into a buffer before attempting
|
||||
@ -2527,7 +2528,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||
old_dict.getKey("/DecodeParms"));
|
||||
stream_buffer = stream->getStreamDataBuffer();
|
||||
}
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> stream_provider =
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> stream_provider =
|
||||
stream->getStreamDataProvider();
|
||||
if (stream_buffer.get()) {
|
||||
QTC::TC("qpdf", "QPDF copy foreign stream with buffer");
|
||||
@ -2543,7 +2544,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||
dict.getKey("/Filter"),
|
||||
dict.getKey("/DecodeParms"));
|
||||
} else {
|
||||
auto foreign_stream_data = make_pointer_holder<ForeignStreamData>(
|
||||
auto foreign_stream_data = std::make_shared<ForeignStreamData>(
|
||||
foreign_stream_qpdf->m->encp,
|
||||
foreign_stream_qpdf->m->file,
|
||||
foreign.getObjectID(),
|
||||
@ -2758,8 +2759,8 @@ QPDF::getCompressibleObjGens()
|
||||
|
||||
bool
|
||||
QPDF::pipeStreamData(
|
||||
PointerHolder<EncryptionParameters> encp,
|
||||
PointerHolder<InputSource> file,
|
||||
std::shared_ptr<EncryptionParameters> encp,
|
||||
std::shared_ptr<InputSource> file,
|
||||
QPDF& qpdf_for_warning,
|
||||
int objid,
|
||||
int generation,
|
||||
@ -2870,7 +2871,7 @@ QPDF::pipeStreamData(
|
||||
|
||||
bool
|
||||
QPDF::pipeForeignStreamData(
|
||||
PointerHolder<ForeignStreamData> foreign,
|
||||
std::shared_ptr<ForeignStreamData> foreign,
|
||||
Pipeline* pipeline,
|
||||
bool suppress_warnings,
|
||||
bool will_retry)
|
||||
|
@ -772,7 +772,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
|
||||
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper AP parse error");
|
||||
}
|
||||
auto rr = new ResourceReplacer(dr_map, rf.getNamesByResourceType());
|
||||
auto tf = PointerHolder<QPDFObjectHandle::TokenFilter>(rr);
|
||||
auto tf = std::shared_ptr<QPDFObjectHandle::TokenFilter>(rr);
|
||||
stream.addTokenFilter(tf);
|
||||
} catch (std::exception& e) {
|
||||
// No way to reproduce in test suite right now since error
|
||||
@ -792,13 +792,13 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||
QPDF* from_qpdf,
|
||||
QPDFAcroFormDocumentHelper* from_afdh)
|
||||
{
|
||||
PointerHolder<QPDFAcroFormDocumentHelper> afdhph;
|
||||
std::shared_ptr<QPDFAcroFormDocumentHelper> afdhph;
|
||||
if (!from_qpdf) {
|
||||
// Assume these are from the same QPDF.
|
||||
from_qpdf = &this->qpdf;
|
||||
from_afdh = this;
|
||||
} else if ((from_qpdf != &this->qpdf) && (!from_afdh)) {
|
||||
afdhph = make_pointer_holder<QPDFAcroFormDocumentHelper>(*from_qpdf);
|
||||
afdhph = std::make_shared<QPDFAcroFormDocumentHelper>(*from_qpdf);
|
||||
from_afdh = afdhph.get();
|
||||
}
|
||||
bool foreign = (from_qpdf != &this->qpdf);
|
||||
|
@ -92,7 +92,8 @@ QPDFEFStreamObjectHelper::getChecksum()
|
||||
}
|
||||
|
||||
QPDFEFStreamObjectHelper
|
||||
QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, PointerHolder<Buffer> data)
|
||||
QPDFEFStreamObjectHelper::createEFStream(
|
||||
QPDF& qpdf, std::shared_ptr<Buffer> data)
|
||||
{
|
||||
return newFromStream(QPDFObjectHandle::newStream(&qpdf, data));
|
||||
}
|
||||
|
@ -915,6 +915,6 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
|
||||
|
||||
AS.addTokenFilter(
|
||||
// line-break
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter>(
|
||||
std::shared_ptr<QPDFObjectHandle::TokenFilter>(
|
||||
new ValueSetter(DA, V, opt, tf, bbox)));
|
||||
}
|
||||
|
@ -1879,7 +1879,7 @@ QPDFJob::processFile(
|
||||
|
||||
std::shared_ptr<QPDF>
|
||||
QPDFJob::processInputSource(
|
||||
PointerHolder<InputSource> is, char const* password, bool used_for_input)
|
||||
std::shared_ptr<InputSource> is, char const* password, bool used_for_input)
|
||||
{
|
||||
auto f1 = std::mem_fn(&QPDF::processInputSource);
|
||||
auto fn = std::bind(f1, std::placeholders::_1, is, std::placeholders::_2);
|
||||
@ -2238,7 +2238,7 @@ QPDFJob::handleTransformations(QPDF& pdf)
|
||||
m->oi_min_height,
|
||||
m->oi_min_area,
|
||||
image);
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> sdp(io);
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> sdp(io);
|
||||
if (io->evaluate(
|
||||
"image " + name + " on page " +
|
||||
QUtil::int_to_string(pageno))) {
|
||||
@ -2494,17 +2494,17 @@ QPDFJob::handlePageSpecs(
|
||||
cout << prefix << ": processing " << page_spec.filename
|
||||
<< std::endl;
|
||||
});
|
||||
PointerHolder<InputSource> is;
|
||||
std::shared_ptr<InputSource> is;
|
||||
ClosedFileInputSource* cis = 0;
|
||||
if (!m->keep_files_open) {
|
||||
QTC::TC("qpdf", "QPDFJob keep files open n");
|
||||
cis = new ClosedFileInputSource(page_spec.filename.c_str());
|
||||
is = PointerHolder<InputSource>(cis);
|
||||
is = std::shared_ptr<InputSource>(cis);
|
||||
cis->stayOpen(true);
|
||||
} else {
|
||||
QTC::TC("qpdf", "QPDFJob keep files open y");
|
||||
FileInputSource* fis = new FileInputSource();
|
||||
is = PointerHolder<InputSource>(fis);
|
||||
is = std::shared_ptr<InputSource>(fis);
|
||||
fis->setFilename(page_spec.filename.c_str());
|
||||
}
|
||||
std::shared_ptr<QPDF> qpdf_ph =
|
||||
@ -3064,7 +3064,8 @@ QPDFJob::setWriterOptions(QPDF& pdf, QPDFWriter& w)
|
||||
w.forcePDFVersion(version, extension_level);
|
||||
}
|
||||
if (m->progress && m->outfilename) {
|
||||
w.registerProgressReporter(PointerHolder<QPDFWriter::ProgressReporter>(
|
||||
w.registerProgressReporter(
|
||||
std::shared_ptr<QPDFWriter::ProgressReporter>(
|
||||
// line-break
|
||||
new ProgressReporter(
|
||||
*(this->m->cout),
|
||||
|
@ -685,7 +685,7 @@ QPDFJob::Config::showObject(std::string const& parameter)
|
||||
QPDFJob::Config*
|
||||
QPDFJob::Config::jobJsonFile(std::string const& parameter)
|
||||
{
|
||||
PointerHolder<char> file_buf;
|
||||
std::shared_ptr<char> file_buf;
|
||||
size_t size;
|
||||
QUtil::read_file_into_memory(parameter.c_str(), file_buf, size);
|
||||
try {
|
||||
|
@ -252,7 +252,7 @@ QPDFObjectHandle::setObjectDescriptionFromInput(
|
||||
QPDFObjectHandle object,
|
||||
QPDF* context,
|
||||
std::string const& description,
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
qpdf_offset_t offset)
|
||||
{
|
||||
object.setObjectDescription(
|
||||
@ -1337,14 +1337,14 @@ QPDFObjectHandle::replaceDict(QPDFObjectHandle new_dict)
|
||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceDict(new_dict);
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
QPDFObjectHandle::getStreamData(qpdf_stream_decode_level_e level)
|
||||
{
|
||||
assertStream();
|
||||
return dynamic_cast<QPDF_Stream*>(obj.get())->getStreamData(level);
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
QPDFObjectHandle::getRawStreamData()
|
||||
{
|
||||
assertStream();
|
||||
@ -1410,7 +1410,7 @@ QPDFObjectHandle::pipeStreamData(
|
||||
|
||||
void
|
||||
QPDFObjectHandle::replaceStreamData(
|
||||
PointerHolder<Buffer> data,
|
||||
std::shared_ptr<Buffer> data,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
@ -1426,7 +1426,7 @@ QPDFObjectHandle::replaceStreamData(
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
assertStream();
|
||||
auto b = make_pointer_holder<Buffer>(data.length());
|
||||
auto b = std::make_shared<Buffer>(data.length());
|
||||
unsigned char* bp = b->getBuffer();
|
||||
memcpy(bp, data.c_str(), data.length());
|
||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||
@ -1435,7 +1435,7 @@ QPDFObjectHandle::replaceStreamData(
|
||||
|
||||
void
|
||||
QPDFObjectHandle::replaceStreamData(
|
||||
PointerHolder<StreamDataProvider> provider,
|
||||
std::shared_ptr<StreamDataProvider> provider,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
@ -1487,7 +1487,7 @@ QPDFObjectHandle::replaceStreamData(
|
||||
{
|
||||
assertStream();
|
||||
auto sdp =
|
||||
PointerHolder<StreamDataProvider>(new FunctionProvider(provider));
|
||||
std::shared_ptr<StreamDataProvider>(new FunctionProvider(provider));
|
||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||
sdp, filter, decode_parms);
|
||||
}
|
||||
@ -1500,7 +1500,7 @@ QPDFObjectHandle::replaceStreamData(
|
||||
{
|
||||
assertStream();
|
||||
auto sdp =
|
||||
PointerHolder<StreamDataProvider>(new FunctionProvider(provider));
|
||||
std::shared_ptr<StreamDataProvider>(new FunctionProvider(provider));
|
||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||
sdp, filter, decode_parms);
|
||||
}
|
||||
@ -1694,7 +1694,7 @@ QPDFObjectHandle::coalesceContentStreams()
|
||||
QPDFObjectHandle new_contents = newStream(qpdf);
|
||||
this->replaceKey("/Contents", new_contents);
|
||||
|
||||
auto provider = PointerHolder<StreamDataProvider>(
|
||||
auto provider = std::shared_ptr<StreamDataProvider>(
|
||||
new CoalesceProvider(*this, contents));
|
||||
new_contents.replaceStreamData(provider, newNull(), newNull());
|
||||
}
|
||||
@ -1772,7 +1772,7 @@ QPDFObjectHandle::parse(
|
||||
std::string const& object_str,
|
||||
std::string const& object_description)
|
||||
{
|
||||
auto input = PointerHolder<InputSource>(
|
||||
auto input = std::shared_ptr<InputSource>(
|
||||
new BufferInputSource("parsed object", object_str));
|
||||
QPDFTokenizer tokenizer;
|
||||
bool empty = false;
|
||||
@ -1908,13 +1908,13 @@ QPDFObjectHandle::parseContentStream_internal(
|
||||
|
||||
void
|
||||
QPDFObjectHandle::parseContentStream_data(
|
||||
PointerHolder<Buffer> stream_data,
|
||||
std::shared_ptr<Buffer> stream_data,
|
||||
std::string const& description,
|
||||
ParserCallbacks* callbacks,
|
||||
QPDF* context)
|
||||
{
|
||||
size_t stream_length = stream_data->getSize();
|
||||
auto input = PointerHolder<InputSource>(
|
||||
auto input = std::shared_ptr<InputSource>(
|
||||
new BufferInputSource(description, stream_data.get()));
|
||||
QPDFTokenizer tokenizer;
|
||||
tokenizer.allowEOF();
|
||||
@ -1969,14 +1969,14 @@ QPDFObjectHandle::parseContentStream_data(
|
||||
}
|
||||
|
||||
void
|
||||
QPDFObjectHandle::addContentTokenFilter(PointerHolder<TokenFilter> filter)
|
||||
QPDFObjectHandle::addContentTokenFilter(std::shared_ptr<TokenFilter> filter)
|
||||
{
|
||||
coalesceContentStreams();
|
||||
this->getKey("/Contents").addTokenFilter(filter);
|
||||
}
|
||||
|
||||
void
|
||||
QPDFObjectHandle::addTokenFilter(PointerHolder<TokenFilter> filter)
|
||||
QPDFObjectHandle::addTokenFilter(std::shared_ptr<TokenFilter> filter)
|
||||
{
|
||||
assertStream();
|
||||
return dynamic_cast<QPDF_Stream*>(obj.get())->addTokenFilter(filter);
|
||||
@ -1984,7 +1984,7 @@ QPDFObjectHandle::addTokenFilter(PointerHolder<TokenFilter> filter)
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDFObjectHandle::parse(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
std::string const& object_description,
|
||||
QPDFTokenizer& tokenizer,
|
||||
bool& empty,
|
||||
@ -1997,7 +1997,7 @@ QPDFObjectHandle::parse(
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDFObjectHandle::parseInternal(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
std::string const& object_description,
|
||||
QPDFTokenizer& tokenizer,
|
||||
bool& empty,
|
||||
@ -2698,7 +2698,7 @@ QPDFObjectHandle::newStream(QPDF* qpdf)
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDFObjectHandle::newStream(QPDF* qpdf, PointerHolder<Buffer> data)
|
||||
QPDFObjectHandle::newStream(QPDF* qpdf, std::shared_ptr<Buffer> data)
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle newStream with data");
|
||||
QPDFObjectHandle result = newStream(qpdf);
|
||||
@ -2836,26 +2836,27 @@ QPDFObjectHandle::copyObject(
|
||||
this->objid = 0;
|
||||
this->generation = 0;
|
||||
|
||||
PointerHolder<QPDFObject> new_obj;
|
||||
std::shared_ptr<QPDFObject> new_obj;
|
||||
|
||||
if (isBool()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone bool");
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Bool(getBoolValue()));
|
||||
new_obj = std::shared_ptr<QPDFObject>(new QPDF_Bool(getBoolValue()));
|
||||
} else if (isNull()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone null");
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Null());
|
||||
new_obj = std::shared_ptr<QPDFObject>(new QPDF_Null());
|
||||
} else if (isInteger()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone integer");
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Integer(getIntValue()));
|
||||
new_obj = std::shared_ptr<QPDFObject>(new QPDF_Integer(getIntValue()));
|
||||
} else if (isReal()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone real");
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Real(getRealValue()));
|
||||
new_obj = std::shared_ptr<QPDFObject>(new QPDF_Real(getRealValue()));
|
||||
} else if (isName()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone name");
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Name(getName()));
|
||||
new_obj = std::shared_ptr<QPDFObject>(new QPDF_Name(getName()));
|
||||
} else if (isString()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone string");
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_String(getStringValue()));
|
||||
new_obj =
|
||||
std::shared_ptr<QPDFObject>(new QPDF_String(getStringValue()));
|
||||
} else if (isArray()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone array");
|
||||
std::vector<QPDFObjectHandle> items;
|
||||
@ -2868,7 +2869,7 @@ QPDFObjectHandle::copyObject(
|
||||
visited, cross_indirect, first_level_only, stop_at_streams);
|
||||
}
|
||||
}
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Array(items));
|
||||
new_obj = std::shared_ptr<QPDFObject>(new QPDF_Array(items));
|
||||
} else if (isDictionary()) {
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone dictionary");
|
||||
std::set<std::string> keys = getKeys();
|
||||
@ -2883,7 +2884,7 @@ QPDFObjectHandle::copyObject(
|
||||
visited, cross_indirect, first_level_only, stop_at_streams);
|
||||
}
|
||||
}
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Dictionary(items));
|
||||
new_obj = std::shared_ptr<QPDFObject>(new QPDF_Dictionary(items));
|
||||
} else {
|
||||
throw std::logic_error("QPDFObjectHandle::makeDirectInternal: "
|
||||
"unknown object type");
|
||||
@ -3172,12 +3173,12 @@ QPDFObjectHandle::dereference()
|
||||
this->obj = nullptr;
|
||||
}
|
||||
if (this->obj.get() == 0) {
|
||||
PointerHolder<QPDFObject> obj =
|
||||
std::shared_ptr<QPDFObject> obj =
|
||||
QPDF::Resolver::resolve(this->qpdf, this->objid, this->generation);
|
||||
if (obj.get() == 0) {
|
||||
// QPDF::resolve never returns an uninitialized object, but
|
||||
// check just in case.
|
||||
this->obj = PointerHolder<QPDFObject>(new QPDF_Null());
|
||||
this->obj = std::shared_ptr<QPDFObject>(new QPDF_Null());
|
||||
} else if (dynamic_cast<QPDF_Reserved*>(obj.get())) {
|
||||
// Do not resolve
|
||||
} else {
|
||||
|
@ -100,7 +100,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
|
||||
QPDFObjectHandle dests = names.getKey("/Dests");
|
||||
if (dests.isDictionary()) {
|
||||
this->m->names_dest =
|
||||
make_pointer_holder<QPDFNameTreeObjectHelper>(
|
||||
std::make_shared<QPDFNameTreeObjectHelper>(
|
||||
dests, this->qpdf);
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ QPDFOutlineObjectHelper::QPDFOutlineObjectHelper(
|
||||
QPDFObjectHandle cur = oh.getKey("/First");
|
||||
while (!cur.isNull()) {
|
||||
QPDFOutlineObjectHelper new_ooh(cur, dh, 1 + depth);
|
||||
new_ooh.m->parent = make_pointer_holder<QPDFOutlineObjectHelper>(*this);
|
||||
new_ooh.m->parent = std::make_shared<QPDFOutlineObjectHelper>(*this);
|
||||
this->m->kids.push_back(new_ooh);
|
||||
cur = cur.getKey("/Next");
|
||||
}
|
||||
}
|
||||
|
||||
PointerHolder<QPDFOutlineObjectHelper>
|
||||
std::shared_ptr<QPDFOutlineObjectHelper>
|
||||
QPDFOutlineObjectHelper::getParent()
|
||||
{
|
||||
return this->m->parent;
|
||||
|
@ -16,7 +16,7 @@ QPDFPageLabelDocumentHelper::QPDFPageLabelDocumentHelper(QPDF& qpdf) :
|
||||
{
|
||||
QPDFObjectHandle root = qpdf.getRoot();
|
||||
if (root.hasKey("/PageLabels")) {
|
||||
this->m->labels = make_pointer_holder<QPDFNumberTreeObjectHelper>(
|
||||
this->m->labels = std::make_shared<QPDFNumberTreeObjectHelper>(
|
||||
root.getKey("/PageLabels"), this->qpdf);
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ QPDFPageObjectHelper::pipeContents(Pipeline* p)
|
||||
|
||||
void
|
||||
QPDFPageObjectHelper::addContentTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter> token_filter)
|
||||
std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter)
|
||||
{
|
||||
if (this->oh.isFormXObject()) {
|
||||
this->oh.addTokenFilter(token_filter);
|
||||
@ -776,7 +776,7 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations)
|
||||
" XObject created from page will not work");
|
||||
}
|
||||
newdict.replaceKey("/BBox", bbox);
|
||||
auto provider = PointerHolder<QPDFObjectHandle::StreamDataProvider>(
|
||||
auto provider = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(
|
||||
new ContentProvider(this->oh));
|
||||
result.replaceStreamData(
|
||||
provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
|
||||
@ -1060,9 +1060,9 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
|
||||
std::vector<QPDFObjectHandle> new_annots;
|
||||
std::vector<QPDFObjectHandle> new_fields;
|
||||
std::set<QPDFObjGen> old_fields;
|
||||
PointerHolder<QPDFAcroFormDocumentHelper> afdhph;
|
||||
std::shared_ptr<QPDFAcroFormDocumentHelper> afdhph;
|
||||
if (!afdh) {
|
||||
afdhph = make_pointer_holder<QPDFAcroFormDocumentHelper>(*qpdf);
|
||||
afdhph = std::make_shared<QPDFAcroFormDocumentHelper>(*qpdf);
|
||||
afdh = afdhph.get();
|
||||
}
|
||||
afdh->transformAnnotations(
|
||||
@ -1101,10 +1101,10 @@ QPDFPageObjectHelper::copyAnnotations(
|
||||
std::vector<QPDFObjectHandle> new_annots;
|
||||
std::vector<QPDFObjectHandle> new_fields;
|
||||
std::set<QPDFObjGen> old_fields;
|
||||
PointerHolder<QPDFAcroFormDocumentHelper> afdhph;
|
||||
PointerHolder<QPDFAcroFormDocumentHelper> from_afdhph;
|
||||
std::shared_ptr<QPDFAcroFormDocumentHelper> afdhph;
|
||||
std::shared_ptr<QPDFAcroFormDocumentHelper> from_afdhph;
|
||||
if (!afdh) {
|
||||
afdhph = make_pointer_holder<QPDFAcroFormDocumentHelper>(*this_qpdf);
|
||||
afdhph = std::make_shared<QPDFAcroFormDocumentHelper>(*this_qpdf);
|
||||
afdh = afdhph.get();
|
||||
}
|
||||
if (this_qpdf == from_qpdf) {
|
||||
@ -1116,8 +1116,7 @@ QPDFPageObjectHelper::copyAnnotations(
|
||||
" is not from the same QPDF as from_page");
|
||||
}
|
||||
} else {
|
||||
from_afdhph =
|
||||
make_pointer_holder<QPDFAcroFormDocumentHelper>(*from_qpdf);
|
||||
from_afdhph = std::make_shared<QPDFAcroFormDocumentHelper>(*from_qpdf);
|
||||
from_afdh = from_afdhph.get();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,8 @@ is_delimiter(char ch)
|
||||
class QPDFWordTokenFinder: public InputSource::Finder
|
||||
{
|
||||
public:
|
||||
QPDFWordTokenFinder(PointerHolder<InputSource> is, std::string const& str) :
|
||||
QPDFWordTokenFinder(
|
||||
std::shared_ptr<InputSource> is, std::string const& str) :
|
||||
is(is),
|
||||
str(str)
|
||||
{
|
||||
@ -34,7 +35,7 @@ class QPDFWordTokenFinder: public InputSource::Finder
|
||||
virtual bool check();
|
||||
|
||||
private:
|
||||
PointerHolder<InputSource> is;
|
||||
std::shared_ptr<InputSource> is;
|
||||
std::string str;
|
||||
};
|
||||
|
||||
@ -503,7 +504,7 @@ QPDFTokenizer::presentEOF()
|
||||
}
|
||||
|
||||
void
|
||||
QPDFTokenizer::expectInlineImage(PointerHolder<InputSource> input)
|
||||
QPDFTokenizer::expectInlineImage(std::shared_ptr<InputSource> input)
|
||||
{
|
||||
if (this->m->state != st_top) {
|
||||
throw std::logic_error("QPDFTokenizer::expectInlineImage called"
|
||||
@ -514,7 +515,7 @@ QPDFTokenizer::expectInlineImage(PointerHolder<InputSource> input)
|
||||
}
|
||||
|
||||
void
|
||||
QPDFTokenizer::findEI(PointerHolder<InputSource> input)
|
||||
QPDFTokenizer::findEI(std::shared_ptr<InputSource> input)
|
||||
{
|
||||
if (!input.get()) {
|
||||
return;
|
||||
@ -645,7 +646,7 @@ QPDFTokenizer::betweenTokens()
|
||||
|
||||
QPDFTokenizer::Token
|
||||
QPDFTokenizer::readToken(
|
||||
PointerHolder<InputSource> input,
|
||||
std::shared_ptr<InputSource> input,
|
||||
std::string const& context,
|
||||
bool allow_bad,
|
||||
size_t max_len)
|
||||
|
@ -153,10 +153,10 @@ QPDFWriter::getBuffer()
|
||||
return result;
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
QPDFWriter::getBufferSharedPointer()
|
||||
{
|
||||
return PointerHolder<Buffer>(getBuffer());
|
||||
return std::shared_ptr<Buffer>(getBuffer());
|
||||
}
|
||||
|
||||
void
|
||||
@ -1081,7 +1081,7 @@ QPDFWriter::writeString(std::string const& str)
|
||||
}
|
||||
|
||||
void
|
||||
QPDFWriter::writeBuffer(PointerHolder<Buffer>& b)
|
||||
QPDFWriter::writeBuffer(std::shared_ptr<Buffer>& b)
|
||||
{
|
||||
this->m->pipeline->write(b->getBuffer(), b->getSize());
|
||||
}
|
||||
@ -1485,7 +1485,7 @@ QPDFWriter::willFilterStream(
|
||||
QPDFObjectHandle stream,
|
||||
bool& compress_stream,
|
||||
bool& is_metadata,
|
||||
PointerHolder<Buffer>* stream_data)
|
||||
std::shared_ptr<Buffer>* stream_data)
|
||||
{
|
||||
compress_stream = false;
|
||||
is_metadata = false;
|
||||
@ -1819,7 +1819,7 @@ QPDFWriter::unparseObject(
|
||||
flags |= f_stream;
|
||||
bool compress_stream = false;
|
||||
bool is_metadata = false;
|
||||
PointerHolder<Buffer> stream_data;
|
||||
std::shared_ptr<Buffer> stream_data;
|
||||
if (willFilterStream(
|
||||
object, compress_stream, is_metadata, &stream_data)) {
|
||||
flags |= f_filtered;
|
||||
@ -1924,7 +1924,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object)
|
||||
|
||||
// Generate stream itself. We have to do this in two passes so we
|
||||
// can calculate offsets in the first pass.
|
||||
PointerHolder<Buffer> stream_buffer;
|
||||
std::shared_ptr<Buffer> stream_buffer;
|
||||
int first_obj = -1;
|
||||
bool compressed = false;
|
||||
for (int pass = 1; pass <= 2; ++pass) {
|
||||
@ -2667,7 +2667,7 @@ QPDFWriter::writeHeader()
|
||||
void
|
||||
QPDFWriter::writeHintStream(int hint_id)
|
||||
{
|
||||
PointerHolder<Buffer> hint_buffer;
|
||||
std::shared_ptr<Buffer> hint_buffer;
|
||||
int S = 0;
|
||||
int O = 0;
|
||||
QPDF::Writer::generateHintStream(
|
||||
@ -2839,7 +2839,7 @@ QPDFWriter::writeXRefStream(
|
||||
p = pushPipeline(
|
||||
new Pl_PNGFilter("pngify xref", p, Pl_PNGFilter::a_encode, esize));
|
||||
}
|
||||
PointerHolder<Buffer> xref_data;
|
||||
std::shared_ptr<Buffer> xref_data;
|
||||
{
|
||||
PipelinePopper pp_xref(this, &xref_data);
|
||||
activatePipelineStack(pp_xref);
|
||||
@ -3098,13 +3098,13 @@ QPDFWriter::writeLinearized()
|
||||
}
|
||||
|
||||
qpdf_offset_t hint_length = 0;
|
||||
PointerHolder<Buffer> hint_buffer;
|
||||
std::shared_ptr<Buffer> hint_buffer;
|
||||
|
||||
// Write file in two passes. Part numbers refer to PDF spec 1.4.
|
||||
|
||||
FILE* lin_pass1_file = 0;
|
||||
auto pp_pass1 = make_pointer_holder<PipelinePopper>(this);
|
||||
auto pp_md5 = make_pointer_holder<PipelinePopper>(this);
|
||||
auto pp_pass1 = std::make_shared<PipelinePopper>(this);
|
||||
auto pp_md5 = std::make_shared<PipelinePopper>(this);
|
||||
for (int pass = 1; pass <= 2; ++pass) {
|
||||
if (pass == 1) {
|
||||
if (!this->m->lin_pass1_filename.empty()) {
|
||||
@ -3489,7 +3489,7 @@ QPDFWriter::indicateProgress(bool decrement, bool finished)
|
||||
}
|
||||
|
||||
void
|
||||
QPDFWriter::registerProgressReporter(PointerHolder<ProgressReporter> pr)
|
||||
QPDFWriter::registerProgressReporter(std::shared_ptr<ProgressReporter> pr)
|
||||
{
|
||||
this->m->progress_reporter = pr;
|
||||
}
|
||||
@ -3497,7 +3497,7 @@ QPDFWriter::registerProgressReporter(PointerHolder<ProgressReporter> pr)
|
||||
void
|
||||
QPDFWriter::writeStandard()
|
||||
{
|
||||
auto pp_md5 = make_pointer_holder<PipelinePopper>(this);
|
||||
auto pp_md5 = std::make_shared<PipelinePopper>(this);
|
||||
if (this->m->deterministic_id) {
|
||||
pushMD5Pipeline(*pp_md5);
|
||||
}
|
||||
|
@ -221,19 +221,19 @@ QPDF_Stream::getLength() const
|
||||
return this->length;
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
QPDF_Stream::getStreamDataBuffer() const
|
||||
{
|
||||
return this->stream_data;
|
||||
}
|
||||
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider>
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider>
|
||||
QPDF_Stream::getStreamDataProvider() const
|
||||
{
|
||||
return this->stream_provider;
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level)
|
||||
{
|
||||
Pl_Buffer buf("stream data buffer");
|
||||
@ -251,7 +251,7 @@ QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level)
|
||||
return buf.getBufferSharedPointer();
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
std::shared_ptr<Buffer>
|
||||
QPDF_Stream::getRawStreamData()
|
||||
{
|
||||
Pl_Buffer buf("stream data buffer");
|
||||
@ -438,7 +438,7 @@ QPDF_Stream::pipeStreamData(
|
||||
// objects.
|
||||
std::vector<std::shared_ptr<Pipeline>> to_delete;
|
||||
|
||||
PointerHolder<ContentNormalizer> normalizer;
|
||||
std::shared_ptr<ContentNormalizer> normalizer;
|
||||
std::shared_ptr<Pipeline> new_pipeline;
|
||||
if (filter) {
|
||||
if (encode_flags & qpdf_ef_compress) {
|
||||
@ -449,7 +449,7 @@ QPDF_Stream::pipeStreamData(
|
||||
}
|
||||
|
||||
if (encode_flags & qpdf_ef_normalize) {
|
||||
normalizer = make_pointer_holder<ContentNormalizer>();
|
||||
normalizer = std::make_shared<ContentNormalizer>();
|
||||
new_pipeline = std::make_shared<Pl_QPDFTokenizer>(
|
||||
"normalizer", normalizer.get(), pipeline);
|
||||
to_delete.push_back(new_pipeline);
|
||||
@ -586,7 +586,7 @@ QPDF_Stream::pipeStreamData(
|
||||
|
||||
void
|
||||
QPDF_Stream::replaceStreamData(
|
||||
PointerHolder<Buffer> data,
|
||||
std::shared_ptr<Buffer> data,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
@ -597,7 +597,7 @@ QPDF_Stream::replaceStreamData(
|
||||
|
||||
void
|
||||
QPDF_Stream::replaceStreamData(
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> provider,
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
@ -608,7 +608,7 @@ QPDF_Stream::replaceStreamData(
|
||||
|
||||
void
|
||||
QPDF_Stream::addTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter> token_filter)
|
||||
std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter)
|
||||
{
|
||||
this->token_filters.push_back(token_filter);
|
||||
}
|
||||
|
@ -754,7 +754,8 @@ QPDF::recover_encryption_key_with_password(
|
||||
}
|
||||
|
||||
QPDF::encryption_method_e
|
||||
QPDF::interpretCF(PointerHolder<EncryptionParameters> encp, QPDFObjectHandle cf)
|
||||
QPDF::interpretCF(
|
||||
std::shared_ptr<EncryptionParameters> encp, QPDFObjectHandle cf)
|
||||
{
|
||||
if (cf.isName()) {
|
||||
std::string filter = cf.getName();
|
||||
@ -1079,7 +1080,7 @@ QPDF::initializeEncryption()
|
||||
|
||||
std::string
|
||||
QPDF::getKeyForObject(
|
||||
PointerHolder<EncryptionParameters> encp,
|
||||
std::shared_ptr<EncryptionParameters> encp,
|
||||
int objid,
|
||||
int generation,
|
||||
bool use_aes)
|
||||
@ -1165,7 +1166,7 @@ QPDF::decryptString(std::string& str, int objid, int generation)
|
||||
} else {
|
||||
QTC::TC("qpdf", "QPDF_encryption rc4 decode string");
|
||||
size_t vlen = str.length();
|
||||
// Using PointerHolder guarantees that tmp will
|
||||
// Using std::shared_ptr guarantees that tmp will
|
||||
// be freed even if rc4.process throws an exception.
|
||||
auto tmp = QUtil::make_unique_cstr(str);
|
||||
RC4 rc4(QUtil::unsigned_char_pointer(key), toI(key.length()));
|
||||
@ -1188,8 +1189,8 @@ QPDF::decryptString(std::string& str, int objid, int generation)
|
||||
|
||||
void
|
||||
QPDF::decryptStream(
|
||||
PointerHolder<EncryptionParameters> encp,
|
||||
PointerHolder<InputSource> file,
|
||||
std::shared_ptr<EncryptionParameters> encp,
|
||||
std::shared_ptr<InputSource> file,
|
||||
QPDF& qpdf_for_warning,
|
||||
Pipeline*& pipeline,
|
||||
int objid,
|
||||
|
@ -2120,7 +2120,7 @@ QPDF::generateHintStream(
|
||||
std::map<int, QPDFXRefEntry> const& xref,
|
||||
std::map<int, qpdf_offset_t> const& lengths,
|
||||
std::map<int, int> const& obj_renumber,
|
||||
PointerHolder<Buffer>& hint_buffer,
|
||||
std::shared_ptr<Buffer>& hint_buffer,
|
||||
int& S,
|
||||
int& O)
|
||||
{
|
||||
|
@ -445,7 +445,7 @@ QUtil::os_wrapper(std::string const& description, int status)
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static PointerHolder<wchar_t>
|
||||
static std::shared_ptr<wchar_t>
|
||||
win_convert_filename(char const* filename)
|
||||
{
|
||||
// Convert the utf-8 encoded filename argument to wchar_t*. First,
|
||||
@ -454,7 +454,7 @@ win_convert_filename(char const* filename)
|
||||
std::string u16 = QUtil::utf8_to_utf16(filename);
|
||||
size_t len = u16.length();
|
||||
size_t wlen = (len / 2) - 1;
|
||||
PointerHolder<wchar_t> wfilenamep(true, new wchar_t[wlen + 1]);
|
||||
auto wfilenamep = QUtil::make_shared_array<wchar_t>(wlen + 1);
|
||||
wchar_t* wfilename = wfilenamep.get();
|
||||
wfilename[wlen] = 0;
|
||||
for (unsigned int i = 2; i < len; i += 2) {
|
||||
@ -471,9 +471,9 @@ QUtil::safe_fopen(char const* filename, char const* mode)
|
||||
{
|
||||
FILE* f = 0;
|
||||
#ifdef _WIN32
|
||||
PointerHolder<wchar_t> wfilenamep = win_convert_filename(filename);
|
||||
std::shared_ptr<wchar_t> wfilenamep = win_convert_filename(filename);
|
||||
wchar_t* wfilename = wfilenamep.get();
|
||||
PointerHolder<wchar_t> wmodep(true, new wchar_t[strlen(mode) + 1]);
|
||||
auto wmodep = QUtil::make_shared_array<wchar_t>(strlen(mode) + 1);
|
||||
wchar_t* wmode = wmodep.get();
|
||||
wmode[strlen(mode)] = 0;
|
||||
for (size_t i = 0; i < strlen(mode); ++i) {
|
||||
@ -612,7 +612,7 @@ void
|
||||
QUtil::remove_file(char const* path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
PointerHolder<wchar_t> wpath = win_convert_filename(path);
|
||||
std::shared_ptr<wchar_t> wpath = win_convert_filename(path);
|
||||
os_wrapper(std::string("remove ") + path, _wunlink(wpath.get()));
|
||||
#else
|
||||
os_wrapper(std::string("remove ") + path, unlink(path));
|
||||
@ -628,8 +628,8 @@ QUtil::rename_file(char const* oldname, char const* newname)
|
||||
} catch (QPDFSystemError&) {
|
||||
// ignore
|
||||
}
|
||||
PointerHolder<wchar_t> wold = win_convert_filename(oldname);
|
||||
PointerHolder<wchar_t> wnew = win_convert_filename(newname);
|
||||
std::shared_ptr<wchar_t> wold = win_convert_filename(oldname);
|
||||
std::shared_ptr<wchar_t> wnew = win_convert_filename(newname);
|
||||
os_wrapper(
|
||||
std::string("rename ") + oldname + " " + newname,
|
||||
_wrename(wold.get(), wnew.get()));
|
||||
@ -824,7 +824,7 @@ QUtil::get_env(std::string const& var, std::string* value)
|
||||
}
|
||||
|
||||
if (value) {
|
||||
PointerHolder<char> t = PointerHolder<char>(true, new char[len + 1]);
|
||||
auto t = QUtil::make_shared_array<char>(len + 1);
|
||||
::GetEnvironmentVariable(var.c_str(), t.get(), len);
|
||||
*value = t.get();
|
||||
}
|
||||
@ -1173,14 +1173,14 @@ QUtil::is_number(char const* p)
|
||||
|
||||
void
|
||||
QUtil::read_file_into_memory(
|
||||
char const* filename, PointerHolder<char>& file_buf, size_t& size)
|
||||
char const* filename, std::shared_ptr<char>& file_buf, size_t& size)
|
||||
{
|
||||
FILE* f = safe_fopen(filename, "rb");
|
||||
FileCloser fc(f);
|
||||
fseek(f, 0, SEEK_END);
|
||||
size = QIntC::to_size(QUtil::tell(f));
|
||||
fseek(f, 0, SEEK_SET);
|
||||
file_buf = make_array_pointer_holder<char>(size);
|
||||
file_buf = QUtil::make_shared_array<char>(size);
|
||||
char* buf_p = file_buf.get();
|
||||
size_t bytes_read = 0;
|
||||
size_t len = 0;
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
struct _qpdf_error
|
||||
{
|
||||
PointerHolder<QPDFExc> exc;
|
||||
std::shared_ptr<QPDFExc> exc;
|
||||
};
|
||||
|
||||
struct _qpdf_data
|
||||
@ -26,10 +26,10 @@ struct _qpdf_data
|
||||
_qpdf_data();
|
||||
~_qpdf_data();
|
||||
|
||||
PointerHolder<QPDF> qpdf;
|
||||
PointerHolder<QPDFWriter> qpdf_writer;
|
||||
std::shared_ptr<QPDF> qpdf;
|
||||
std::shared_ptr<QPDFWriter> qpdf_writer;
|
||||
|
||||
PointerHolder<QPDFExc> error;
|
||||
std::shared_ptr<QPDFExc> error;
|
||||
_qpdf_error tmp_error;
|
||||
std::list<QPDFExc> warnings;
|
||||
std::string tmp_string;
|
||||
@ -40,12 +40,12 @@ struct _qpdf_data
|
||||
unsigned long long size;
|
||||
char const* password;
|
||||
bool write_memory;
|
||||
PointerHolder<Buffer> output_buffer;
|
||||
std::shared_ptr<Buffer> output_buffer;
|
||||
|
||||
// QPDFObjectHandle support
|
||||
bool silence_errors;
|
||||
bool oh_error_occurred;
|
||||
std::map<qpdf_oh, PointerHolder<QPDFObjectHandle>> oh_cache;
|
||||
std::map<qpdf_oh, std::shared_ptr<QPDFObjectHandle>> oh_cache;
|
||||
qpdf_oh next_oh;
|
||||
std::set<std::string> cur_iter_dict_keys;
|
||||
std::set<std::string>::const_iterator dict_iter;
|
||||
@ -111,13 +111,13 @@ static void
|
||||
call_init_write(qpdf_data qpdf)
|
||||
{
|
||||
qpdf->qpdf_writer =
|
||||
make_pointer_holder<QPDFWriter>(*(qpdf->qpdf), qpdf->filename);
|
||||
std::make_shared<QPDFWriter>(*(qpdf->qpdf), qpdf->filename);
|
||||
}
|
||||
|
||||
static void
|
||||
call_init_write_memory(qpdf_data qpdf)
|
||||
{
|
||||
qpdf->qpdf_writer = make_pointer_holder<QPDFWriter>(*(qpdf->qpdf));
|
||||
qpdf->qpdf_writer = std::make_shared<QPDFWriter>(*(qpdf->qpdf));
|
||||
qpdf->qpdf_writer->setOutputMemory();
|
||||
}
|
||||
|
||||
@ -144,15 +144,15 @@ trap_errors(qpdf_data qpdf, std::function<void(qpdf_data)> fn)
|
||||
try {
|
||||
fn(qpdf);
|
||||
} catch (QPDFExc& e) {
|
||||
qpdf->error = make_pointer_holder<QPDFExc>(e);
|
||||
qpdf->error = std::make_shared<QPDFExc>(e);
|
||||
status |= QPDF_ERRORS;
|
||||
} catch (std::runtime_error& e) {
|
||||
qpdf->error =
|
||||
make_pointer_holder<QPDFExc>(qpdf_e_system, "", "", 0, e.what());
|
||||
std::make_shared<QPDFExc>(qpdf_e_system, "", "", 0, e.what());
|
||||
status |= QPDF_ERRORS;
|
||||
} catch (std::exception& e) {
|
||||
qpdf->error =
|
||||
make_pointer_holder<QPDFExc>(qpdf_e_internal, "", "", 0, e.what());
|
||||
std::make_shared<QPDFExc>(qpdf_e_internal, "", "", 0, e.what());
|
||||
status |= QPDF_ERRORS;
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ qpdf_init()
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c called qpdf_init");
|
||||
qpdf_data qpdf = new _qpdf_data();
|
||||
qpdf->qpdf = make_pointer_holder<QPDF>();
|
||||
qpdf->qpdf = std::make_shared<QPDF>();
|
||||
return qpdf;
|
||||
}
|
||||
|
||||
@ -241,8 +241,7 @@ qpdf_error
|
||||
qpdf_next_warning(qpdf_data qpdf)
|
||||
{
|
||||
if (qpdf_more_warnings(qpdf)) {
|
||||
qpdf->tmp_error.exc =
|
||||
make_pointer_holder<QPDFExc>(qpdf->warnings.front());
|
||||
qpdf->tmp_error.exc = std::make_shared<QPDFExc>(qpdf->warnings.front());
|
||||
qpdf->warnings.pop_front();
|
||||
QTC::TC("qpdf", "qpdf-c qpdf_next_warning returned warning");
|
||||
return &qpdf->tmp_error;
|
||||
@ -974,7 +973,7 @@ qpdf_register_progress_reporter(
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c registered progress reporter");
|
||||
qpdf->qpdf_writer->registerProgressReporter(
|
||||
PointerHolder<QPDFWriter::ProgressReporter>(
|
||||
std::shared_ptr<QPDFWriter::ProgressReporter>(
|
||||
new ProgressReporter(report_progress, data)));
|
||||
}
|
||||
|
||||
@ -1035,7 +1034,7 @@ static qpdf_oh
|
||||
new_object(qpdf_data qpdf, QPDFObjectHandle const& qoh)
|
||||
{
|
||||
qpdf_oh oh = ++qpdf->next_oh; // never return 0
|
||||
qpdf->oh_cache[oh] = make_pointer_holder<QPDFObjectHandle>(qoh);
|
||||
qpdf->oh_cache[oh] = std::make_shared<QPDFObjectHandle>(qoh);
|
||||
return oh;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ class JSONHandler
|
||||
|
||||
Handlers h;
|
||||
};
|
||||
PointerHolder<Members> m;
|
||||
std::shared_ptr<Members> m;
|
||||
};
|
||||
|
||||
#endif // JSONHANDLER_HH
|
||||
|
@ -10,7 +10,8 @@
|
||||
class OffsetInputSource: public InputSource
|
||||
{
|
||||
public:
|
||||
OffsetInputSource(PointerHolder<InputSource>, qpdf_offset_t global_offset);
|
||||
OffsetInputSource(
|
||||
std::shared_ptr<InputSource>, qpdf_offset_t global_offset);
|
||||
virtual ~OffsetInputSource();
|
||||
|
||||
virtual qpdf_offset_t findAndSkipNextEOL();
|
||||
@ -22,7 +23,7 @@ class OffsetInputSource: public InputSource
|
||||
virtual void unreadCh(char ch);
|
||||
|
||||
private:
|
||||
PointerHolder<InputSource> proxied;
|
||||
std::shared_ptr<InputSource> proxied;
|
||||
qpdf_offset_t global_offset;
|
||||
qpdf_offset_t max_safe_offset;
|
||||
};
|
||||
|
@ -46,8 +46,8 @@ class Pl_PNGFilter: public Pipeline
|
||||
unsigned int bytes_per_pixel;
|
||||
unsigned char* cur_row; // points to buf1 or buf2
|
||||
unsigned char* prev_row; // points to buf1 or buf2
|
||||
PointerHolder<unsigned char> buf1;
|
||||
PointerHolder<unsigned char> buf2;
|
||||
std::shared_ptr<unsigned char> buf1;
|
||||
std::shared_ptr<unsigned char> buf2;
|
||||
size_t pos;
|
||||
size_t incoming;
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ class Pl_RC4: public Pipeline
|
||||
virtual void finish();
|
||||
|
||||
private:
|
||||
PointerHolder<unsigned char> outbuf;
|
||||
std::shared_ptr<unsigned char> outbuf;
|
||||
size_t out_bufsize;
|
||||
RC4 rc4;
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ class Pl_TIFFPredictor: public Pipeline
|
||||
unsigned int bytes_per_row;
|
||||
unsigned int samples_per_pixel;
|
||||
unsigned int bits_per_sample;
|
||||
PointerHolder<unsigned char> cur_row;
|
||||
std::shared_ptr<unsigned char> cur_row;
|
||||
size_t pos;
|
||||
};
|
||||
|
||||
|
@ -37,8 +37,8 @@ class QPDF_Stream: public QPDFObject
|
||||
// Methods to help QPDF copy foreign streams
|
||||
qpdf_offset_t getOffset() const;
|
||||
size_t getLength() const;
|
||||
PointerHolder<Buffer> getStreamDataBuffer() const;
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider>
|
||||
std::shared_ptr<Buffer> getStreamDataBuffer() const;
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider>
|
||||
getStreamDataProvider() const;
|
||||
|
||||
// See comments in QPDFObjectHandle.hh for these methods.
|
||||
@ -49,18 +49,18 @@ class QPDF_Stream: public QPDFObject
|
||||
qpdf_stream_decode_level_e decode_level,
|
||||
bool suppress_warnings,
|
||||
bool will_retry);
|
||||
PointerHolder<Buffer> getStreamData(qpdf_stream_decode_level_e);
|
||||
PointerHolder<Buffer> getRawStreamData();
|
||||
std::shared_ptr<Buffer> getStreamData(qpdf_stream_decode_level_e);
|
||||
std::shared_ptr<Buffer> getRawStreamData();
|
||||
void replaceStreamData(
|
||||
PointerHolder<Buffer> data,
|
||||
std::shared_ptr<Buffer> data,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms);
|
||||
void replaceStreamData(
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> provider,
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms);
|
||||
void
|
||||
addTokenFilter(PointerHolder<QPDFObjectHandle::TokenFilter> token_filter);
|
||||
addTokenFilter(std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter);
|
||||
|
||||
void replaceDict(QPDFObjectHandle new_dict);
|
||||
|
||||
@ -101,9 +101,9 @@ class QPDF_Stream: public QPDFObject
|
||||
QPDFObjectHandle stream_dict;
|
||||
qpdf_offset_t offset;
|
||||
size_t length;
|
||||
PointerHolder<Buffer> stream_data;
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> stream_provider;
|
||||
std::vector<PointerHolder<QPDFObjectHandle::TokenFilter>> token_filters;
|
||||
std::shared_ptr<Buffer> stream_data;
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> stream_provider;
|
||||
std::vector<std::shared_ptr<QPDFObjectHandle::TokenFilter>> token_filters;
|
||||
};
|
||||
|
||||
#endif // QPDF_STREAM_HH
|
||||
|
Loading…
Reference in New Issue
Block a user