done saveCmd
This commit is contained in:
parent
b98c396637
commit
0b3fa73bda
4 changed files with 26 additions and 5 deletions
5
dbCmds.txt
Normal file
5
dbCmds.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
e
|
|
@ -1,13 +1,16 @@
|
||||||
#include "db_engine.h"
|
#include "db_engine.h"
|
||||||
|
|
||||||
db_engine::db_engine(){
|
db_engine::db_engine(){
|
||||||
//
|
cmdList.push_back("a");
|
||||||
|
cmdList.push_back("b");
|
||||||
|
cmdList.push_back("c");
|
||||||
|
cmdList.push_back("d");
|
||||||
}
|
}
|
||||||
|
|
||||||
//create a new table in memory
|
//create a new table in memory
|
||||||
//creates a vector
|
//creates a vector
|
||||||
void db_engine::createCmd(){
|
void db_engine::createCmd(){
|
||||||
////
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
//open a txt file, parse SQL script, load data in table
|
//open a txt file, parse SQL script, load data in table
|
||||||
|
@ -15,9 +18,18 @@ void db_engine::createCmd(){
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//save all the commands to the db text file
|
//should write cmdList to a .txt file
|
||||||
void db_engine::saveCmd(){
|
void db_engine::saveCmd(){
|
||||||
//
|
std::ofstream dbCmdFile;
|
||||||
|
dbCmdFile.open("dbCmds.txt", std::ios_base::app);
|
||||||
|
|
||||||
|
std::vector<std::string>::iterator it = cmdList.begin();
|
||||||
|
while (it != cmdList.end()){
|
||||||
|
dbCmdFile << *it << "\n";
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//display the table currently stored in memory
|
//display the table currently stored in memory
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
5
test.cpp
5
test.cpp
|
@ -1,5 +1,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "db_engine.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::cout << "Hello World!";
|
db_engine engine;
|
||||||
|
engine.saveCmd();
|
||||||
|
std::cout << "succesfully traversed the code!";
|
||||||
}
|
}
|
Reference in a new issue