-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp.snippets
75 lines (70 loc) · 2.05 KB
/
cpp.snippets
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
snippet FormatData "Format Data Program C++ skeleton" b
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <regex>
#include <iterator>
#include <algorithm>
#include <cstddef> // for size_t
using std::cout; using std::cin; using std::endl; using std::cerr;
using std::ostream; using std::istream;
using std::string;
using std::istringstream; using std::ostringstream;
using std::fstream; using std::ifstream; using std::ofstream;
using std::vector;
using std::regex; using std::regex_match;
using std::istream_iterator; using std::ostream_iterator;
void formatdata(ostream &, const char *);
int main(int argc, char *argv[]) {
if (argc < 2) {
cerr << "no argument, please provide argument" << endl;
return 0;
}
while (--argc) {
char *ifname = *++argv;
string ofname = string(ifname, 0, ${1:string(ifname).size()-4}) + "${2:.dat}";
// cout << ifname << ' ' << ofname << endl;
// formatdata(cout, ifname);
ofstream outstream(ofname);
formatdata(outstream, ifname);
}
return 0;
}
void formatdata(ostream &${4:os}, const char *${5:filename}) {
${6:#statements}
}
endsnippet
snippet commoninconlyinsource "common include only in source" b
#include <iostream>
using std::cout; using std::cin; using std::endl; using std::cerr;
using std::ostream; using std::istream;
#include <string>
using std::string;
#include <sstream>
using std::istringstream; using std::ostringstream;
#include <fstream>
using std::fstream; using std::ifstream; using std::ofstream;
#include <vector>
using std::vector;
#include <regex>
using std::regex; using std::regex_match;
#include <iterator>
using std::istream_iterator; using std::ostream_iterator;
#include <algorithm>
#include <cstddef> // for size_t
$0
endsnippet
snippet commoninconlyinheader "common include only in header" b
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <regex>
#include <iterator>
#include <algorithm>
#include <cstddef> // for size_t
$0
endsnippet