Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrettyWriter formatting options. #577

Merged
merged 1 commit into from
Mar 9, 2016

Conversation

comand
Copy link
Contributor

@comand comand commented Mar 8, 2016

This change adds PrettyWriter::SetFormatOptions with a corresponding
bitfield enum PrettyFormatOptions. This allows options affecting the
format of the PrettyWriter to be set. The first option to be provided
is kFormatSingleLineArray, which instructs the PrettyWriter to write
arrays on a single line, rather than breaking them up onto a line
per element.

This change adds PrettyWriter::SetFormatOptions with a corresponding
bitfield enum PrettyFormatOptions. This allows options affecting the
format of the PrettyWriter to be set. The first option to be provided
is kFormatSingleLineArray, which instructs the PrettyWriter to write
arrays on a single line, rather than breaking them up onto a line
per element.
miloyip added a commit that referenced this pull request Mar 9, 2016
Add PrettyWriter format option for writing array in single line.
@miloyip miloyip merged commit d454d21 into Tencent:master Mar 9, 2016
@miloyip
Copy link
Collaborator

miloyip commented Mar 9, 2016

Thank you.

@comand comand deleted the prettywriter-options branch March 9, 2016 21:12
@Xilinxx
Copy link

Xilinxx commented Aug 9, 2017

I do love the SetFormatterOptions for a 1D array!

But it needs a little improvement for multidimensional arrays.

Now I come up with a line like this
{ "laserruntimes": [[[32411, 2, 0, 0, 0, 0, 0, 0, 0, 0, 27, 311, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 24, 0, 0, 0, 0... }
instead of a 1 column output without the kFormatSingleLineArray. (Default)

I was looking at the code but can't figure out how I can know if I am in a nested array, my idea is to change EndArray(SizeType memberCount = 0) implementation.
`

    if (!empty && !(formatOptions_ & kFormatSingleLineArray)) {
        Base::os_->Put('\n');
        WriteIndent();
    }
    if (!empty && (formatOptions_ & kFormatSingleLine2DArray)) {            
        //How to detect if Array in array?
        Base::os_->Put('\n');            
    }        


`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants