Last active
August 16, 2024 09:57
-
-
Save nyzss/71f9973a4ebb269de2ff5dbace7c3e1f to your computer and use it in GitHub Desktop.
Canonical Form for 42 CPP projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Canonical Form HPP": { | |
"prefix": ["canoh", "canoheader", "canonicalh", "canonicalheader", "orthoheader", "orthodoxheader"], | |
"body": [ | |
"#pragma once", | |
"#ifndef ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_HPP", | |
"# define ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_HPP", | |
"", | |
"#include <iostream>", | |
"", | |
"class ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}", | |
"{", | |
"private:", | |
"protected:", | |
"public:", | |
"\t${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} ();", | |
"\t${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} (const ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} &${1:${TM_FILENAME_BASE/(.*)/${1:/downcase}/}});", | |
"\t~${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} ();", | |
"\t${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} & operator=(const ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} &${1:${TM_FILENAME_BASE/(.*)/${1:/downcase}/}});", | |
"};", | |
"", | |
"#endif /* ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_HPP */", | |
"" | |
], | |
"description": "HEADER: this is the header part of the orthodox canonical form. snippet for vscode by okoca" | |
}, | |
"Canonical Form CPP": { | |
"prefix": ["canoc", "canocpp", "canonicalc", "canonicalcpp", "orthocpp", "orthodoxcpp"], | |
"body": [ | |
"#include \"${TM_FILENAME_BASE}.hpp\"", | |
"", | |
"${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}::${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}()", | |
"{", | |
"\t$0", | |
"}", | |
"", | |
"${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}::${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}(const ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} &${1:${TM_FILENAME_BASE/(.*)/${1:/downcase}/}})", | |
"{", | |
"\t", | |
"}", | |
"", | |
"${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}::~${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}()", | |
"{", | |
"\t", | |
"}", | |
"", | |
"${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} & ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}::operator=(const ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} &${1:${TM_FILENAME_BASE/(.*)/${1:/downcase}/}})", | |
"{", | |
"\tif (this != &${1:${TM_FILENAME_BASE/(.*)/${1:/downcase}/}})", | |
"\t{", | |
"\t\t// Copy data members from ${1:${TM_FILENAME_BASE/(.*)/${1:/downcase}/}} to this object", | |
"\t}", | |
"\treturn *this;", | |
"}", | |
"" | |
], | |
"description": "CPP FILE: this is the cpp file part of the orthodox canonical form. snippet for vscode by okoca" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
changed version to capitalize filename, so that you can make files in lowercase but still have the class name first letter in uppercase