| 21 | namespace KDevMI { |
| 22 | class MIDebugSession; |
| 23 | class MIVariable : public KDevelop::Variable |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | |
| 27 | |
| 28 | public: |
| 29 | MIVariable(MIDebugSession *session, KDevelop::TreeModel* model, KDevelop::TreeItem* parent, |
| 30 | const QString& expression, const QString& display = QString()); |
| 31 | |
| 32 | ~MIVariable() override; |
| 33 | |
| 34 | /* FIXME: should eventually remove, so that existence of |
| 35 | varobjs is fully encapsulalated inside GdbVariable. */ |
| 36 | const QString& varobj() const; |
| 37 | void handleUpdate(const MI::Value& var); |
| 38 | |
| 39 | /* Called when debugger dies. Clears the association between varobj names |
| 40 | and Variable instances. */ |
| 41 | void markAsDead(); |
| 42 | |
| 43 | bool canSetFormat() const override { return true; } |
| 44 | |
| 45 | protected: // Variable overrides |
| 46 | void attachMaybe(QObject *callback, const char *callbackMethod) override; |
| 47 | void fetchMoreChildren() override; |
| 48 | void formatChanged() override; |
| 49 | |
| 50 | protected: // Internal |
| 51 | friend class ::CreateVarobjHandler; |
| 52 | friend class ::FetchMoreChildrenHandler; |
| 53 | friend class ::SetFormatHandler; |
| 54 | |
| 55 | /** |
| 56 | * Construct a MIVariable child directly from a MI value |
| 57 | */ |
| 58 | MIVariable *createChild(const MI::Value &child); |
| 59 | |
| 60 | QString enquotedExpression() const; |
| 61 | virtual QString formatValue(const QString &rawValue) const; |
| 62 | |
| 63 | /** |
| 64 | * Format the value of a field "value" of a given tuple value and assign the result to @c this->value(). |
| 65 | * |
| 66 | * @pre @p tupleValue contains a field named "value" |
| 67 | * @return unformatted, raw value of the "value" field of @p tupleValue |
| 68 | */ |
| 69 | QString setValueToValueFieldOf(const MI::Value& tupleValue); |
| 70 | |
| 71 | /** |
| 72 | * If a given tuple value has a field "value", format the value |
| 73 | * of the field and assign the result to @c this->value(). |
| 74 | */ |
| 75 | void setValueToOptionalValueFieldOf(const MI::Value& tupleValue); |
| 76 | |
| 77 | bool sessionIsAlive() const; |
| 78 | |
| 79 | void setVarobj(const QString& v); |
| 80 | |