-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_header.lua
executable file
·34 lines (29 loc) · 1010 Bytes
/
create_header.lua
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
function create_header(num)
-- this is a lua function to generate .cpp files
num = num or 0;
local str_arr = {};
-- construct lines of text
for i = 1, num do
str_arr[i] = {};
str_arr[i][1] = "#ifndef creationlib_hh_";
str_arr[i][2] = "#define creationlib_hh_";
str_arr[i][3] = "#include \"ClassEx" .. i .. ".hh\"";
str_arr[i][4] = "#endif";
end
-- output to std or file (or both)
pwd = os.getenv("PWD");
full_path = pwd .. "/include/creationlib.hh";
full_path = full_path:gsub("/", "//"); -- escape slashes
print("creating header .hh file\n");
local fileN = assert(io.open(full_path,
"w+"));
fileN:write(str_arr[1][1] .. "\n");
fileN:write(str_arr[1][2] .. "\n\n");
--local fileAll = assert(io.open("src/ClassExN.cpp", "w+"));
for i = 1, num do
fileN:write(str_arr[i][3] .. "\n");
end
fileN:write("\n" .. str_arr[1][4] .. "\n");
end
-- command line args
create_header(arg[1]);