summaryrefslogtreecommitdiff
path: root/src/rules/constructor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rules/constructor.cpp')
-rw-r--r--src/rules/constructor.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/src/rules/constructor.cpp b/src/rules/constructor.cpp
index e9acb1b..8777ce1 100644
--- a/src/rules/constructor.cpp
+++ b/src/rules/constructor.cpp
@@ -22,8 +22,13 @@
registerRuleExt(constructor, "006", "(.+)[.](cpp|h)")
+bool foundConstructor(false);
+int align = 0;
+
startRule(constructor)
{
+ foundConstructor = false;
+ align = 0;
}
endRule(constructor)
@@ -32,6 +37,53 @@ endRule(constructor)
parseLineRule(constructor)
{
- if (strEndWith(data, "):"))
- print("Add space between constructor and \":\".");
+ if (foundConstructor)
+ {
+ if (data.size() > 0 && data[0] == '#')
+ return;
+
+ int align2 = 0;
+ const size_t sz = data.size();
+ for (size_t f = 0; f < sz; f ++)
+ {
+ if (data[f] != ' ')
+ break;
+ align2 ++;
+ }
+ if (align2 != align + 4)
+ print("Wrong align in initialisation list.");
+
+ foundConstructor = false;
+ }
+ else
+ {
+ if (data.find("(") != std::string::npos)
+ {
+ align = 0 ;
+ const size_t sz = data.size();
+ for (size_t f = 0; f < sz; f ++)
+ {
+ if (data[f] != ' ')
+ break;
+ align ++;
+ }
+ }
+ if (strEndWith(data, "):"))
+ {
+ print("Add space between constructor and \":\".");
+ if (data.find("<") == std::string::npos
+ && data.find("?") == std::string::npos)
+ {
+ foundConstructor = true;
+ }
+ }
+ else if (strEndWith(data, ") :"))
+ {
+ if (data.find("<") == std::string::npos
+ && data.find("?") == std::string::npos)
+ {
+ foundConstructor = true;
+ }
+ }
+ }
}