]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueRegex.h
Update to ELF Tool Chain r3475
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / OptionValueRegex.h
1 //===-- OptionValueRegex.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_OptionValueRegex_h_
11 #define liblldb_OptionValueRegex_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/RegularExpression.h"
18 #include "lldb/Interpreter/OptionValue.h"
19
20 namespace lldb_private {
21
22 class OptionValueRegex : public OptionValue
23 {
24 public:
25     OptionValueRegex(const char *value = nullptr) :
26         OptionValue(),
27         m_regex (value)
28     {
29     }
30
31     ~OptionValueRegex() override = default;
32
33     //---------------------------------------------------------------------
34     // Virtual subclass pure virtual overrides
35     //---------------------------------------------------------------------
36     
37     OptionValue::Type
38     GetType() const override
39     {
40         return eTypeRegex;
41     }
42     
43     void
44     DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
45     
46     Error
47     SetValueFromString(llvm::StringRef value,
48                        VarSetOperationType op = eVarSetOperationAssign) override;
49
50     bool
51     Clear() override
52     {
53         m_regex.Clear();
54         m_value_was_set = false;
55         return true;
56     }
57
58     lldb::OptionValueSP
59     DeepCopy() const override;
60
61     //---------------------------------------------------------------------
62     // Subclass specific functions
63     //---------------------------------------------------------------------
64     const RegularExpression *
65     GetCurrentValue() const
66     {
67         return (m_regex.IsValid() ? &m_regex : nullptr);
68     }
69     
70     void
71     SetCurrentValue (const char *value)
72     {
73         if (value && value[0])
74             m_regex.Compile (value);
75         else
76             m_regex.Clear();
77     }
78
79     bool
80     IsValid () const
81     {
82         return m_regex.IsValid();
83     }
84     
85 protected:
86     RegularExpression m_regex;
87 };
88
89 } // namespace lldb_private
90
91 #endif // liblldb_OptionValueRegex_h_