Add and parse cpp_static_assert

This commit is contained in:
Jonathan Müller 2017-04-11 20:21:25 +02:00
commit 4db09778b5
14 changed files with 200 additions and 6 deletions

View file

@ -57,6 +57,8 @@ namespace cppast
class_template_t,
class_template_specialization_t,
static_assert_t,
unexposed_t,
count,

View file

@ -0,0 +1,52 @@
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#ifndef CPPAST_CPP_STATIC_ASSERT_HPP_INCLUDED
#define CPPAST_CPP_STATIC_ASSERT_HPP_INCLUDED
#include <cppast/cpp_entity.hpp>
#include <cppast/cpp_expression.hpp>
namespace cppast
{
class cpp_static_assert : public cpp_entity
{
public:
static cpp_entity_kind kind() noexcept;
/// \returns A newly created `static_assert()` entity.
/// \notes It will not be registered as nothing can refer to it.
static std::unique_ptr<cpp_static_assert> build(std::unique_ptr<cpp_expression> expr,
std::string msg)
{
return std::unique_ptr<cpp_static_assert>(
new cpp_static_assert(std::move(expr), std::move(msg)));
}
/// \returns A reference to the [cppast::cpp_expression]() that is being asserted.
const cpp_expression& expression() const noexcept
{
return *expr_;
}
/// \returns A reference to the message of the assertion.
const std::string& message() const noexcept
{
return msg_;
}
private:
cpp_static_assert(std::unique_ptr<cpp_expression> expr, std::string msg)
: cpp_entity(""), expr_(std::move(expr)), msg_(std::move(msg))
{
}
cpp_entity_kind do_get_entity_kind() const noexcept override;
std::unique_ptr<cpp_expression> expr_;
std::string msg_;
};
} // namespace cppast
#endif // CPPAST_CPP_STATIC_ASSERT_HPP_INCLUDED