ΒΆllvm::Expected<FormatStyle> getStyle(
    llvm::StringRef StyleName,
    llvm::StringRef FileName,
    llvm::StringRef FallbackStyle,
    llvm::StringRef Code = "",
    llvm::vfs::FileSystem* FS = nullptr,
    bool AllowUnknownOptions = false)

Description

Construct a FormatStyle based on ``StyleName``. ``StyleName`` can take several forms: * "{<key>: <value>, ...}" - Set specic style parameters. * "<style name>" - One of the style names supported by getPredefinedStyle(). * "file" - Load style configuration from a file called ``.clang-format`` located in one of the parent directories of ``FileName`` or the current directory if ``FileName`` is empty. * "file:<format_file_path>" to explicitly specify the configuration file to use.

Declared at: clang/include/clang/Format/Format.h:4262

Parameters

llvm::StringRef StyleName
Style name to interpret according to the description above.
llvm::StringRef FileName
Path to start search for .clang-format if ``StyleName`` == "file".
llvm::StringRef FallbackStyle
The name of a predefined style used to fallback to in case \p StyleName is "file" and no file can be found.
llvm::StringRef Code = ""
The actual code to be formatted. Used to determine the language if the filename isn't sufficient.
llvm::vfs::FileSystem* FS = nullptr
The underlying file system, in which the file resides. By default, the file system is the real file system.
bool AllowUnknownOptions = false
If true, unknown format options only emit a warning. If false, errors are emitted on unknown format options.

Returns

FormatStyle as specified by ``StyleName``. If ``StyleName`` is "file" and no file is found, returns ``FallbackStyle``. If no style could be determined, returns an Error.