folly::stripLeftMargin

De-indent a string.

Synopsis

Declared in <folly/String.h>

std::string
stripLeftMargin(std::string s);

Description

Strips the leading and the trailing whitespace-only lines. Then looks for the least indented non-whitespace-only line and removes its amount of leading whitespace from every line. Assumes leading whitespace is either all spaces or all tabs.

Purpose: including a multiline string literal in source code, indented to the level expected from context.

Return Value

The de-indented string.

Parameters

NameDescription
sThe string to de-indent.