Home | History | Annotate | Download | only in Interpreter
      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 #include <string>
     16 
     17 // Other libraries and framework includes
     18 // Project includes
     19 #include "lldb/Core/RegularExpression.h"
     20 #include "lldb/Interpreter/OptionValue.h"
     21 
     22 namespace lldb_private {
     23 
     24 class OptionValueRegex : public OptionValue
     25 {
     26 public:
     27     OptionValueRegex (const char *value = NULL, uint32_t regex_flags = 0) :
     28         OptionValue(),
     29         m_regex (value, regex_flags)
     30     {
     31     }
     32 
     33     virtual
     34     ~OptionValueRegex()
     35     {
     36     }
     37 
     38     //---------------------------------------------------------------------
     39     // Virtual subclass pure virtual overrides
     40     //---------------------------------------------------------------------
     41 
     42     virtual OptionValue::Type
     43     GetType () const
     44     {
     45         return eTypeRegex;
     46     }
     47 
     48     virtual void
     49     DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
     50 
     51     virtual Error
     52     SetValueFromCString (const char *value,
     53                          VarSetOperationType op = eVarSetOperationAssign);
     54 
     55     virtual bool
     56     Clear ()
     57     {
     58         m_regex.Clear();
     59         m_value_was_set = false;
     60         return true;
     61     }
     62 
     63     virtual lldb::OptionValueSP
     64     DeepCopy () const;
     65 
     66     //---------------------------------------------------------------------
     67     // Subclass specific functions
     68     //---------------------------------------------------------------------
     69     const RegularExpression *
     70     GetCurrentValue() const
     71     {
     72         if (m_regex.IsValid())
     73             return &m_regex;
     74         return NULL;
     75     }
     76 
     77     void
     78     SetCurrentValue (const char *value, uint32_t regex_flags)
     79     {
     80         if (value && value[0])
     81             m_regex.Compile (value, regex_flags);
     82         else
     83             m_regex.Clear();
     84     }
     85 
     86     bool
     87     IsValid () const
     88     {
     89         return m_regex.IsValid();
     90     }
     91 
     92 protected:
     93     RegularExpression m_regex;
     94 };
     95 
     96 } // namespace lldb_private
     97 
     98 #endif  // liblldb_OptionValueRegex_h_
     99