1 //===-- OptionValueSInt64.cpp -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Interpreter/OptionValueSInt64.h"
14 // Other libraries and framework includes
16 #include "lldb/Host/StringConvert.h"
17 #include "lldb/Utility/Stream.h"
20 using namespace lldb_private;
22 void OptionValueSInt64::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
24 // printf ("%p: DumpValue (exe_ctx=%p, strm, mask) m_current_value = %" PRIi64
25 // "\n", this, exe_ctx, m_current_value);
26 if (dump_mask & eDumpOptionType)
27 strm.Printf("(%s)", GetTypeAsCString());
28 // if (dump_mask & eDumpOptionName)
29 // DumpQualifiedName (strm);
30 if (dump_mask & eDumpOptionValue) {
31 if (dump_mask & eDumpOptionType)
32 strm.PutCString(" = ");
33 strm.Printf("%" PRIi64, m_current_value);
37 Status OptionValueSInt64::SetValueFromString(llvm::StringRef value_ref,
38 VarSetOperationType op) {
41 case eVarSetOperationClear:
46 case eVarSetOperationReplace:
47 case eVarSetOperationAssign: {
49 std::string value_str = value_ref.trim().str();
50 int64_t value = StringConvert::ToSInt64(value_str.c_str(), 0, 0, &success);
52 if (value >= m_min_value && value <= m_max_value) {
53 m_value_was_set = true;
54 m_current_value = value;
57 error.SetErrorStringWithFormat(
58 "%" PRIi64 " is out of range, valid values must be between %" PRIi64
60 value, m_min_value, m_max_value);
62 error.SetErrorStringWithFormat("invalid int64_t string value: '%s'",
63 value_ref.str().c_str());
67 case eVarSetOperationInsertBefore:
68 case eVarSetOperationInsertAfter:
69 case eVarSetOperationRemove:
70 case eVarSetOperationAppend:
71 case eVarSetOperationInvalid:
72 error = OptionValue::SetValueFromString(value_ref, op);
78 lldb::OptionValueSP OptionValueSInt64::DeepCopy() const {
79 return OptionValueSP(new OptionValueSInt64(*this));