From 5069c3b800a5806ef132d187c4ec93d037d55ad2 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 18 Mar 2017 21:41:46 +0100 Subject: fixed Q-Reg autocompletion for `Q` command * StateQueryQReg is now derived from StateExpectQReg whose semantics have been changed slightly. * The alternative would have been another common base class for both StateQueryQReg and StateExpectQReg. --- src/qregisters.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/qregisters.h') diff --git a/src/qregisters.h b/src/qregisters.h index d57323a..a08bafe 100644 --- a/src/qregisters.h +++ b/src/qregisters.h @@ -485,10 +485,11 @@ public: * Command states */ -/* +/** * Super class for states accepting Q-Register specifications */ class StateExpectQReg : public State { +protected: QRegSpecMachine machine; public: @@ -498,6 +499,16 @@ private: State *custom(gchar chr); protected: + /** + * Called when a register specification has been + * successfully parsed. + * The QRegSpecMachine is not reset automatically. + * + * @param reg Register of the parsed Q-Reg + * specification. May be NULL in + * parse-only mode or with QREG_OPTIONAL. + * @returns Next parser state. + */ virtual State *got_register(QRegister *reg) = 0; /* in cmdline.cpp */ @@ -540,14 +551,12 @@ private: State *got_file(const gchar *filename); }; -class StateQueryQReg : public State { - QRegSpecMachine machine; - +class StateQueryQReg : public StateExpectQReg { public: - StateQueryQReg(); + StateQueryQReg() : StateExpectQReg(QREG_OPTIONAL) {} private: - State *custom(gchar chr); + State *got_register(QRegister *reg); }; class StateCtlUCommand : public StateExpectQReg { -- cgit v1.2.3