vfs: check userland buffers before reading them.
[haiku.git] / headers / private / debugger / model / ExpressionInfo.h
blobeb468f705b50bab9ded64b0f9da0200d47996b66
1 /*
2 * Copyright 2014, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef EXPRESSION_INFO_H
6 #define EXPRESSION_INFO_H
9 #include <String.h>
11 #include <Referenceable.h>
12 #include <util/DoublyLinkedList.h>
13 #include <Variant.h>
16 class Type;
17 class Value;
18 class ValueNodeChild;
21 enum expression_result_kind {
22 EXPRESSION_RESULT_KIND_UNKNOWN = 0,
23 EXPRESSION_RESULT_KIND_PRIMITIVE,
24 EXPRESSION_RESULT_KIND_VALUE_NODE,
25 EXPRESSION_RESULT_KIND_TYPE
29 class ExpressionResult : public BReferenceable {
30 public:
31 ExpressionResult();
32 virtual ~ExpressionResult();
35 expression_result_kind Kind() const { return fResultKind; }
37 Value* PrimitiveValue() const
38 { return fPrimitiveValue; }
39 ValueNodeChild* ValueNodeValue() const
40 { return fValueNodeValue; }
41 Type* GetType() const
42 { return fTypeResult; }
44 void SetToPrimitive(Value* value);
45 void SetToValueNode(ValueNodeChild* child);
46 void SetToType(Type* type);
47 private:
48 void _Unset();
50 private:
51 expression_result_kind fResultKind;
52 Value* fPrimitiveValue;
53 ValueNodeChild* fValueNodeValue;
54 Type* fTypeResult;
58 class ExpressionInfo : public BReferenceable {
59 public:
60 class Listener;
62 public:
63 ExpressionInfo();
64 ExpressionInfo(const ExpressionInfo& other);
65 ExpressionInfo(const BString& expression);
66 virtual ~ExpressionInfo();
68 void SetTo(const BString& expression);
70 const BString& Expression() const { return fExpression; }
72 void AddListener(Listener* listener);
73 void RemoveListener(Listener* listener);
75 void NotifyExpressionEvaluated(status_t result,
76 ExpressionResult* value);
78 private:
79 typedef DoublyLinkedList<Listener> ListenerList;
81 private:
82 BString fExpression;
83 ListenerList fListeners;
87 class ExpressionInfo::Listener : public DoublyLinkedListLinkImpl<Listener> {
88 public:
89 virtual ~Listener();
91 virtual void ExpressionEvaluated(ExpressionInfo* info,
92 status_t result,
93 ExpressionResult* value) = 0;
97 #endif // EXPRESSION_INFO_H