diff options
author | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2023-06-17 15:26:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-17 15:26:16 +0200 |
commit | 44dce4e2988ec09e36dfb6d1fc527a143e6f597f (patch) | |
tree | 3cdb1999faeb5103eb87c36fb1673d8cbb5ab082 /libqpdf/QPDFJob_json.cc | |
parent | fc30e75122f6bef20ac8d676ac7cb8822feecf3e (diff) | |
parent | acd0acf16931ce92bc908e4960c5a1e43d53b550 (diff) | |
download | qpdf-44dce4e2988ec09e36dfb6d1fc527a143e6f597f.tar.zst |
Merge pull request #978 from m-holger/reflow
Code tidy - reflow comments and strings
Diffstat (limited to 'libqpdf/QPDFJob_json.cc')
-rw-r--r-- | libqpdf/QPDFJob_json.cc | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc index 126f9a13..92488df1 100644 --- a/libqpdf/QPDFJob_json.cc +++ b/libqpdf/QPDFJob_json.cc @@ -30,27 +30,20 @@ namespace typedef std::function<void(char const*)> param_handler_t; typedef std::function<void(JSON)> json_handler_t; - // The code that calls these methods is automatically - // generated by generate_auto_job. This describes how we - // implement what it does. We keep a stack of handlers in - // json_handlers. The top of the stack is the "current" json - // handler, intially for the top-level object. Whenever we - // encounter a scalar, we add a handler using addBare, - // addParameter, or addChoices. Whenever we encounter a - // dictionary, we first add the dictionary handlers. Then we - // walk into the dictionary and, for each key, we register a - // dict key handler and push it to the stack, then do the same - // process for the key's value. Then we pop the key handler - // off the stack. When we encounter an array, we add the array - // handlers, push an item handler to the stack, call - // recursively for the array's single item (as this is what is - // expected in a schema), and pop the item handler. Note that - // we don't pop dictionary start/end handlers. The dictionary - // handlers and the key handlers are at the same level in - // JSONHandler. This logic is subtle and took several tries to - // get right. It's best understood by carefully understanding - // the behavior of JSONHandler, the JSON schema, and the code - // in generate_auto_job. + // The code that calls these methods is automatically generated by generate_auto_job. This + // describes how we implement what it does. We keep a stack of handlers in json_handlers. + // The top of the stack is the "current" json handler, intially for the top-level object. + // Whenever we encounter a scalar, we add a handler using addBare, addParameter, or + // addChoices. Whenever we encounter a dictionary, we first add the dictionary handlers. + // Then we walk into the dictionary and, for each key, we register a dict key handler and + // push it to the stack, then do the same process for the key's value. Then we pop the key + // handler off the stack. When we encounter an array, we add the array handlers, push an + // item handler to the stack, call recursively for the array's single item (as this is what + // is expected in a schema), and pop the item handler. Note that we don't pop dictionary + // start/end handlers. The dictionary handlers and the key handlers are at the same level in + // JSONHandler. This logic is subtle and took several tries to get right. It's best + // understood by carefully understanding the behavior of JSONHandler, the JSON schema, and + // the code in generate_auto_job. void addBare(bare_handler_t); void addParameter(param_handler_t); @@ -261,9 +254,8 @@ Handlers::setupReplaceInput() void Handlers::beginEncrypt(JSON j) { - // This method is only called if the overall JSON structure - // matches the schema, so we already know that keys that are - // present have the right types. + // This method is only called if the overall JSON structure matches the schema, so we already + // know that keys that are present have the right types. int key_len = 0; std::string user_password; std::string owner_password; @@ -284,14 +276,13 @@ Handlers::beginEncrypt(JSON j) }); if (key_len == 0) { QTC::TC("qpdf", "QPDFJob json encrypt no key length"); - usage("exactly one of 40bit, 128bit, or 256bit must be given;" - " an empty dictionary may be supplied for one of them" - " to set the key length without imposing any restrictions"); + usage("exactly one of 40bit, 128bit, or 256bit must be given; an empty dictionary may be " + "supplied for one of them to set the key length without imposing any restrictions"); } if (!(user_password_seen && owner_password_seen)) { QTC::TC("qpdf", "QPDFJob json encrypt missing password"); - usage("the user and owner password are both required; use the empty" - " string for the user password if you don't want a password"); + usage("the user and owner password are both required; use the empty string for the user " + "password if you don't want a password"); } this->c_enc = c_main->encrypt(key_len, user_password, owner_password); } |