From 0b3fa73bda56028ffd22d7878d37d6fa3aa998a8 Mon Sep 17 00:00:00 2001 From: Becca Date: Mon, 14 Sep 2015 16:46:49 -0500 Subject: [PATCH] done saveCmd --- dbCmds.txt | 5 +++++ db_engine.cpp | 20 ++++++++++++++++---- db_engine.h | 1 + test.cpp | 5 ++++- 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 dbCmds.txt diff --git a/dbCmds.txt b/dbCmds.txt new file mode 100644 index 0000000..9405325 --- /dev/null +++ b/dbCmds.txt @@ -0,0 +1,5 @@ +a +b +c +d +e diff --git a/db_engine.cpp b/db_engine.cpp index 4afe038..d6346c8 100755 --- a/db_engine.cpp +++ b/db_engine.cpp @@ -1,13 +1,16 @@ #include "db_engine.h" 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 //creates a vector void db_engine::createCmd(){ - //// + // } //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(){ - // + std::ofstream dbCmdFile; + dbCmdFile.open("dbCmds.txt", std::ios_base::app); + + std::vector::iterator it = cmdList.begin(); + while (it != cmdList.end()){ + dbCmdFile << *it << "\n"; + ++it; + } + + cmdList.clear(); } //display the table currently stored in memory diff --git a/db_engine.h b/db_engine.h index a949dfd..7c9b31c 100755 --- a/db_engine.h +++ b/db_engine.h @@ -1,3 +1,4 @@ +#include #include #include diff --git a/test.cpp b/test.cpp index 491d9f9..0eafca0 100755 --- a/test.cpp +++ b/test.cpp @@ -1,5 +1,8 @@ #include +#include "db_engine.h" int main() { - std::cout << "Hello World!"; + db_engine engine; + engine.saveCmd(); + std::cout << "succesfully traversed the code!"; } \ No newline at end of file