1314564Sdim//===-- OptionValueUInt64.h --------------------------------------*- C++
2314564Sdim//-*-===//
3254721Semaste//
4353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5353358Sdim// See https://llvm.org/LICENSE.txt for license information.
6353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef liblldb_OptionValueUInt64_h_
11254721Semaste#define liblldb_OptionValueUInt64_h_
12254721Semaste
13254721Semaste#include "lldb/Interpreter/OptionValue.h"
14254721Semaste
15254721Semastenamespace lldb_private {
16314564Sdim
17314564Sdimclass OptionValueUInt64 : public OptionValue {
18254721Semastepublic:
19314564Sdim  OptionValueUInt64() : OptionValue(), m_current_value(0), m_default_value(0) {}
20254721Semaste
21314564Sdim  OptionValueUInt64(uint64_t value)
22314564Sdim      : OptionValue(), m_current_value(value), m_default_value(value) {}
23254721Semaste
24314564Sdim  OptionValueUInt64(uint64_t current_value, uint64_t default_value)
25314564Sdim      : OptionValue(), m_current_value(current_value),
26314564Sdim        m_default_value(default_value) {}
27254721Semaste
28314564Sdim  ~OptionValueUInt64() override {}
29254721Semaste
30314564Sdim  // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object
31341825Sdim  // inside of a lldb::OptionValueSP object if all goes well. If the string
32341825Sdim  // isn't a uint64_t value or any other error occurs, return an empty
33341825Sdim  // lldb::OptionValueSP and fill error in with the correct stuff.
34321369Sdim  static lldb::OptionValueSP Create(const char *, Status &) = delete;
35321369Sdim  static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error);
36314564Sdim  // Virtual subclass pure virtual overrides
37314564Sdim
38314564Sdim  OptionValue::Type GetType() const override { return eTypeUInt64; }
39314564Sdim
40314564Sdim  void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
41314564Sdim                 uint32_t dump_mask) override;
42314564Sdim
43321369Sdim  Status
44314564Sdim  SetValueFromString(llvm::StringRef value,
45314564Sdim                     VarSetOperationType op = eVarSetOperationAssign) override;
46321369Sdim  Status
47314564Sdim  SetValueFromString(const char *,
48314564Sdim                     VarSetOperationType = eVarSetOperationAssign) = delete;
49314564Sdim
50314564Sdim  bool Clear() override {
51314564Sdim    m_current_value = m_default_value;
52314564Sdim    m_value_was_set = false;
53314564Sdim    return true;
54314564Sdim  }
55314564Sdim
56314564Sdim  lldb::OptionValueSP DeepCopy() const override;
57314564Sdim
58314564Sdim  // Subclass specific functions
59314564Sdim
60314564Sdim  const uint64_t &operator=(uint64_t value) {
61314564Sdim    m_current_value = value;
62314564Sdim    return m_current_value;
63314564Sdim  }
64314564Sdim
65314564Sdim  operator uint64_t() const { return m_current_value; }
66314564Sdim
67314564Sdim  uint64_t GetCurrentValue() const { return m_current_value; }
68314564Sdim
69314564Sdim  uint64_t GetDefaultValue() const { return m_default_value; }
70314564Sdim
71314564Sdim  void SetCurrentValue(uint64_t value) { m_current_value = value; }
72314564Sdim
73314564Sdim  void SetDefaultValue(uint64_t value) { m_default_value = value; }
74314564Sdim
75254721Semasteprotected:
76314564Sdim  uint64_t m_current_value;
77314564Sdim  uint64_t m_default_value;
78254721Semaste};
79254721Semaste
80254721Semaste} // namespace lldb_private
81254721Semaste
82296417Sdim#endif // liblldb_OptionValueUInt64_h_
83