xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Expression/ExpressionSourceCode.h (revision e25152834cdf3b353892835a4f3b157e066a8ed4)
1 //===-- ExpressionSourceCode.h ----------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H
10 #define LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H
11 
12 #include "lldb/lldb-enumerations.h"
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/StringRef.h"
15 
16 #include <string>
17 
18 namespace lldb_private {
19 
20 class ExpressionSourceCode {
21 protected:
22   enum Wrapping : bool {
23     Wrap = true,
24     NoWrap = false,
25   };
26 
27 public:
NeedsWrapping()28   bool NeedsWrapping() const { return m_wrap == Wrap; }
29 
GetName()30   const char *GetName() const { return m_name.c_str(); }
31 
32 protected:
ExpressionSourceCode(llvm::StringRef name,llvm::StringRef prefix,llvm::StringRef body,Wrapping wrap)33   ExpressionSourceCode(llvm::StringRef name, llvm::StringRef prefix,
34                        llvm::StringRef body, Wrapping wrap)
35       : m_name(name.str()), m_prefix(prefix.str()), m_body(body.str()),
36         m_wrap(wrap) {}
37 
38   std::string m_name;
39   std::string m_prefix;
40   std::string m_body;
41   Wrapping m_wrap;
42 };
43 
44 } // namespace lldb_private
45 
46 #endif
47