1 //===-- OptionValueSInt64.cpp ---------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Interpreter/OptionValueSInt64.h"
11 #include "lldb/Utility/Stream.h"
14 using namespace lldb_private
;
16 void OptionValueSInt64::DumpValue(const ExecutionContext
*exe_ctx
, Stream
&strm
,
18 // printf ("%p: DumpValue (exe_ctx=%p, strm, mask) m_current_value = %"
20 // "\n", this, exe_ctx, m_current_value);
21 if (dump_mask
& eDumpOptionType
)
22 strm
.Printf("(%s)", GetTypeAsCString());
23 // if (dump_mask & eDumpOptionName)
24 // DumpQualifiedName (strm);
25 if (dump_mask
& eDumpOptionValue
) {
26 if (dump_mask
& eDumpOptionType
)
27 strm
.PutCString(" = ");
28 strm
.Printf("%" PRIi64
, m_current_value
);
32 Status
OptionValueSInt64::SetValueFromString(llvm::StringRef value_ref
,
33 VarSetOperationType op
) {
36 case eVarSetOperationClear
:
41 case eVarSetOperationReplace
:
42 case eVarSetOperationAssign
: {
43 llvm::StringRef value_trimmed
= value_ref
.trim();
45 if (llvm::to_integer(value_trimmed
, value
)) {
46 if (value
>= m_min_value
&& value
<= m_max_value
) {
47 m_value_was_set
= true;
48 m_current_value
= value
;
51 error
= Status::FromErrorStringWithFormat(
52 "%" PRIi64
" is out of range, valid values must be between %" PRIi64
54 value
, m_min_value
, m_max_value
);
56 error
= Status::FromErrorStringWithFormat(
57 "invalid int64_t string value: '%s'", value_ref
.str().c_str());
61 case eVarSetOperationInsertBefore
:
62 case eVarSetOperationInsertAfter
:
63 case eVarSetOperationRemove
:
64 case eVarSetOperationAppend
:
65 case eVarSetOperationInvalid
:
66 error
= OptionValue::SetValueFromString(value_ref
, op
);