-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathcpp_try_block.h
More file actions
54 lines (42 loc) · 1.25 KB
/
Copy pathcpp_try_block.h
File metadata and controls
54 lines (42 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (C) 2022 Satya Das and CppParser contributors
// SPDX-License-Identifier: MIT
#ifndef BFF3C538_E8C8_40D9_8ADF_948EC6671390
#define BFF3C538_E8C8_40D9_8ADF_948EC6671390
#include "cppast/cpp_compound.h"
#include "cppast/cpp_entity.h"
#include "cppast/cpp_var_type.h"
#include <string>
namespace cppast {
struct CppCatchBlock
{
std::unique_ptr<CppVarType> exceptionType_;
std::string exceptionName_;
std::unique_ptr<CppCompound> catchStmt_;
};
using CppCatchBlockPtr = std::unique_ptr<CppCatchBlock>;
using CppCatchBlocks = std::vector<CppCatchBlockPtr>;
class CppTryBlock : public CppEntity
{
public:
static constexpr auto EntityType()
{
return CppEntityType::TRY_BLOCK;
}
public:
CppTryBlock(std::unique_ptr<CppCompound> tryStmt, std::unique_ptr<CppCatchBlock> firstCatchBlock)
: CppEntity(EntityType())
, tryStmt_(std::move(tryStmt))
{
catchBlocks_.push_back(std::move(firstCatchBlock));
}
public:
void addCatchBlock(std::unique_ptr<CppCatchBlock> catchBlock)
{
catchBlocks_.emplace_back(std::move(catchBlock));
}
private:
std::unique_ptr<CppCompound> tryStmt_;
CppCatchBlocks catchBlocks_;
};
} // namespace cppast
#endif /* BFF3C538_E8C8_40D9_8ADF_948EC6671390 */