1//===-- OptionValueSInt64.h --------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_OptionValueSInt64_h_
11#define liblldb_OptionValueSInt64_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Interpreter/OptionValue.h"
18
19namespace lldb_private {
20
21class OptionValueSInt64 : public OptionValue
22{
23public:
24    OptionValueSInt64 () :
25        OptionValue(),
26        m_current_value (0),
27        m_default_value (0),
28        m_min_value (INT64_MIN),
29        m_max_value (INT64_MAX)
30    {
31    }
32
33    OptionValueSInt64 (int64_t value) :
34        OptionValue(),
35        m_current_value (value),
36        m_default_value (value),
37        m_min_value (INT64_MIN),
38        m_max_value (INT64_MAX)
39    {
40    }
41
42    OptionValueSInt64 (int64_t current_value,
43                       int64_t default_value) :
44        OptionValue(),
45        m_current_value (current_value),
46        m_default_value (default_value),
47        m_min_value (INT64_MIN),
48        m_max_value (INT64_MAX)
49    {
50    }
51
52    OptionValueSInt64 (const OptionValueSInt64 &rhs) :
53        OptionValue(rhs),
54        m_current_value (rhs.m_current_value),
55        m_default_value (rhs.m_default_value),
56        m_min_value (rhs.m_min_value),
57        m_max_value (rhs.m_max_value)
58    {
59    }
60
61    virtual
62    ~OptionValueSInt64()
63    {
64    }
65
66    //---------------------------------------------------------------------
67    // Virtual subclass pure virtual overrides
68    //---------------------------------------------------------------------
69
70    virtual OptionValue::Type
71    GetType () const
72    {
73        return eTypeSInt64;
74    }
75
76    virtual void
77    DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
78
79    virtual Error
80    SetValueFromCString (const char *value,
81                         VarSetOperationType op = eVarSetOperationAssign);
82
83    virtual bool
84    Clear ()
85    {
86        m_current_value = m_default_value;
87        m_value_was_set = false;
88        return true;
89    }
90
91    virtual lldb::OptionValueSP
92    DeepCopy () const;
93
94    //---------------------------------------------------------------------
95    // Subclass specific functions
96    //---------------------------------------------------------------------
97
98    const int64_t &
99    operator = (int64_t value)
100    {
101        m_current_value = value;
102        return m_current_value;
103    }
104
105    int64_t
106    GetCurrentValue() const
107    {
108        return m_current_value;
109    }
110
111    int64_t
112    GetDefaultValue() const
113    {
114        return m_default_value;
115    }
116
117    bool
118    SetCurrentValue (int64_t value)
119    {
120        if (value >= m_min_value && value <= m_max_value)
121        {
122            m_current_value = value;
123            return true;
124        }
125        return false;
126    }
127
128    bool
129    SetDefaultValue (int64_t value)
130    {
131        if (value >= m_min_value && value <= m_max_value)
132        {
133            m_default_value = value;
134            return true;
135        }
136        return false;
137    }
138
139    void
140    SetMinimumValue (int64_t v)
141    {
142        m_min_value = v;
143    }
144
145    int64_t
146    GetMinimumValue () const
147    {
148        return m_min_value;
149    }
150
151    void
152    SetMaximumValue (int64_t v)
153    {
154        m_max_value = v;
155    }
156
157    int64_t
158    GetMaximumValue () const
159    {
160        return m_max_value;
161    }
162
163protected:
164    int64_t m_current_value;
165    int64_t m_default_value;
166    int64_t m_min_value;
167    int64_t m_max_value;
168};
169
170} // namespace lldb_private
171
172#endif  // liblldb_OptionValueSInt64_h_
173