summaryrefslogtreecommitdiffstats
path: root/vim/snippets/cpp.snippets
blob: 65fe5e1dc3c169e2324a36b24277fca86f9d679a (plain) (blame)
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
# Read File Into Vector
snippet readfile
	std::vector<char> v;
	if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
		char buf[1024];
		while (size_t len = fread(buf, 1, sizeof(buf), $2))
			v.insert(v.end(), buf, buf + len);
		fclose($2);
	}${3}
# std::map
snippet map
	std::map<${1:key}, ${2:value}> ${3};
# std::vector
snippet vector
	std::vector<${1:char}> ${2};
# Namespace
snippet ns
	namespace ${1:`Filename('', 'my')`} {
		${2}
	}
# Class
snippet cl
	class ${1:`Filename('$1', 'name')`} {
	public:
		$1(${2:arguments});
		virtual ~$1();
	
	private:
		${3:/* data */}
	};
# for loop with iterators
snippet forv
	for (std::vector<${1:int}>::const_iterator ${2:it} = ${3:vec}.begin();
	     $2 != $3.end();
	     ++$2) {
	    ${4:/* code */}
	}