blob: a3be73997c2677f75487bf3276ac14de8f6ff110 [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- 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
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02009#ifndef LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H
10#define LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H
Andrew Walbran3d2c1972020-04-07 12:24:26 +010011
12#include "lldb/lldb-enumerations.h"
13#include "llvm/ADT/ArrayRef.h"
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020014#include "llvm/ADT/StringRef.h"
Andrew Walbran3d2c1972020-04-07 12:24:26 +010015
16#include <string>
17
18namespace lldb_private {
19
20class ExpressionSourceCode {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020021protected:
22 enum Wrapping : bool {
23 Wrap = true,
24 NoWrap = false,
25 };
26
Andrew Walbran3d2c1972020-04-07 12:24:26 +010027public:
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020028 bool NeedsWrapping() const { return m_wrap == Wrap; }
Andrew Walbran3d2c1972020-04-07 12:24:26 +010029
30 const char *GetName() const { return m_name.c_str(); }
31
32protected:
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020033 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) {}
Andrew Walbran3d2c1972020-04-07 12:24:26 +010037
38 std::string m_name;
39 std::string m_prefix;
40 std::string m_body;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020041 Wrapping m_wrap;
Andrew Walbran3d2c1972020-04-07 12:24:26 +010042};
43
44} // namespace lldb_private
45
46#endif