glm::io additional operators and properties #1232
Open
115
−31
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.
Hello!
I was using
glm::io
and found myself wanting to print matrices in a single line easily.I saw very convinient operators for easily changing
precision
,width
... but none forspace
andnewline
, hence this PR commits:space
andnewline
with a packed struct namedfiller
(related tostd::setfill
), following the same structure as the structdelimeter
.delimeter
optional last argument. Seems pretty useful to have them in order to restore the default behavior.precision=3
andwidth=8
likeformat_punct
does in the default constructor (actually done in a later commit).Skip initial newline when printing matrices. IMO seems more logical to let the end user do it, in my case I need this to be able to print matrices in a single line.Introduces differences with previous outputs! Quite noticeable, but consistent with vector behavior.width=0
and keep an space between components for better visualization.fill
property instead of doingsetw(space)
. This allows to set e.g.'0'
as filler only, becausespace
was also being used in many other places. Can be modified as part of the structfiller
.firstline
property to be able to keep the previous behavior broken in commit (3.), basically replaces the firstnewline
for a customizable character. Can be modified as part of the structfiller
.io::formatted
:io::reset
to restore default settings andio::compressed
to setup single line printing.I split the commits for simpler discussion/review/changes, let me know what you think.
I can squash them all in the end or whatever you prefer.
Regards!