1 //===-- OptionValueRegex.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/OptionValueRegex.h"
14 // Other libraries and framework includes
16 #include "lldb/Core/Stream.h"
19 using namespace lldb_private;
22 OptionValueRegex::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
24 if (dump_mask & eDumpOptionType)
25 strm.Printf ("(%s)", GetTypeAsCString ());
26 if (dump_mask & eDumpOptionValue)
28 if (dump_mask & eDumpOptionType)
29 strm.PutCString (" = ");
30 if (m_regex.IsValid())
32 const char *regex_text = m_regex.GetText();
33 if (regex_text && regex_text[0])
34 strm.Printf ("%s", regex_text);
44 OptionValueRegex::SetValueFromCString (const char *value_cstr,
45 VarSetOperationType op)
50 case eVarSetOperationInvalid:
51 case eVarSetOperationInsertBefore:
52 case eVarSetOperationInsertAfter:
53 case eVarSetOperationRemove:
54 case eVarSetOperationAppend:
55 error = OptionValue::SetValueFromCString (value_cstr, op);
58 case eVarSetOperationClear:
62 case eVarSetOperationReplace:
63 case eVarSetOperationAssign:
64 if (m_regex.Compile (value_cstr, m_regex.GetCompileFlags()))
66 m_value_was_set = true;
70 char regex_error[1024];
71 if (m_regex.GetErrorAsCString(regex_error, sizeof(regex_error)))
72 error.SetErrorString (regex_error);
74 error.SetErrorStringWithFormat ("regex error %u", m_regex.GetErrorCode());
83 OptionValueRegex::DeepCopy () const
85 return OptionValueSP(new OptionValueRegex(m_regex.GetText(), m_regex.GetCompileFlags()));