Commit ff75a83c authored by Mario Bajer's avatar Mario Bajer
Browse files

cleaned list

changed multi to require target .json file
parent 26c8b8c0
...@@ -5,19 +5,19 @@ int main(){ ...@@ -5,19 +5,19 @@ int main(){
htmlHeader("list.cgi"); htmlHeader("list.cgi");
cout << "<body>" << endl; cout << "<body>"
cout << "<br>" << endl; "<br>"
cout << "<div class=\"container\">" << endl; "<div class=\"container\">"
cout << "<table class=\"table\">" << endl; "<table class=\"table\">"
cout << "<thead class=\"thead-dark\">" << endl; "<thead class=\"thead-dark\">"
cout << "<tr>" << endl; "<tr>"
cout << "<th>ID</th>" << endl; "<th>ID</th>"
cout << "<th>Dimension</th>" << endl; "<th>Dimension</th>"
cout << "<th>File Location</th>" << endl; "<th>File Location</th>"
cout << "<th></th>" << endl; "<th></th>"
cout << "</tr>" << endl; "</tr>"
cout << "</thead>" << endl; "</thead>"
cout << "<tbody>" << endl; "<tbody>" << endl;
string path = "Json"; string path = "Json";
for(const auto & entry : fs::directory_iterator(path)){ for(const auto & entry : fs::directory_iterator(path)){
......
...@@ -85,6 +85,7 @@ int main(){ ...@@ -85,6 +85,7 @@ int main(){
string matrixs1 = ""; string matrixs1 = "";
string matrixs2 = ""; string matrixs2 = "";
string matrixs3 = "";
form_iterator fi1 = formData.getElement("multi1"); form_iterator fi1 = formData.getElement("multi1");
if( !fi1->isEmpty() && fi1 != (*formData).end()) { if( !fi1->isEmpty() && fi1 != (*formData).end()) {
matrixs1 = **fi1; matrixs1 = **fi1;
...@@ -103,13 +104,24 @@ int main(){ ...@@ -103,13 +104,24 @@ int main(){
cout << "Error on Matrix 2!" << endl; cout << "Error on Matrix 2!" << endl;
} }
form_iterator fi3 = formData.getElement("multi3");
if( !fi3->isEmpty() && fi3 != (*formData).end()) {
matrixs3 = **fi3;
cout << matrixs3 << endl;
}
else {
cout << "Error on Matrix 3 (result)!" << endl;
}
string debug = "debug 0"; string debug = "debug 0";
cout << debug << endl; cout << debug << endl;
json json1; json json1;
json json2; json json2;
json json3;
ifstream in1(matrixs1); ifstream in1(matrixs1);
ifstream in2(matrixs2); ifstream in2(matrixs2);
// ifstream in3(matrixs3);
in1 >> json1; in1 >> json1;
in2 >> json2; in2 >> json2;
cout << "debug 1" << endl; cout << "debug 1" << endl;
...@@ -138,28 +150,34 @@ int main(){ ...@@ -138,28 +150,34 @@ int main(){
result = run(mult_strassen, matrix1, matrix2); result = run(mult_strassen, matrix1, matrix2);
cout << "debug 4"; cout << "debug 4";
json json3; // json3["id"] = result.ID;
// json3["dimension"] = result.dim;
srand(time(NULL));
result.ID = rand() % 100;
string folderpath = "Json/";
string testpath = folderpath + to_string(result.ID);
while(existsm(testpath)){
cout << "<p>" << "File mit ID: " << result.ID << " existiert bereits!" << "</p>";
result.ID = rand() % 100;
testpath = folderpath + to_string(result.ID);
}
folderpath += to_string(result.ID) + ".json";
json3["id"] = result.ID;
json3["dimension"] = result.dim;
int size = result.dim * result.dim; int size = result.dim * result.dim;
vector<int> v(result.data, result.data + size); vector<int> v(result.data, result.data + size);
json3["matrix"] = v; json3["matrix"] = v;
ofstream o;
o.open(folderpath); // json json3;
o << json3 << endl;
o.close(); // srand(time(NULL));
//
// result.ID = rand() % 100;
// string folderpath = "Json/";
// string testpath = folderpath + to_string(result.ID);
// while(existsm(testpath)){
// cout << "<p>" << "File mit ID: " << result.ID << " existiert bereits!" << "</p>";
// result.ID = rand() % 100;
// testpath = folderpath + to_string(result.ID);
// }
// folderpath += to_string(result.ID) + ".json";
// json3["id"] = result.ID;
// json3["dimension"] = result.dim;
// int size = result.dim * result.dim;
// vector<int> v(result.data, result.data + size);
// json3["matrix"] = v;
// ofstream o;
// o.open(folderpath);
// o << json3 << endl;
// o.close();
// result.generateMatrix(result.dim); // result.generateMatrix(result.dim);
cout << "Resulting Matrix saved at ID: " + to_string(result.ID) << endl; cout << "Resulting Matrix saved at ID: " + to_string(result.ID) << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment