1 /* 2 SPDX-FileCopyrightText: 2008 CÃ ©dric Pasteur <cedric.pasteur@free.fr> 3 SPDX-FileCopyrightText: 2001 Matthias Hölzer-Klüpfel <mhk@caldera.de> 4 5 SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 8 #ifndef ASTYLEFORMATTER_H 9 #define ASTYLEFORMATTER_H 10 11 #include <QVariant> 12 #include <QString> 13 14 #include "astyle.h" 15 16 class AStyleFormatter : public astyle::ASFormatter 17 { 18 public: 19 /** Creates an empty AStyleFormatter with C style by default. 20 */ 21 AStyleFormatter(); 22 23 QString formatSource(const QString& text, const QString& leftContext = QString(), const QString& rightContext = QString()); 24 25 QVariant option(const QString &name) const; 26 27 bool predefinedStyle(const QString &name); 28 void loadStyle(const QString &content); 29 QString saveStyle() const; 30 31 // indent 32 void setTabIndentation(int length, bool forceTabs); 33 void setSpaceIndentation(int length); 34 void setTabSpaceConversionMode(bool mode); 35 void setFillEmptyLines(bool on); 36 void setBlockIndent(bool on); 37 void setBracketIndent(bool on); 38 void setCaseIndent(bool on); 39 void setClassIndent(bool on); 40 void setLabelIndent(bool on); 41 void setNamespaceIndent(bool on); 42 void setPreprocessorIndent(bool on); 43 void setSwitchIndent(bool on); 44 void setMaxInStatementIndentLength(int max); 45 void setMinConditionalIndentLength(int min); 46 void setAfterParens(bool on); 47 void setContinuation(int n); 48 //brackets 49 void setBracketFormatMode(astyle::BraceMode mode); 50 void setBreakClosingHeaderBracketsMode(bool state); 51 //blocks 52 void setBreakBlocksMode(bool state); 53 void setBreakElseIfsMode(bool state); 54 void setBreakClosingHeaderBlocksMode(bool state); 55 //padding 56 void setOperatorPaddingMode(bool mode); 57 void setParensOutsidePaddingMode(bool mode); 58 void setParensInsidePaddingMode(bool mode); 59 void setParensHeaderPaddingMode(bool mode); 60 void setParensUnPaddingMode(bool state); 61 //oneliners 62 void setBreakOneLineBlocksMode(bool state); 63 void setBreakOneLineStatementsMode(bool state); 64 //pointer 65 void setPointerAlignment(astyle::PointerAlign alignment); 66 67 private: 68 void updateFormatter(); 69 void resetStyle(); 70 71 QVariantMap m_options; 72 }; 73 74 #endif // ASTYLEFORMATTER_H 75