aboutsummaryrefslogtreecommitdiff
path: root/snippets/cpp.json
diff options
context:
space:
mode:
Diffstat (limited to 'snippets/cpp.json')
-rw-r--r--snippets/cpp.json385
1 files changed, 385 insertions, 0 deletions
diff --git a/snippets/cpp.json b/snippets/cpp.json
new file mode 100644
index 0000000..aca55d0
--- /dev/null
+++ b/snippets/cpp.json
@@ -0,0 +1,385 @@
+{
+ "Basic C++ main template": {
+ "scope": "cpp",
+ "prefix": "main",
+ "body": [
+ "#include <cstdio>",
+ "",
+ "int main (int argc, char *argv[]) ",
+ "{",
+ " $0",
+ " return 0;",
+ "}"
+ ],
+ "description": "Basic main template in C++"
+ },
+ "Basic C++ iostream main template": {
+ "scope": "cpp",
+ "prefix": "iomain",
+ "body": [
+ "#include <cstdio>",
+ "#include <iostream>",
+ "",
+ "int main (int argc, char *argv[])",
+ "{",
+ " $0",
+ " return 0;",
+ "}"
+ ],
+ "description": "Basic iostream main templace in C++"
+ },
+ "If statement": {
+ "scope": "c",
+ "prefix": "if",
+ "body": [
+ "if ($1) {",
+ " ${2:/* code here */} ",
+ "}"
+ ],
+ "description": "Creates an if statement"
+ },
+ "Else statement": {
+ "scope": "c",
+ "prefix": "else",
+ "body": [
+ "else {",
+ " ${0:/* code here */}",
+ "}"
+ ],
+ "description": "Creates an else statement"
+ },
+ "Else if statement": {
+ "scope": "c",
+ "prefix": "elif",
+ "body": [
+ "else if ($1) {",
+ " ${2:/* code here */}",
+ "}"
+ ],
+ "description": "Creates an else if statement"
+ },
+ "Switch": {
+ "scope": "c",
+ "prefix": "switch",
+ "body": [
+ "switch ($1) ",
+ "{",
+ " case $2:",
+ " $3;",
+ " break;",
+ "",
+ " default:",
+ " $4;",
+ " break;",
+ "}"
+ ],
+ "description": "Creates a void function"
+ },
+ "For loop": {
+ "scope": "c",
+ "prefix": "for",
+ "body": [
+ "for (int ${1:i} = ${2:0}; ${1:i} < $3; ++${1:i}) {",
+ " ${4:/* code goes here */}",
+ "}"
+ ],
+ "description": "Creates a for loop"
+ },
+ "Reverse For loop": {
+ "scope": "c",
+ "prefix": "forrev",
+ "body": [
+ "for (int ${1:i} = $2; ${1:i} >= ${3:0}; --${1:i}) {",
+ " ${4:/* code goes here */}",
+ "}"
+ ],
+ "description": "Creates a reverse for loop"
+ },
+ "Range For loop": {
+ "scope": "cpp",
+ "prefix": "forrange",
+ "body": [
+ "for (auto &${1:element} : ${2:containeur}) {",
+ " ${3:/* code goes here */}",
+ "}"
+ ],
+ "description": "Creates a range for loop"
+ },
+ "While loop": {
+ "scope": "c",
+ "prefix": "while",
+ "body": [
+ "while ($1) {",
+ " ${2:/* code goes here */}",
+ "}"
+ ],
+ "description": "Creates a while loop"
+ },
+ "Do...while loop": {
+ "scope": "c",
+ "prefix": "dowhile",
+ "body": [
+ "do {",
+ " ${1:/* code goes here */}",
+ "} while($2)"
+ ],
+ "description": "Creates a do...while loop"
+ },
+ "Create linked list": {
+ "scope": "c",
+ "prefix": "clist",
+ "body": [
+ "typedef struct {",
+ " ${1:int} value;",
+ " struct node_t* next;",
+ "} node_t;"
+ ],
+ "description": "Creates a linked list template"
+ },
+ "Create int function": {
+ "scope": "c",
+ "prefix": "intf",
+ "body": [
+ "int $1 (${2:void})",
+ "{",
+ " $4",
+ " return $3;",
+ "}"
+ ],
+ "description": "Creates a function that returns an int"
+ },
+ "Create float function": {
+ "scope": "c",
+ "prefix": "floatf",
+ "body": [
+ "float $1 (${2:void}) ",
+ "{",
+ " $4",
+ " return $3;",
+ "}"
+ ],
+ "description": "Creates a function that returns a float"
+ },
+ "Create double function": {
+ "scope": "c",
+ "prefix": "doublef",
+ "body": [
+ "double $1 (${2:void})",
+ "{",
+ " $4",
+ " return $3;",
+ "}"
+ ],
+ "description": "Creates a function that returns a double"
+ },
+ "Create string function": {
+ "scope": "c",
+ "prefix": "strf",
+ "body": [
+ "char* $1 (${2:void})",
+ "{",
+ " $4",
+ " return $3;",
+ "}"
+ ],
+ "description": "Creates a function that returns a string"
+ },
+ "Create long function": {
+ "scope": "c",
+ "prefix": "longf",
+ "body": [
+ "long $1 (${2:void}) ",
+ "{",
+ " $4",
+ " return $3;",
+ "}"
+ ],
+ "description": "Creates a function that returns a long"
+ },
+ "Create short function": {
+ "scope": "c",
+ "prefix": "shortf",
+ "body": [
+ "short $1 (${2:void}) ",
+ "{",
+ " $4",
+ " return $3;",
+ "}"
+ ],
+ "description": "Creates a function that returns a short"
+ },
+ "Create void function": {
+ "scope": "c",
+ "prefix": "voidf",
+ "body": [
+ "void $1 (${2:void}) ",
+ "{",
+ " $3",
+ "}"
+ ],
+ "description": "Creates a void function"
+ },
+ "Creates a header include guard C++": {
+ "scope": "cpp",
+ "prefix": "ig",
+ "body": [
+ "#ifndef ${TM_FILENAME/(.*)\\..+$/${1:/upcase}_HPP/}",
+ "#define ${TM_FILENAME/(.*)\\..+$/${1:/upcase}_HPP/}",
+ "",
+ "${0:// Code for header body}",
+ "",
+ "#endif // ${TM_FILENAME/(.*)\\..+$/${1:/upcase}_HPP/}"
+ ],
+ "description": "Creates header include guard based on file name for C++ projects"
+ },
+ "Include": {
+ "scope": "c",
+ "prefix": "inc",
+ "body": [
+ "#include <$0>"
+ ],
+ "description": "Include a header into a file"
+ },
+ "Malloc": {
+ "scope": "c",
+ "prefix": "malloc",
+ "body": [
+ "malloc($1 * sizeof(${2:int}))"
+ ],
+ "description": "Arrow for pointers in C & C++"
+ },
+ "fopen": {
+ "scope": "c",
+ "prefix": "fopen",
+ "body": [
+ "fopen(\"${1:monfichier}\", \"${2|r,r+,w,w+,a,a+|}\")"
+ ],
+ "description": "Open a file"
+ },
+ "define": {
+ "scope": "c",
+ "prefix": "define",
+ "body": [
+ "#define $1 $2"
+ ],
+ "description": "Define a constant"
+ },
+ "enum": {
+ "scope": "c",
+ "prefix": "enum",
+ "body": [
+ "enum $1 {$2, $3}"
+ ],
+ "description": "Arrow for pointers in C & C++"
+ },
+ "union": {
+ "scope": "c",
+ "prefix": "union",
+ "body": [
+ "union $1 {",
+ " $2;",
+ " $3;",
+ "}"
+ ],
+ "description": "Arrow for pointers in C & C++"
+ },
+ "struct": {
+ "scope": "c",
+ "prefix": "struct",
+ "body": [
+ "struct $1 {",
+ "${2:// Code goes here}",
+ "};"
+ ],
+ "description": "Struct in C & C++"
+ },
+ "typedef": {
+ "scope": "c",
+ "prefix": "type",
+ "body": [
+ "typedef struct _$1 {",
+ "${2:// Code goes here}",
+ "} t_$1;"
+ ],
+ "description": "Typedef struct in C & C++"
+ },
+ "vector": {
+ "scope": "cpp",
+ "prefix": "vector",
+ "body": [
+ "std::vector<$1> $2;"
+ ],
+ "description": "std::vector in C++"
+ },
+ "array": {
+ "scope": "cpp",
+ "prefix": "array",
+ "body": [
+ "std::array<$1,$2> $3;"
+ ],
+ "description": "std::array in C++"
+ },
+ "fichier": {
+ "scope": "cpp",
+ "prefix": "file",
+ "body": [
+ "std::${1|ofstream,ifstream|} $2 {${3:'monfichier.txt'}${4:, std::ios::app}};"
+ ],
+ "description": "Files in C++"
+ },
+ "lambda": {
+ "scope": "cpp",
+ "prefix": "lambda",
+ "body": [
+ "[${1:// Capture zone}](${2:// Parameters}) -> ${3:// Return type} {${4:// Your code goes here}};"
+ ],
+ "description": "Lambda in C++"
+ },
+ "template": {
+ "scope": "cpp",
+ "prefix": "template",
+ "body": [
+ "template <${1:typename T}>",
+ "${2:void} $3($4) {",
+ "${5:// Code goes here}",
+ "}"
+ ],
+ "description": "Template in C++"
+ },
+ "class": {
+ "scope": "cpp",
+ "prefix": "class",
+ "body": [
+ "class $1",
+ "{",
+ " public:",
+ " $2",
+ " private:",
+ " $3",
+ "};"
+ ],
+ "description": "Class in C++"
+ },
+ "set": {
+ "scope": "cpp",
+ "prefix": "set",
+ "body": [
+ "$1 set_$2 ($3 $4)",
+ "{",
+ " this->$2 = $4;",
+ "}"
+ ],
+ "description": "Setteur in C++"
+ },
+ "get": {
+ "scope": "cpp",
+ "prefix": "get",
+ "body": [
+ "$1 get_$2 ()",
+ "{",
+ " return this->$2;",
+ "}"
+ ],
+ "description": "Getteur in C++"
+ }
+}
ArKa projects. All rights to me, and your next child right arm.