Lot of code for generating code. Working on unit tests.
This commit is contained in:
parent
da45929b12
commit
8f4845d4d2
42 changed files with 1089 additions and 267 deletions
27
pglablib/codebuilder/IndentationConfig.cpp
Normal file
27
pglablib/codebuilder/IndentationConfig.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include "IndentationConfig.h"
|
||||
|
||||
IndentationConfig::IndentationConfig() = default;
|
||||
|
||||
IndentationConfig::IndentationConfig(int tab_size, int indentation_size, bool use_tabs)
|
||||
: m_tabSize(tab_size)
|
||||
, m_indentationSize(indentation_size)
|
||||
, m_useTabs(use_tabs)
|
||||
{}
|
||||
|
||||
/** Returns a string with the right amount of tabs and spaces for the
|
||||
* requested indentation level.
|
||||
*/
|
||||
QString IndentationConfig::getIndentString(int level) const
|
||||
{
|
||||
int spaces = level * m_indentationSize;
|
||||
int tabs = 0;
|
||||
if (m_useTabs) {
|
||||
tabs = spaces / m_tabSize;
|
||||
spaces -= tabs * m_tabSize;
|
||||
}
|
||||
|
||||
if (tabs > 0)
|
||||
return QString(tabs, '\t') + QString(spaces, ' ');
|
||||
else
|
||||
return QString(spaces, ' ');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue