From ce435222b2ae95645a1a0f79a8b1fca443ed3724 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 21 Aug 2017 21:33:52 -0400 Subject: Push QPDFWriter member variables into a nested class --- include/qpdf/QPDFWriter.hh | 148 +++++++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 66 deletions(-) (limited to 'include') diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index bca9c168..6114669c 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -374,7 +374,6 @@ class QPDFWriter enum trailer_e { t_normal, t_lin_first, t_lin_second }; - void init(); int bytesNeeded(unsigned long long n); void writeBinary(unsigned long long val, unsigned int bytes); void writeString(std::string const& str); @@ -483,71 +482,88 @@ class QPDFWriter void discardGeneration(std::map const& in, std::map& out); - QPDF& pdf; - char const* filename; - FILE* file; - bool close_file; - Pl_Buffer* buffer_pipeline; - Buffer* output_buffer; - bool normalize_content_set; - bool normalize_content; - bool compress_streams; - bool compress_streams_set; - qpdf_stream_decode_level_e stream_decode_level; - bool stream_decode_level_set; - bool qdf_mode; - bool preserve_unreferenced_objects; - bool newline_before_endstream; - bool static_id; - bool suppress_original_object_ids; - bool direct_stream_lengths; - bool encrypted; - bool preserve_encryption; - bool linearized; - bool pclm; - qpdf_object_stream_e object_stream_mode; - std::string encryption_key; - bool encrypt_metadata; - bool encrypt_use_aes; - std::map encryption_dictionary; - int encryption_V; - int encryption_R; - - std::string id1; // for /ID key of - std::string id2; // trailer dictionary - std::string final_pdf_version; - int final_extension_level; - std::string min_pdf_version; - int min_extension_level; - std::string forced_pdf_version; - int forced_extension_level; - std::string extra_header_text; - int encryption_dict_objid; - std::string cur_data_key; - std::list > to_delete; - Pl_Count* pipeline; - std::list object_queue; - std::map obj_renumber; - std::map xref; - std::map lengths; - int next_objid; - int cur_stream_length_id; - size_t cur_stream_length; - bool added_newline; - int max_ostream_index; - std::set normalized_streams; - std::map page_object_to_seq; - std::map contents_to_page_seq; - std::map object_to_object_stream; - std::map > object_stream_to_objects; - std::list pipeline_stack; - bool deterministic_id; - Pl_MD5* md5_pipeline; - std::string deterministic_id_data; - - // For linearization only - std::map obj_renumber_no_gen; - std::map object_to_object_stream_no_gen; + class Members + { + friend class QPDFWriter; + + public: + ~Members(); + + private: + Members(QPDF& pdf); + Members(Members const&); + + QPDF& pdf; + char const* filename; + FILE* file; + bool close_file; + Pl_Buffer* buffer_pipeline; + Buffer* output_buffer; + bool normalize_content_set; + bool normalize_content; + bool compress_streams; + bool compress_streams_set; + qpdf_stream_decode_level_e stream_decode_level; + bool stream_decode_level_set; + bool qdf_mode; + bool preserve_unreferenced_objects; + bool newline_before_endstream; + bool static_id; + bool suppress_original_object_ids; + bool direct_stream_lengths; + bool encrypted; + bool preserve_encryption; + bool linearized; + bool pclm; + qpdf_object_stream_e object_stream_mode; + std::string encryption_key; + bool encrypt_metadata; + bool encrypt_use_aes; + std::map encryption_dictionary; + int encryption_V; + int encryption_R; + + std::string id1; // for /ID key of + std::string id2; // trailer dictionary + std::string final_pdf_version; + int final_extension_level; + std::string min_pdf_version; + int min_extension_level; + std::string forced_pdf_version; + int forced_extension_level; + std::string extra_header_text; + int encryption_dict_objid; + std::string cur_data_key; + std::list > to_delete; + Pl_Count* pipeline; + std::list object_queue; + std::map obj_renumber; + std::map xref; + std::map lengths; + int next_objid; + int cur_stream_length_id; + size_t cur_stream_length; + bool added_newline; + int max_ostream_index; + std::set normalized_streams; + std::map page_object_to_seq; + std::map contents_to_page_seq; + std::map object_to_object_stream; + std::map > object_stream_to_objects; + std::list pipeline_stack; + bool deterministic_id; + Pl_MD5* md5_pipeline; + std::string deterministic_id_data; + + // For linearization only + std::map obj_renumber_no_gen; + std::map object_to_object_stream_no_gen; + }; + + // 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 m; }; #endif // __QPDFWRITER_HH__ -- cgit v1.2.3-54-g00ecf