This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathlanguage-c.cson
113 lines (113 loc) · 4.38 KB
/
language-c.cson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
'.source.c, .source.cpp, .source.objc, .source.objcpp':
'#ifndef … #define … #endif':
'prefix': 'def'
'body': '#ifndef ${1:SYMBOL}\n#define $1 ${2:value}\n#endif'
'#include <>':
'prefix': 'Inc'
'body': '#include <${1:.h}>'
'#include ""':
'prefix': 'inc'
'body': '#include "${1:.h}"'
'#pragma mark':
'prefix': 'mark'
'body': '#if 0\n${1:#pragma mark -\n}#pragma mark $2\n#endif\n\n$0'
'main()':
'prefix': 'main'
'body': 'int main(int argc, char const *argv[]) {\n\t${1:/* code */}\n\treturn 0;\n}'
'For Loop':
'prefix': 'for'
'body': 'for (size_t ${1:i} = 0; ${1:i} < ${2:count}; ${1:i}${3:++}) {\n\t${4:/* code */}\n}'
'Header Include-Guard':
'prefix': 'once'
'body': '#ifndef ${1:SYMBOL}\n#define $1\n\n${2}\n\n#endif /* end of include guard: $1 */\n'
'Shared Pointer':
'prefix': 'sp'
'body': 'typedef std::shared_ptr<${2:${1:my_type}_t}> ${3:${4:my_type}_ptr};'
'Typedef':
'prefix': 'td'
'body': 'typedef ${1:int} ${2:MyCustomType};'
'Do While Loop':
'prefix': 'do'
'body': 'do {\n\t${0:/* code */}\n} while(${1:/* condition */});'
'While Loop':
'prefix': 'while'
'body': 'while (${1:/* condition */}) {\n\t${2:/* code */}\n}'
'fprintf':
'prefix': 'fprintf'
'body': 'fprintf(${1:stderr}, "${2:%s}\\\\n", $3);$4'
'If Condition':
'prefix': 'if'
'body': 'if (${1:/* condition */}) {\n\t${2:/* code */}\n}'
'If Else':
'prefix': 'ife'
'body': 'if (${1:/* condition */}) {\n\t${2:/* code */}\n} else {\n\t${3:/* code */}\n}'
'If ElseIf':
'prefix': 'iff'
'body': 'if (${1:/* condition */}) {\n\t${2:/* code */}\n} else if (${3:/* condition */}) {\n\t${4:/* code */}\n}'
'If ElseIf Else':
'prefix': 'iffe'
'body': 'if (${1:/* condition */}) {\n\t${2:/* code */}\n} else if (${3:/* condition */}) {\n\t${4:/* code */}\n} else {\n\t${5:/* code */}\n}'
'Switch Statement':
'prefix': 'switch'
'body': 'switch (${1:/* expression */}) {\n\tcase ${2:/* value */}:\n}'
'case':
'prefix': 'cs'
'body': 'case ${1:/* value */}:$0'
'printf':
'prefix': 'printf'
'body': 'printf("${1:%s}\\\\n", $2);$3'
'scanf':
'prefix': 'scanf'
'body': 'scanf(\"${1:%s}\\\\n\", $2);$3'
'Struct':
'prefix': 'st'
'body': 'struct ${1:name_t} {\n\t${2:/* data */}\n};'
'void':
'prefix': 'void'
'body': 'void ${1:name}(${2:/* arguments */}) {\n\t${3:/* code */}\n}'
'any function':
'prefix': 'func'
'body': '${1:int} ${2:name}(${3:/* arguments */}) {\n\t${5:/* code */}\n\treturn ${4:0};\n}'
'write file':
'prefix': 'wf'
'body': 'FILE *${1:fp};\n${1:fp} = fopen ("${2:filename.txt}","w");\nif (${1:fp}!=NULL)\n{\n\tfprintf(${1:fp},"${3:Some String\\\\n}");\n\tfclose (${1:fp});\n}'
'read file':
'prefix': 'rf'
'body': 'FILE *${1:fp};\n${1:fp} = fopen ("${2:filename.txt}","r");\nif (${1:fp}!=NULL)\n{\n\tfscanf(${1:fp},"${3:Some String\\\\n}", ${3:&var});\n\tfclose (${1:fp});\n}'
'.source.cpp, .source.objcpp':
'Enumeration':
'prefix': 'enum'
'body': 'enum ${1:name} { $0 };'
'Class':
'prefix': 'cl'
'body': 'class ${1:name_t} {\nprivate:\n\t${0:/* data */}\n\npublic:\n\t${1:name_t} (${2:arguments});\n\tvirtual ~${1:name_t} ();\n};'
'Namespace':
'prefix': 'ns'
'body': 'namespace ${1:name} {\n\t$2\n} /* $1 */'
'cout':
'prefix': 'cout'
'body': 'std::cout << \"${1:/* message */}\" << \'\\\\n\';'
'cin':
'prefix': 'cin'
'body': 'std::cin >> ${1:/* variable */};'
'cerr':
'prefix': 'cerr'
'body': 'std::cerr << \"${1:/* error message */}\" << \'\\\\n\';'
'std::map':
'prefix': 'map'
'body': 'std::map<${1:key}, ${2:value}> map$3;'
'std::string':
'prefix': 'str'
'body': 'std::string'
'std::vector':
'prefix': 'vector'
'body': 'std::vector<${1:int}> v$2;'
'template <typename>':
'prefix': 'tp'
'body': 'template <typename ${1:T}>'
'output file':
'prefix': 'outf'
'body': 'std::ofstream ${1:afile}("${2:filename.txt}", std::ios::out);\nif (${1:afile}.is_open()) {\n\t${1:afile} << "${3:This is a line.}\\\\n";\n\t${1:afile}.close();\n}'
'input file':
'prefix': 'inf'
'body': 'std::ifstream ${1:afile}("${2:filename.txt}", std::ios::in);\nif (${1:afile}.is_open()) {\n\tstd::string line;\n\twhile (std::getline(${1:afile}, line)) {\n\t\tstd::cout << line << \'\\\\n\';\n\t}\n\t${1:afile}.close();\n}\nelse {\n\tstd::cerr << "Unable to open file\\\\n";\n}'