forked from standardese/cppast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp_language_linkage.hpp
More file actions
60 lines (48 loc) · 1.85 KB
/
Copy pathcpp_language_linkage.hpp
File metadata and controls
60 lines (48 loc) · 1.85 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
55
56
57
58
59
60
// Copyright (C) 2017-2019 Jonathan Müller <[email protected]>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#ifndef CPPAST_CPP_LANGUAGE_LINKAGE_HPP_INCLUDED
#define CPPAST_CPP_LANGUAGE_LINKAGE_HPP_INCLUDED
#include <cppast/cpp_entity.hpp>
#include <cppast/cpp_entity_container.hpp>
namespace cppast
{
/// A [cppast::cpp_entity]() modelling a language linkage.
class cpp_language_linkage final : public cpp_entity,
public cpp_entity_container<cpp_language_linkage, cpp_entity>
{
public:
static cpp_entity_kind kind() noexcept;
/// Builds a [cppast::cpp_language_linkage]().
class builder
{
public:
/// \effects Sets the name, that is the kind of language linkage.
explicit builder(std::string name) : linkage_(new cpp_language_linkage(std::move(name))) {}
/// \effects Adds an entity to the language linkage.
void add_child(std::unique_ptr<cpp_entity> child)
{
linkage_->add_child(std::move(child));
}
/// \returns The not yet finished language linkage.
cpp_language_linkage& get() const noexcept
{
return *linkage_;
}
/// \returns The finalized language linkage.
/// \notes It is not registered on purpose as nothing can refer to it.
std::unique_ptr<cpp_language_linkage> finish()
{
return std::move(linkage_);
}
private:
std::unique_ptr<cpp_language_linkage> linkage_;
};
/// \returns `true` if the linkage is a block, `false` otherwise.
bool is_block() const noexcept;
private:
using cpp_entity::cpp_entity;
cpp_entity_kind do_get_entity_kind() const noexcept override;
};
} // namespace cppast
#endif // CPPAST_CPP_LANGUAGE_LINKAGE_HPP_INCLUDED