added dependencies to modinfo format in modinfoparser.cpp
This commit is contained in:
parent
9b6190ae15
commit
5f9d3c683e
@ -3,11 +3,13 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
struct rmodinfo {
|
||||
string name;
|
||||
string description;
|
||||
vector<string> deps;
|
||||
int release;
|
||||
string repotype;
|
||||
string repoaddr;
|
||||
@ -56,10 +58,10 @@ while(!modinfo.eof()) {
|
||||
for(int i = 1; line[i] != ']' && i < line.length(); i++) {
|
||||
tmpact += line[i];
|
||||
}
|
||||
if(tmpact == "description" || tmpact == "release" || tmpact == "repotype" || tmpact == "repoaddr") {
|
||||
if(tmpact == "description" || tmpact == "release" || tmpact == "deps" || tmpact == "repotype" || tmpact == "repoaddr") {
|
||||
action = tmpact;
|
||||
} else {
|
||||
cerr << "Modinfo parse error: Found " << tmpact << " although description/release/repotype/repoaddr was expected." << endl;
|
||||
cerr << "Modinfo parse error: Found " << tmpact << " although description/release/deps/repotype/repoaddr was expected." << endl;
|
||||
modinfo.close();
|
||||
return 1;
|
||||
}
|
||||
@ -86,6 +88,20 @@ while(!modinfo.eof()) {
|
||||
tmp.release = atoi(line.c_str());
|
||||
action = "parse";
|
||||
}
|
||||
} else if(action == "deps") {
|
||||
if(line[0] == '{') {
|
||||
cerr << "Modinfo parse error: Found " << line[0] << " although string or [ was expected." << endl;
|
||||
modinfo.close();
|
||||
return 1;
|
||||
} else if(line[0] == '[') {
|
||||
if(line[1] == 'd' && line[2] == 'e' && line[3] == 'p' && line[4] == 's' && line[5] == 'e' && line[6] == 'n' && line[7] == 'd' && line[8] == ']') {
|
||||
action = "parse";
|
||||
} else {
|
||||
cerr << "Modinfo parse error: Found " << line << " although string or [depsend] was expected." << endl;
|
||||
}
|
||||
} else {
|
||||
tmp.deps.push_back(line);
|
||||
}
|
||||
} else if(action == "repotype") {
|
||||
if(line[0] == '[' || line[0] == '{') {
|
||||
cerr << "Modinfo parse error: Found " << line[0] << " although string was expected." << endl;
|
||||
@ -131,7 +147,11 @@ if(pr == 1) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
cout << "Modinfo parsed successfully! This is how your mod will be displayed like: " << endl;
|
||||
cout << "modlist/" << rmi.name << " (release: " << rmi.release << ")" << endl << rmi.description << endl;
|
||||
cout << "modlist/" << rmi.name << " (release: " << rmi.release << ")" << endl << rmi.description << endl << "dependencies: ";
|
||||
for(int i = 0; i < rmi.deps.size(); i++) {
|
||||
cout << rmi.deps[i] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
cout << "and this is what will be also read by 3m:" << endl;
|
||||
cout << "repotype: " << rmi.repotype << ", repoaddr: " << rmi.repoaddr << endl;
|
||||
return EXIT_SUCCESS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user