diff --git a/.gitignore b/.gitignore index aee1d95..b4a18f8 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ *.out *.app .vscode/tasks.json +src/.vscode/settings.json diff --git a/src/main.cpp b/src/main.cpp index 336e242..f97ef98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,7 @@ int main() { std::vector subjects; //make a dynamic array to hold subjects using a container loadSubjects(subjects); //this will load the subjects from the file, using the function from tracker.cpp + //idea: ask user for name, store subjects file under name to check if it exists addSubject(subjects); addSubject(subjects); diff --git a/src/tracker.cpp b/src/tracker.cpp index b2139da..ac68e89 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -3,16 +3,17 @@ #include #include -//here we will put the actual function definitions for main.cpp to use (protypes in tracker.h) +//here we will put the actual function definitions for main.cpp to use (prototypes in tracker.h) -/*this will load the array of subjects from our subjects.txt file*/ +/*this will load the array of subjects from our subjects.txt file*/ +/* NEED TO SWITCH TO A CSV FILE */ void loadSubjects(std::vector &subjects) { //make a dynamic array to hold subjects using a container std::cout << "Loading subjects..." << std::endl; //loading message to show that the program is working - std::ifstream inFile("subjects.txt"); // open file for reading + std::ifstream inFile("subjects.csv"); // open file for reading //check if the file exists if (!inFile) { //if the file does not exist std::cout << "Error: No Such File Exists. Creating New File" << std::endl; //print the error message - std::ofstream outFile("subjects.txt"); //use ofstream to make a new blank text file + std::ofstream outFile("subjects.csv"); //use ofstream to make a new blank text file return; //return nothing if the file does not exist } //read the file if it exists diff --git a/src/tracker.h b/src/tracker.h index 8834ae6..42da679 100644 --- a/src/tracker.h +++ b/src/tracker.h @@ -1,22 +1,36 @@ #include #include +using namespace std; //decided this would be easier than typing std:: before everything, and we aren't using any other namespaces // Example struct for a Subject object just to get us started struct Subject { - std::string name; - std::vector tasks; - int hoursStudied; - // int grade; // Uncomment if needed later + string name; + int64_t timeInSeconds; //storing time as seconds, will convert to minutes for display. Using int64_t to avoid issues with larger numbers. + vector tasks; //we will use a vector to hold the tasks + //int grade; //i don't know if we are going to use this yet, but i'm putting it here just in case - // Constructor to initialize name and hoursStudied - Subject(const std::string& name = "", int hoursStudied = 0) - : name(name), hoursStudied(hoursStudied) {} }; -//function prototypes -void loadSubjects(std::vector& subjects); //this will load the array of subjects from our subjects.txt file +/*Function Prototypes*/ +void loadSubjects(vector& subjects); //this will load the array of subjects from our subjects.txt file void saveSubjects(/*filler declaration*/); //this will save the array of subjects to our subjects.txt file -void addSubject(std::vector& subjects); //this will add a subject to the array of subjects -void addTask(std::vector& subjects); //this will add a task to a single subject -void welcomeMessage(std::string name); //this will print the welcome message -bool inputCheck(std::string& str); //this will check to see that there are no special characters in an input +void addSubject(vector& subjects); //this will add a subject to the array of subjects +void addTask(Subject& name); //take the subject, add the task to it and return +void welcomeMessage(string name); //this will print the welcome message +void displayView(string name); //print name (string), tasks (vector), time (int), call convertTime() +void convertTime(); //turn seconds to minutes for the display view + +/*CSV Parsing Prototypes*/ +vector parseTaskArray(const string& taskString); //parse the string of tasks into a vector of strings +string formatTaskArray(const vector& tasks); //format the vector of tasks into a string so it can be written to the csv +Subject parseRow(const string& csvLine); //parse a row of the csv into a Subject object using the struct +string formatRow(const Subject& subject); //formats a Subject object into a string +void readCSV(vector& subjects); //reads the csv file and fills the vector of subjects +void writeCSV(const vector& subjects); //writes to the csv file with the vector of subjects + +/* +Example CSV file (putting this here so we can finish the actual functions to use this format) +subject_name,time_in_seconds,[task1,task2,task3] +Math,3600,[Review calculus,Practice integrals] +Physics,7200,[Read chapter 1,Lab prep] +*/