TDME2  1.9.200
msclib2dll-main.cpp
Go to the documentation of this file.
1 #include <set>
2 #include <string>
3 #include <vector>
4 
5 #include <tdme/tdme.h>
7 #include <tdme/engine/Version.h>
10 #include <tdme/utilities/Console.h>
14 
15 using std::set;
16 using std::string;
17 using std::vector;
18 
27 
28 
29 void parseHpp(const string& fileName) {
30  Console::println("Processing file: " + fileName);
31  vector<string> fileContent;
32  FileSystem::getInstance()->getContentAsStringArray(".", fileName, fileContent);
33  StringTokenizer lineStringTokenizer;
34  auto symbolsMode = false;
35  set<string> symbols;
36  for (auto i = 0; i < fileContent.size(); i++) {
37  auto line = fileContent[i];
38  line = StringTools::trim(line);
39  if (symbolsMode == false) {
40  if (StringTools::endsWith(line, " public symbols") == true) {
41  symbolsMode = true;
42  i++;
43  }
44  } else {
45  if (line.empty() == true) {
46  symbolsMode = false;
47  } else {
48  lineStringTokenizer.tokenize(line, " ");
49  if (lineStringTokenizer.hasMoreTokens() == true) lineStringTokenizer.nextToken();
50  if (lineStringTokenizer.hasMoreTokens() == true) symbols.insert(lineStringTokenizer.nextToken());
51  }
52  }
53  }
54  vector<string> newFileContent;
55  newFileContent.push_back("EXPORTS");
56  for (const auto& symbol: symbols) newFileContent.push_back("\t" + symbol);
57  FileSystem::getInstance()->setContentFromStringArray(".", fileName + ".def", newFileContent);
58 }
59 
60 int main(int argc, char** argv)
61 {
62  Console::println(string("msclib2dll ") + Version::getVersion());
63  Console::println(Version::getCopyright());
64  Console::println();
65 
66  if (argc != 2) {
67  Console::println("Usage: msclib2dll path_to_file");
68  Console::println("Note: path_to_file can be obtained from dumpbin /LINKERMEMBER xyz.lib");
69  Application::exit(Application::EXITCODE_FAILURE);
70  }
71 
72  parseHpp(argv[1]);
73 
74  //
75  Application::exit(Application::EXITCODE_SUCCESS);
76 }
Application base class, please make sure to allocate application on heap to have correct application ...
Definition: Application.h:41
File system singleton class.
Definition: FileSystem.h:17
Console class.
Definition: Console.h:29
String tokenizer class.
void tokenize(const string &str, const string &delimiters, bool emptyTokens=false)
Tokenize.
String tools class.
Definition: StringTools.h:22
int main(int argc, char **argv)
void parseHpp(const string &fileName)
std::exception Exception
Exception base class.
Definition: Exception.h:18