From cc5154c8d3c4c427233709609d4db64219a82529 Mon Sep 17 00:00:00 2001 From: ZhuangYumin Date: Thu, 14 Dec 2023 14:16:42 +0000 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AEmodify=E4=B8=8D=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E5=87=BA=E7=8E=B0=E9=87=8D=E5=A4=8D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/lexer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/lexer.cpp b/backend/src/lexer.cpp index 65c6288..8681a23 100644 --- a/backend/src/lexer.cpp +++ b/backend/src/lexer.cpp @@ -347,18 +347,33 @@ bool CommandModifyLexer(const std::string &command, std::string &ISBN, author = ""; keyword = ""; price = -1; + bool has_ISBN = false; + bool has_name = false; + bool has_author = false; + bool has_keyword = false; + bool has_price = false; while (ss >> token) { if (token[1] == 'I') { + if (has_ISBN) return false; + has_ISBN = true; // debugPrint("ISBN's token is ", token); ISBN = token.substr(6); } else if (token[1] == 'n') { + if (has_name) return false; + has_name = true; name = token.substr(6 + 1, token.size() - 7 - 1); } else if (token[1] == 'a') { + if (has_author) return false; + has_author = true; author = token.substr(8 + 1, token.size() - 9 - 1); } else if (token[1] == 'k') { + if (has_keyword) return false; + has_keyword = true; keyword = token.substr(9 + 1, token.size() - 10 - 1); if (keyword.length() > 60) return false; } else if (token[1] == 'p') { + if (has_price) return false; + has_price = true; price = std::stod(token.substr(7)); } else return false;