※ 引述《ijb ()》之銘言:
: CmdParser::parseCmd(String& option)
: {
: ....
: ....
: string cmd = str.substr(0, n); <--- 從option來的
這裏為什麼會跟 "option" 有關啊?
: CmdExec* e = getCmd(cmd);
: if(....)
: else if (n != string::npos) {
: size_t opt = str.find_first_not_of(' ',n); <--- 想請問這句話的意思
請參照 SGI STL 中 string 的 document...
: ....
: ....
: option=str.substr(opt);
: 意思是指 option = cmd的一部份 = option的一部份 ??
什麼??
Anyway, "option" 是 "str" 的一部分...
: 如果是這樣str.find_first_not_of(' ',n)的用意是取第一個空白字元後的command嗎?
: ^^
不是... 請參照 SGI STL 中 string 的 document...
: 所以TODO的getCmd,針對一連串的指令時,如madd a b 6 23 12
: 要怎麼寫對應的狀況??在這時候就可以給錯了嗎?
根據 reference code, "getCmd" 被呼叫時, 參數 "cmd" 只有 command part (e.g.
"madd")... 不曉得為什麼會有你說的這種情況?
: 拉里拉雜的....呃,連我自己都快看不懂了,真囧....
Good luck...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.121.131.138