Etheram68 5 роки тому
батько
коміт
6512a345b9
4 змінених файлів з 21 додано та 21 видалено
  1. 3 0
      README.md
  2. 1 1
      package.json
  3. 2 2
      src/basicInput.ts
  4. 15 18
      src/template.ts

+ 3 - 0
README.md

@@ -39,6 +39,9 @@ To report a bug or ask for a feature, please open a [Github issue](https://githu
 
 ## Release Notes
 
+### 0.2.8
+Modify Template
+
 ### 0.2.6 / 0.2.7
 First letter is upper, other letter is sensitive case And modify Template
 

+ 1 - 1
package.json

@@ -2,7 +2,7 @@
 	"name": "canonicalclasscpp",
 	"displayName": "42 Canonical Class CPP",
 	"description": "This extension is to automatically create a canonical hpp and cpp file",
-	"version": "0.2.7",
+	"version": "0.2.8",
 	"publisher": "frfreyCanonicalClassCPP",
 	"icon": "42.png",
 	"repository": {

+ 2 - 2
src/basicInput.ts

@@ -36,8 +36,8 @@ export async function createQuickClass() {
 		const wsedit = new vscode.WorkspaceEdit();
 		const wsPath = vscode.workspace.workspaceFolders![0].uri.fsPath;
 
-		const filePathCpp = vscode.Uri.file(wsPath + '/' + name + '.Class' + '.cpp');
-		const filePathHpp = vscode.Uri.file(wsPath + '/' + name + '.Class' + '.hpp');
+		const filePathCpp = vscode.Uri.file(wsPath + '/' + name + '.cpp');
+		const filePathHpp = vscode.Uri.file(wsPath + '/' + name + '.hpp');
 
 		let command = (vscode.workspace.getConfiguration().get('headercppclass.headerId') as string).trim();
 

+ 15 - 18
src/template.ts

@@ -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 !");
 }