@@ -36,6 +36,7 @@ namespace cpp_mgr {
3636 if (num >= off) {
3737 bool find = false ;
3838 if (line.find (str) != string::npos) {
39+ find = true ;
3940 }
4041 else {
4142 bool find = false ;
@@ -89,53 +90,33 @@ namespace cpp_mgr {
8990 insert_from_file (lines, insert_a, fp);
9091 }
9192
93+ void repl_line (vector<wstring>& lines, int ln, wstring s) {
94+ lines[ln-1 ] = s;
95+ }
96+
97+ void repl_line_from_file (vector<wstring>& lines, int ln, const char * fp) {
98+ vector<wstring> a;
99+ utils::read_file_lines_w (fp, a);
100+ lines[ln -1 ] = a[0 ];
101+ }
102+
103+ void swap_line (vector<wstring>& lines, int ln1, int ln2) {
104+ wstring ss = lines[ln1-1 ];
105+ lines[ln1-1 ] = lines[ln2-1 ];
106+ lines[ln2-1 ] = ss;
107+ }
108+
92109 void proc_cpp (const char * ifp, const char * ofp, const char * sfp) {
93110 vector<wstring> lines;
94111 utils::read_file_lines_w (ifp, lines);
95112
96113 vector<wstring> l_script;
97114 utils::read_file_lines_w (sfp, l_script);
98115
99- std::wstring_convert<std::codecvt_utf8< wchar_t >> conv ;
116+ std::vector<oz_script_var> vars ;
100117
101118 for (auto c : l_script) {
102- if (c.length () == 0 ) {
103- // empty line
104- continue ;
105- }
106- else if (c[0 ] == ' #' ) {
107- // comment
108- continue ;
109- }
110- else {
111- vector<wstring> cmd;
112- utils::string_split_w (c, L" " , cmd);
113- wcout << " cmd:" << cmd[0 ] << endl;
114-
115- int opcode = ozil2_script_mgr::str2opcode (cmd[0 ]);
116-
117- string fp;
118-
119- switch (opcode) {
120- case 100 :
121- fp = " ./src_res/" +conv.to_bytes (cmd[3 ]);
122- insert_method_at_from_file (lines, cmd[1 ], cmd[2 ], fp.c_str ());
123- break ;
124- case 101 :
125- insert_line (lines, 10 , cmd[2 ]);
126- break ;
127- case 102 :
128- fp = " ./src_res/" + conv.to_bytes (cmd[2 ]);
129- insert_from_file (lines, 10 , fp.c_str ());
130- break ;
131- case 103 :
132- insert_header (lines, cmd[1 ]);
133- break ;
134- case -1 :
135- continue ;
136- break ;
137- }
138- }
119+ ozil2_script_mgr::run_line (lines, vars, c);
139120 }
140121
141122 utils::write_file_lines_w (ofp, lines);
0 commit comments