4

I'm using the Universal Indent GUI and Uncrustify for my C++ project. The code width is set to 80 characters and the code format is almost satisfying. This seems to work fine for regular code, but string literals are not split, and I would like that to happen as well.

The following example demonstrates I'm trying to achieve ...

Original:

Logger myLog;
myLog << "Long log message which exceeds line width." << std::endmsg;

Beautifed (align_left_shift=true):

Logger myLog;
myLog << 
"Long log message which exceeds line width." 
      << std::endmsg;

Preferred:

Logger myLog;
myLog << "Long log message which exceeds "
         "line width." 
      << std::endmsg;
// or
myLog << "Long log message which exceeds "
         "line width." << std::endmsg;

Is this possible with the auxiliary tools mentioned?

Thanks in advance ...

janr
  • 3,664
  • 3
  • 24
  • 36

1 Answers1

-2
myLog << "Long log message which exceeds " \
         "line width."
      << std::endmsg;
Dan Moulding
  • 211,373
  • 23
  • 97
  • 98
Pandan
  • 5
  • 1
  • you've ruined my answer, for what I'm really grateful... ...you have to put \ at the end of the line with string constant (same way you do MACROs definition on multiple lines) – Pandan Oct 31 '12 at 13:28
  • 1
    I think you did not understand my problem. Uncrustify is a code beautifer and I'm searching for a parameter which could achieve the above-mentioned format. Besides, your code change does not compile at all! – janr Oct 31 '12 at 14:22
  • 3
    No, you don't have to put line-continuations between string constants. the compiler will happily merge them for you. – WhozCraig Oct 31 '12 at 15:01
  • 1
    I've rolled the answer back to it's original version, with the exception that I "codified" it so that it renders as "source code" on the webpage. The breaking that occurred in the edit by @PhonicUK wasn't their fault; it was a bug in the Stack Overflow editor that inserted the `
    `s. However, people should be more careful when editing other peoples' content. Stuff like this isn't typical around here. Apologies.
    – Dan Moulding Oct 31 '12 at 15:43