Commit acfc9db0515559cdcc56104ba1ec2082b09b0b8f
1 parent
d16308b3
QPDFJob: switch to C++11-style field initializers
Showing
2 changed files
with
112 additions
and
218 deletions
include/qpdf/QPDFJob.hh
| ... | ... | @@ -586,135 +586,142 @@ class QPDFJob |
| 586 | 586 | ~Members() = default; |
| 587 | 587 | |
| 588 | 588 | private: |
| 589 | + // These default values are duplicated in help and docs. | |
| 590 | + static int constexpr DEFAULT_KEEP_FILES_OPEN_THRESHOLD = 200; | |
| 591 | + static int constexpr DEFAULT_OI_MIN_WIDTH = 128; | |
| 592 | + static int constexpr DEFAULT_OI_MIN_HEIGHT = 128; | |
| 593 | + static int constexpr DEFAULT_OI_MIN_AREA = 16384; | |
| 594 | + static int constexpr DEFAULT_II_MIN_BYTES = 1024; | |
| 595 | + | |
| 589 | 596 | Members(); |
| 590 | 597 | Members(Members const&) = delete; |
| 591 | 598 | |
| 592 | 599 | std::shared_ptr<QPDFLogger> log; |
| 593 | - std::string message_prefix; | |
| 594 | - bool warnings; | |
| 595 | - unsigned long encryption_status; | |
| 596 | - bool verbose; | |
| 600 | + std::string message_prefix{"qpdf"}; | |
| 601 | + bool warnings{false}; | |
| 602 | + unsigned long encryption_status{0}; | |
| 603 | + bool verbose{false}; | |
| 597 | 604 | std::shared_ptr<char> password; |
| 598 | - bool linearize; | |
| 599 | - bool decrypt; | |
| 600 | - int split_pages; | |
| 601 | - bool progress; | |
| 602 | - std::function<void(int)> progress_handler; | |
| 603 | - bool suppress_warnings; | |
| 604 | - bool warnings_exit_zero; | |
| 605 | - bool copy_encryption; | |
| 605 | + bool linearize{false}; | |
| 606 | + bool decrypt{false}; | |
| 607 | + int split_pages{0}; | |
| 608 | + bool progress{false}; | |
| 609 | + std::function<void(int)> progress_handler{nullptr}; | |
| 610 | + bool suppress_warnings{false}; | |
| 611 | + bool warnings_exit_zero{false}; | |
| 612 | + bool copy_encryption{false}; | |
| 606 | 613 | std::string encryption_file; |
| 607 | 614 | std::shared_ptr<char> encryption_file_password; |
| 608 | - bool encrypt; | |
| 609 | - bool password_is_hex_key; | |
| 610 | - bool suppress_password_recovery; | |
| 611 | - password_mode_e password_mode; | |
| 612 | - bool allow_insecure; | |
| 613 | - bool allow_weak_crypto; | |
| 615 | + bool encrypt{false}; | |
| 616 | + bool password_is_hex_key{false}; | |
| 617 | + bool suppress_password_recovery{false}; | |
| 618 | + password_mode_e password_mode{pm_auto}; | |
| 619 | + bool allow_insecure{false}; | |
| 620 | + bool allow_weak_crypto{false}; | |
| 614 | 621 | std::string user_password; |
| 615 | 622 | std::string owner_password; |
| 616 | - int keylen; | |
| 617 | - bool r2_print; | |
| 618 | - bool r2_modify; | |
| 619 | - bool r2_extract; | |
| 620 | - bool r2_annotate; | |
| 621 | - bool r3_accessibility; | |
| 622 | - bool r3_extract; | |
| 623 | - bool r3_assemble; | |
| 624 | - bool r3_annotate_and_form; | |
| 625 | - bool r3_form_filling; | |
| 626 | - bool r3_modify_other; | |
| 627 | - qpdf_r3_print_e r3_print; | |
| 628 | - bool force_V4; | |
| 629 | - bool force_R5; | |
| 630 | - bool cleartext_metadata; | |
| 631 | - bool use_aes; | |
| 632 | - bool stream_data_set; | |
| 633 | - qpdf_stream_data_e stream_data_mode; | |
| 634 | - bool compress_streams; | |
| 635 | - bool compress_streams_set; | |
| 636 | - bool recompress_flate; | |
| 637 | - bool recompress_flate_set; | |
| 638 | - int compression_level; | |
| 639 | - qpdf_stream_decode_level_e decode_level; | |
| 640 | - bool decode_level_set; | |
| 641 | - bool normalize_set; | |
| 642 | - bool normalize; | |
| 643 | - bool suppress_recovery; | |
| 644 | - bool object_stream_set; | |
| 645 | - qpdf_object_stream_e object_stream_mode; | |
| 646 | - bool ignore_xref_streams; | |
| 647 | - bool qdf_mode; | |
| 648 | - bool preserve_unreferenced_objects; | |
| 649 | - remove_unref_e remove_unreferenced_page_resources; | |
| 650 | - bool keep_files_open; | |
| 651 | - bool keep_files_open_set; | |
| 652 | - size_t keep_files_open_threshold; | |
| 653 | - bool newline_before_endstream; | |
| 623 | + int keylen{0}; | |
| 624 | + bool r2_print{true}; | |
| 625 | + bool r2_modify{true}; | |
| 626 | + bool r2_extract{true}; | |
| 627 | + bool r2_annotate{true}; | |
| 628 | + bool r3_accessibility{true}; | |
| 629 | + bool r3_extract{true}; | |
| 630 | + bool r3_assemble{true}; | |
| 631 | + bool r3_annotate_and_form{true}; | |
| 632 | + bool r3_form_filling{true}; | |
| 633 | + bool r3_modify_other{true}; | |
| 634 | + qpdf_r3_print_e r3_print{qpdf_r3p_full}; | |
| 635 | + bool force_V4{false}; | |
| 636 | + bool force_R5{false}; | |
| 637 | + bool cleartext_metadata{false}; | |
| 638 | + bool use_aes{false}; | |
| 639 | + bool stream_data_set{false}; | |
| 640 | + qpdf_stream_data_e stream_data_mode{qpdf_s_compress}; | |
| 641 | + bool compress_streams{true}; | |
| 642 | + bool compress_streams_set{false}; | |
| 643 | + bool recompress_flate{false}; | |
| 644 | + bool recompress_flate_set{false}; | |
| 645 | + int compression_level{-1}; | |
| 646 | + qpdf_stream_decode_level_e decode_level{qpdf_dl_generalized}; | |
| 647 | + bool decode_level_set{false}; | |
| 648 | + bool normalize_set{false}; | |
| 649 | + bool normalize{false}; | |
| 650 | + bool suppress_recovery{false}; | |
| 651 | + bool object_stream_set{false}; | |
| 652 | + qpdf_object_stream_e object_stream_mode{qpdf_o_preserve}; | |
| 653 | + bool ignore_xref_streams{false}; | |
| 654 | + bool qdf_mode{false}; | |
| 655 | + bool preserve_unreferenced_objects{false}; | |
| 656 | + remove_unref_e remove_unreferenced_page_resources{re_auto}; | |
| 657 | + bool keep_files_open{true}; | |
| 658 | + bool keep_files_open_set{false}; | |
| 659 | + size_t keep_files_open_threshold{DEFAULT_KEEP_FILES_OPEN_THRESHOLD}; | |
| 660 | + bool newline_before_endstream{false}; | |
| 654 | 661 | std::string linearize_pass1; |
| 655 | - bool coalesce_contents; | |
| 656 | - bool flatten_annotations; | |
| 657 | - int flatten_annotations_required; | |
| 658 | - int flatten_annotations_forbidden; | |
| 659 | - bool generate_appearances; | |
| 662 | + bool coalesce_contents{false}; | |
| 663 | + bool flatten_annotations{false}; | |
| 664 | + int flatten_annotations_required{0}; | |
| 665 | + int flatten_annotations_forbidden{an_invisible | an_hidden}; | |
| 666 | + bool generate_appearances{false}; | |
| 660 | 667 | PDFVersion max_input_version; |
| 661 | 668 | std::string min_version; |
| 662 | 669 | std::string force_version; |
| 663 | - bool show_npages; | |
| 664 | - bool deterministic_id; | |
| 665 | - bool static_id; | |
| 666 | - bool static_aes_iv; | |
| 667 | - bool suppress_original_object_id; | |
| 668 | - bool show_encryption; | |
| 669 | - bool show_encryption_key; | |
| 670 | - bool check_linearization; | |
| 671 | - bool show_linearization; | |
| 672 | - bool show_xref; | |
| 673 | - bool show_trailer; | |
| 674 | - int show_obj; | |
| 675 | - int show_gen; | |
| 676 | - bool show_raw_stream_data; | |
| 677 | - bool show_filtered_stream_data; | |
| 678 | - bool show_pages; | |
| 679 | - bool show_page_images; | |
| 680 | - size_t collate; | |
| 681 | - bool flatten_rotation; | |
| 682 | - bool list_attachments; | |
| 670 | + bool show_npages{false}; | |
| 671 | + bool deterministic_id{false}; | |
| 672 | + bool static_id{false}; | |
| 673 | + bool static_aes_iv{false}; | |
| 674 | + bool suppress_original_object_id{false}; | |
| 675 | + bool show_encryption{false}; | |
| 676 | + bool show_encryption_key{false}; | |
| 677 | + bool check_linearization{false}; | |
| 678 | + bool show_linearization{false}; | |
| 679 | + bool show_xref{false}; | |
| 680 | + bool show_trailer{false}; | |
| 681 | + int show_obj{0}; | |
| 682 | + int show_gen{0}; | |
| 683 | + bool show_raw_stream_data{false}; | |
| 684 | + bool show_filtered_stream_data{false}; | |
| 685 | + bool show_pages{false}; | |
| 686 | + bool show_page_images{false}; | |
| 687 | + size_t collate{0}; | |
| 688 | + bool flatten_rotation{false}; | |
| 689 | + bool list_attachments{false}; | |
| 683 | 690 | std::string attachment_to_show; |
| 684 | 691 | std::list<std::string> attachments_to_remove; |
| 685 | 692 | std::list<AddAttachment> attachments_to_add; |
| 686 | 693 | std::list<CopyAttachmentFrom> attachments_to_copy; |
| 687 | - int json_version; | |
| 694 | + int json_version{0}; | |
| 688 | 695 | std::set<std::string> json_keys; |
| 689 | 696 | std::set<std::string> json_objects; |
| 690 | - qpdf_json_stream_data_e json_stream_data; | |
| 691 | - bool json_stream_data_set; | |
| 697 | + qpdf_json_stream_data_e json_stream_data{qpdf_sj_none}; | |
| 698 | + bool json_stream_data_set{false}; | |
| 692 | 699 | std::string json_stream_prefix; |
| 693 | - bool test_json_schema; | |
| 694 | - bool check; | |
| 695 | - bool optimize_images; | |
| 696 | - bool externalize_inline_images; | |
| 697 | - bool keep_inline_images; | |
| 698 | - bool remove_page_labels; | |
| 699 | - size_t oi_min_width; | |
| 700 | - size_t oi_min_height; | |
| 701 | - size_t oi_min_area; | |
| 702 | - size_t ii_min_bytes; | |
| 703 | - UnderOverlay underlay; | |
| 704 | - UnderOverlay overlay; | |
| 705 | - UnderOverlay* under_overlay; | |
| 700 | + bool test_json_schema{false}; | |
| 701 | + bool check{false}; | |
| 702 | + bool optimize_images{false}; | |
| 703 | + bool externalize_inline_images{false}; | |
| 704 | + bool keep_inline_images{false}; | |
| 705 | + bool remove_page_labels{false}; | |
| 706 | + size_t oi_min_width{DEFAULT_OI_MIN_WIDTH}; | |
| 707 | + size_t oi_min_height{DEFAULT_OI_MIN_HEIGHT}; | |
| 708 | + size_t oi_min_area{DEFAULT_OI_MIN_AREA}; | |
| 709 | + size_t ii_min_bytes{DEFAULT_II_MIN_BYTES}; | |
| 710 | + UnderOverlay underlay{"underlay"}; | |
| 711 | + UnderOverlay overlay{"overlay"}; | |
| 712 | + UnderOverlay* under_overlay{nullptr}; | |
| 706 | 713 | std::vector<PageSpec> page_specs; |
| 707 | 714 | std::map<std::string, RotationSpec> rotations; |
| 708 | - bool require_outfile; | |
| 709 | - bool replace_input; | |
| 710 | - bool check_is_encrypted; | |
| 711 | - bool check_requires_password; | |
| 715 | + bool require_outfile{true}; | |
| 716 | + bool replace_input{false}; | |
| 717 | + bool check_is_encrypted{false}; | |
| 718 | + bool check_requires_password{false}; | |
| 712 | 719 | std::shared_ptr<char> infilename; |
| 713 | 720 | std::shared_ptr<char> outfilename; |
| 714 | - bool json_input; | |
| 715 | - bool json_output; | |
| 721 | + bool json_input{false}; | |
| 722 | + bool json_output{false}; | |
| 716 | 723 | std::string update_from_json; |
| 717 | - bool report_mem_usage; | |
| 724 | + bool report_mem_usage{false}; | |
| 718 | 725 | }; |
| 719 | 726 | std::shared_ptr<Members> m; |
| 720 | 727 | }; | ... | ... |
libqpdf/QPDFJob.cc
| ... | ... | @@ -304,121 +304,8 @@ ProgressReporter::reportProgress(int percentage) |
| 304 | 304 | << "%\n"; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | -// These default values are duplicated in help and docs. | |
| 308 | -static int constexpr DEFAULT_KEEP_FILES_OPEN_THRESHOLD = 200; | |
| 309 | -static int constexpr DEFAULT_OI_MIN_WIDTH = 128; | |
| 310 | -static int constexpr DEFAULT_OI_MIN_HEIGHT = 128; | |
| 311 | -static int constexpr DEFAULT_OI_MIN_AREA = 16384; | |
| 312 | -static int constexpr DEFAULT_II_MIN_BYTES = 1024; | |
| 313 | - | |
| 314 | 307 | QPDFJob::Members::Members() : |
| 315 | - log(QPDFLogger::defaultLogger()), | |
| 316 | - message_prefix("qpdf"), | |
| 317 | - warnings(false), | |
| 318 | - encryption_status(0), | |
| 319 | - verbose(false), | |
| 320 | - password(nullptr), | |
| 321 | - linearize(false), | |
| 322 | - decrypt(false), | |
| 323 | - split_pages(0), | |
| 324 | - progress(false), | |
| 325 | - progress_handler(nullptr), | |
| 326 | - suppress_warnings(false), | |
| 327 | - warnings_exit_zero(false), | |
| 328 | - copy_encryption(false), | |
| 329 | - encryption_file_password(nullptr), | |
| 330 | - encrypt(false), | |
| 331 | - password_is_hex_key(false), | |
| 332 | - suppress_password_recovery(false), | |
| 333 | - password_mode(pm_auto), | |
| 334 | - allow_insecure(false), | |
| 335 | - allow_weak_crypto(false), | |
| 336 | - keylen(0), | |
| 337 | - r2_print(true), | |
| 338 | - r2_modify(true), | |
| 339 | - r2_extract(true), | |
| 340 | - r2_annotate(true), | |
| 341 | - r3_accessibility(true), | |
| 342 | - r3_extract(true), | |
| 343 | - r3_assemble(true), | |
| 344 | - r3_annotate_and_form(true), | |
| 345 | - r3_form_filling(true), | |
| 346 | - r3_modify_other(true), | |
| 347 | - r3_print(qpdf_r3p_full), | |
| 348 | - force_V4(false), | |
| 349 | - force_R5(false), | |
| 350 | - cleartext_metadata(false), | |
| 351 | - use_aes(false), | |
| 352 | - stream_data_set(false), | |
| 353 | - stream_data_mode(qpdf_s_compress), | |
| 354 | - compress_streams(true), | |
| 355 | - compress_streams_set(false), | |
| 356 | - recompress_flate(false), | |
| 357 | - recompress_flate_set(false), | |
| 358 | - compression_level(-1), | |
| 359 | - decode_level(qpdf_dl_generalized), | |
| 360 | - decode_level_set(false), | |
| 361 | - normalize_set(false), | |
| 362 | - normalize(false), | |
| 363 | - suppress_recovery(false), | |
| 364 | - object_stream_set(false), | |
| 365 | - object_stream_mode(qpdf_o_preserve), | |
| 366 | - ignore_xref_streams(false), | |
| 367 | - qdf_mode(false), | |
| 368 | - preserve_unreferenced_objects(false), | |
| 369 | - remove_unreferenced_page_resources(re_auto), | |
| 370 | - keep_files_open(true), | |
| 371 | - keep_files_open_set(false), | |
| 372 | - keep_files_open_threshold(DEFAULT_KEEP_FILES_OPEN_THRESHOLD), | |
| 373 | - newline_before_endstream(false), | |
| 374 | - coalesce_contents(false), | |
| 375 | - flatten_annotations(false), | |
| 376 | - flatten_annotations_required(0), | |
| 377 | - flatten_annotations_forbidden(an_invisible | an_hidden), | |
| 378 | - generate_appearances(false), | |
| 379 | - show_npages(false), | |
| 380 | - deterministic_id(false), | |
| 381 | - static_id(false), | |
| 382 | - static_aes_iv(false), | |
| 383 | - suppress_original_object_id(false), | |
| 384 | - show_encryption(false), | |
| 385 | - show_encryption_key(false), | |
| 386 | - check_linearization(false), | |
| 387 | - show_linearization(false), | |
| 388 | - show_xref(false), | |
| 389 | - show_trailer(false), | |
| 390 | - show_obj(0), | |
| 391 | - show_gen(0), | |
| 392 | - show_raw_stream_data(false), | |
| 393 | - show_filtered_stream_data(false), | |
| 394 | - show_pages(false), | |
| 395 | - show_page_images(false), | |
| 396 | - collate(0), | |
| 397 | - flatten_rotation(false), | |
| 398 | - list_attachments(false), | |
| 399 | - json_version(0), | |
| 400 | - json_stream_data(qpdf_sj_none), | |
| 401 | - json_stream_data_set(false), | |
| 402 | - test_json_schema(false), | |
| 403 | - check(false), | |
| 404 | - optimize_images(false), | |
| 405 | - externalize_inline_images(false), | |
| 406 | - keep_inline_images(false), | |
| 407 | - remove_page_labels(false), | |
| 408 | - oi_min_width(DEFAULT_OI_MIN_WIDTH), | |
| 409 | - oi_min_height(DEFAULT_OI_MIN_HEIGHT), | |
| 410 | - oi_min_area(DEFAULT_OI_MIN_AREA), | |
| 411 | - ii_min_bytes(DEFAULT_II_MIN_BYTES), | |
| 412 | - underlay("underlay"), | |
| 413 | - overlay("overlay"), | |
| 414 | - under_overlay(nullptr), | |
| 415 | - require_outfile(true), | |
| 416 | - replace_input(false), | |
| 417 | - check_is_encrypted(false), | |
| 418 | - check_requires_password(false), | |
| 419 | - json_input(false), | |
| 420 | - json_output(false), | |
| 421 | - report_mem_usage(false) | |
| 308 | + log(QPDFLogger::defaultLogger()) | |
| 422 | 309 | { |
| 423 | 310 | } |
| 424 | 311 | ... | ... |