feat: support line wrapping for Binary in literal syntax#1455
Open
sxrzh wants to merge 3 commits into
Open
Conversation
SGSSGene
requested changes
Jul 3, 2026
SGSSGene
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for this PR! this finally makes larger binary data possible!
Comment on lines
+550
to
+563
| if(wrap) { | ||
| if(wrap <= indent) return false; | ||
| wrap -= indent; | ||
| std::size_t point = wrap; | ||
| for(std::size_t i = 0; i < encoded.size(); i++) { | ||
| if(i == point) { | ||
| wrapped += '\n'; | ||
| point += wrap; | ||
| } | ||
| wrapped += encoded[i]; | ||
| } | ||
| } | ||
| else | ||
| wrapped = encoded; |
Collaborator
There was a problem hiding this comment.
Minor: add spaces after if and for. Also added curly brackets for the else case.
Suggested change
| if(wrap) { | |
| if(wrap <= indent) return false; | |
| wrap -= indent; | |
| std::size_t point = wrap; | |
| for(std::size_t i = 0; i < encoded.size(); i++) { | |
| if(i == point) { | |
| wrapped += '\n'; | |
| point += wrap; | |
| } | |
| wrapped += encoded[i]; | |
| } | |
| } | |
| else | |
| wrapped = encoded; | |
| if (wrap) { | |
| if (wrap <= indent) return false; | |
| wrap -= indent; | |
| std::size_t point = wrap; | |
| for (std::size_t i = 0; i < encoded.size(); i++) { | |
| if (i == point) { | |
| wrapped += '\n'; | |
| point += wrap; | |
| } | |
| wrapped += encoded[i]; | |
| } | |
| } | |
| else { | |
| wrapped = encoded; | |
| } |
| } | ||
| else | ||
| wrapped = encoded; | ||
| WriteLiteralString(out, wrapped.data(), wrapped.size(), indent); |
Collaborator
There was a problem hiding this comment.
This is an oversight from the other PR. If I see correctly WriteLiteralString is always true, but I think we should pass the return value if one day someone changes WriteLiteralString to return something else.
(The return true; in the next line should be removed)
Suggested change
| WriteLiteralString(out, wrapped.data(), wrapped.size(), indent); | |
| return WriteLiteralString(out, wrapped.data(), wrapped.size(), indent); |
Collaborator
There was a problem hiding this comment.
Even though it is not directly related. Could you return the value from WriteSingleQuotedString instead of returning always true?
Contributor
Author
|
Done. Thanks for your hard work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1287.
Support line wrapping for Binary in literal syntax.
The line wrapping length is 80 by default, which means each line (indentation included) doesn't exceed 80 characters in literal Binary. This length could be manipulated through
out << YAML::Wrap(len), andWrap(0)means disabling the wrapping.If current indentation exceeds the wrapping length (not 0),
Utils::WriteLiteralBinarywill returnfalsewithout any exception, just like other functions inemitterutils.cpp.