|
|
@@ -17,7 +17,7 @@ export const getTemplate = ( name: string | undefined, filePathCpp: vscode.Uri ,
|
|
|
if (name)
|
|
|
{
|
|
|
let len = name.length;
|
|
|
- len += 23;
|
|
|
+ len += 17;
|
|
|
len = 80 - len - 1
|
|
|
let star = "*"
|
|
|
for (; len > 0; len--)
|
|
|
@@ -25,15 +25,12 @@ export const getTemplate = ( name: string | undefined, filePathCpp: vscode.Uri ,
|
|
|
star += "*"
|
|
|
}
|
|
|
|
|
|
- let classcpp = "#include \"" + name + ".Class" + ".hpp\"\n" +
|
|
|
+ let classcpp = "#include \"" + name + ".hpp\"\n" +
|
|
|
"\n/*\n** ------------------------------- CONSTRUCTOR --------------------------------\n*/\n\n" +
|
|
|
- name + "::" + name + "()\n{\n std::cout << \"Default constructor called\"" +
|
|
|
- " << std::endl;\n}\n\n" +
|
|
|
- name + "::" + name + "( const " + name + " & src )\n{\n" +
|
|
|
- " std::cout << \"Copy constructor called\" << std::endl;\n" +
|
|
|
- " *this = src;\n}\n\n" +
|
|
|
+ name + "::" + name + "()\n{\n}\n\n" +
|
|
|
+ name + "::" + name + "( const " + name + " & src )\n{\n}\n\n" +
|
|
|
"\n/*\n** -------------------------------- DESTRUCTOR --------------------------------\n*/\n\n" +
|
|
|
- name + "::~" + name + "()\n{\n std::cout << \"Destructor called\" << std::endl;\n}\n\n" +
|
|
|
+ name + "::~" + name + "()\n{\n}\n\n" +
|
|
|
"\n/*\n** --------------------------------- OVERLOAD ---------------------------------\n*/\n\n" +
|
|
|
name + " & " + name + "::operator=( " + name + " const & rhs )\n{\n //if ( this != &rhs )\n" +
|
|
|
" //{\n //this->_value = rhs.getValue();\n //}\n" +
|
|
|
@@ -43,8 +40,8 @@ export const getTemplate = ( name: string | undefined, filePathCpp: vscode.Uri ,
|
|
|
"\n/*\n** --------------------------------- METHODS ----------------------------------\n*/\n\n" +
|
|
|
"\n/* ************************************************************************** */";
|
|
|
|
|
|
- let classhpp = "#ifndef " + name.toUpperCase() + "_CLASS" + "_HPP\n" +
|
|
|
- "# define " + name.toUpperCase() + "_CLASS" + "_HPP\n\n" +
|
|
|
+ let classhpp = "#ifndef " + name.toUpperCase() + "_HPP\n" +
|
|
|
+ "# define " + name.toUpperCase() + "_HPP\n\n" +
|
|
|
"# include <iostream>\n" +
|
|
|
"# include <string>\n\n" +
|
|
|
"class " + name + "\n{\n" +
|
|
|
@@ -61,20 +58,20 @@ export const getTemplate = ( name: string | undefined, filePathCpp: vscode.Uri ,
|
|
|
"};\n\n" +
|
|
|
"std::ostream & operator<<( std::ostream & o, " + name + " const & i );"+
|
|
|
"\n\n" +
|
|
|
- "#endif /* *" + star + " " + name.toUpperCase() + "_CLASS_H */";
|
|
|
+ "#endif /* *" + star + " " + name.toUpperCase() + "_H */";
|
|
|
|
|
|
|
|
|
fs.writeFile(filePathCpp.fsPath, classcpp, function (err: any) { if (err) return console.log(err); });
|
|
|
fs.writeFile(filePathHpp.fsPath, classhpp, function (err: any) { if (err) return console.log(err); });
|
|
|
|
|
|
- vscode.window.showInformationMessage("Files : " + name + ".class.cpp, " + name + ".class.hpp created !");
|
|
|
+ vscode.window.showInformationMessage("Files : " + name + ".cpp, " + name + ".hpp created !");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
export const getTemplateFull = ( name: string, filePathCpp: vscode.Uri, filePathHpp: vscode.Uri, valueArray: Array<string | undefined>, typeArray: Array<string | undefined> ) => {
|
|
|
let len = name.length;
|
|
|
- len += 23;
|
|
|
+ len += 17;
|
|
|
len = 80 - len - 1
|
|
|
let star = "*"
|
|
|
for (; len > 0; len--)
|
|
|
@@ -82,7 +79,7 @@ export const getTemplateFull = ( name: string, filePathCpp: vscode.Uri, filePath
|
|
|
star += "*"
|
|
|
}
|
|
|
|
|
|
- let classcpp = "#include \"" + name + ".Class" + ".hpp\"\n\n" +
|
|
|
+ let classcpp = "#include \"" + name + ".hpp\"\n\n" +
|
|
|
name + "::" + name + "()\n{\n}\n\n" +
|
|
|
name + "::" + name + "( const " + name + " & object )\n{\n}\n\n" +
|
|
|
name + "::~" + name + "()\n{\n std::cout << \"Destructor called\" << std::endl;\n}\n\n" +
|
|
|
@@ -93,8 +90,8 @@ export const getTemplateFull = ( name: string, filePathCpp: vscode.Uri, filePath
|
|
|
"{\n //o << \"Value = \" << i.getValue();\n return o;\n}\n\n" +
|
|
|
"\n/* ************************************************************************** */";
|
|
|
|
|
|
- let classhpp = "#ifndef " + name.toUpperCase() + "_CLASS" + "_HPP\n" +
|
|
|
- "# define " + name.toUpperCase() + "_CLASS" + "_HPP\n\n" +
|
|
|
+ let classhpp = "#ifndef " + name.toUpperCase() + "_HPP\n" +
|
|
|
+ "# define " + name.toUpperCase() + "_HPP\n\n" +
|
|
|
"# include <iostream>\n\n" +
|
|
|
"class " + name + "\n{\n" +
|
|
|
"\n" +
|
|
|
@@ -121,11 +118,11 @@ export const getTemplateFull = ( name: string, filePathCpp: vscode.Uri, filePath
|
|
|
classhpp += "};\n\n" +
|
|
|
"std::ostream & operator<<( std::ostream & o, " + name + " const & i );"+
|
|
|
"\n\n" +
|
|
|
- "#endif /* *" + star + " " + name.toUpperCase() + "_CLASS_H */";
|
|
|
+ "#endif /* *" + star + " " + name.toUpperCase() + "_H */";
|
|
|
|
|
|
|
|
|
fs.writeFile(filePathCpp.fsPath, classcpp, function (err: any) { if (err) return console.log(err); });
|
|
|
fs.writeFile(filePathHpp.fsPath, classhpp, function (err: any) { if (err) return console.log(err); });
|
|
|
|
|
|
- vscode.window.showInformationMessage("Files : " + name + ".class.cpp, " + name + ".class.hpp created !");
|
|
|
+ vscode.window.showInformationMessage("Files : " + name + ".cpp, " + name + ".hpp created !");
|
|
|
}
|