From 97ed88bd3ad0cbd44732e5abedb6c6fd84d468fa Mon Sep 17 00:00:00 2001 From: ganome Date: Fri, 31 Jan 2025 16:32:12 -0700 Subject: [PATCH] Added a nested switch for different search methods, still only model search available --- src/main.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1af462c..51885fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,7 @@ int main() { createDB(dbFile); char quit = '&'; + char searchby = '&'; while(tolower(quit) != 'q') { std::cout << "========================\n"; @@ -38,12 +39,22 @@ int main() { std::cout << "(Q)uit hardware database\n"; std::cin >> quit; switch(tolower(quit)) { - case 's': - std::cout << "Enter search string: "; - std::cin >> msearch; - msearchlower = boost::algorithm::to_lower_copy(msearch); - searchTable(dbFile, msearchlower); // Replace this string with a variable that is the query grabbed from the user! - break; + case 's': + std::cout << "What would you like to search by?\n"; + std::cout << "(M)odel name\n"; + std::cout << "(Q)uit\n"; + std::cin >> searchby; + switch(tolower(searchby)) { + case 'm': + std::cout << "Enter search string: "; + std::cin >> msearch; + msearchlower = boost::algorithm::to_lower_copy(msearch); + searchTable(dbFile, msearchlower); // Replace this string with a variable that is the query grabbed from the user! + break; + default: + break; + } + break; case 'q': break; // default: