|
@@ -1,6 +1,5 @@
|
|
|
-#include <iostream>
|
|
|
|
|
-#include <fstream>
|
|
|
|
|
-#include <string>
|
|
|
|
|
|
|
+#include <bdlib/src/Stream.h>
|
|
|
|
|
+#include <bdlib/src/String.h>
|
|
|
#include <cctype>
|
|
#include <cctype>
|
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
#include <cstring>
|
|
#include <cstring>
|
|
@@ -10,41 +9,37 @@ int main(int argc, char *argv[]) {
|
|
|
if (argc == 2)
|
|
if (argc == 2)
|
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
|
|
- fstream file;
|
|
|
|
|
- ofstream out;
|
|
|
|
|
- file.open(argv[1]);
|
|
|
|
|
- out.open(argv[2]);
|
|
|
|
|
|
|
+ bd::Stream file, out;
|
|
|
|
|
+ file.loadFile(argv[1]);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- char line[1024] = "";
|
|
|
|
|
- string type;
|
|
|
|
|
|
|
+ bd::String type, line;
|
|
|
char c;
|
|
char c;
|
|
|
|
|
|
|
|
- while (file.getline(line, sizeof(line))) {
|
|
|
|
|
|
|
+ while (file.tell() < file.length()) {
|
|
|
|
|
+ line = file.getline().chomp();
|
|
|
if (line[0] == '#') continue;
|
|
if (line[0] == '#') continue;
|
|
|
if (line[0] == ':') {
|
|
if (line[0] == ':') {
|
|
|
- type = &line[1];
|
|
|
|
|
|
|
+ type = line(1, line.length() - 1);
|
|
|
if (type == "end")
|
|
if (type == "end")
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- transform(type.begin(), type.end(), type.begin(), (int(*)(int)) toupper);
|
|
|
|
|
|
|
+ transform(type.begin(), type.end(), type.mdata(), (int(*)(int)) toupper);
|
|
|
|
|
|
|
|
type = "DEFAULT_" + type;
|
|
type = "DEFAULT_" + type;
|
|
|
- out << "#define " << type << " \"\\" << endl;
|
|
|
|
|
|
|
+ out << "#define " << type << " \"\\" << "\n";
|
|
|
} else {
|
|
} else {
|
|
|
if (!type.length())
|
|
if (!type.length())
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
out << line;
|
|
out << line;
|
|
|
- c = file.peek();
|
|
|
|
|
|
|
+ c = file.peek()[0];
|
|
|
if (strchr("\n:", c)) {
|
|
if (strchr("\n:", c)) {
|
|
|
- out << "\"\n" << endl;
|
|
|
|
|
|
|
+ out << "\"\n\n";
|
|
|
type = "";
|
|
type = "";
|
|
|
} else
|
|
} else
|
|
|
- out << ",\\" << endl;
|
|
|
|
|
|
|
+ out << ",\\\n";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- file.close();
|
|
|
|
|
- out.close();
|
|
|
|
|
|
|
+ out.writeFile(argv[2]);
|
|
|
}
|
|
}
|