Add signature() to cpp_function_base

This commit is contained in:
Jonathan Müller 2017-07-10 19:26:55 +02:00
commit 93d2c58f7f
8 changed files with 112 additions and 22 deletions

View file

@ -94,6 +94,14 @@ namespace cppast
return variadic_;
}
/// \returns The signature of the function,
/// i.e. parameters and cv/ref-qualifiers if a member function.
/// It has the form `(int,char,...) const`.
std::string signature() const
{
return do_get_signature();
}
protected:
/// Builder class for functions.
///
@ -176,6 +184,10 @@ namespace cppast
{
}
protected:
/// \returns The signature, it is called by [*signature()]().
virtual std::string do_get_signature() const;
private:
detail::intrusive_list<cpp_function_parameter> parameters_;
std::unique_ptr<cpp_expression> noexcept_expr_;

View file

@ -23,24 +23,10 @@ namespace cppast
pure, //< Set if the function is pure.
override, //< Set if the function overrides a base class function.
final, //< Set if the function is marked `final`.
};
} // namespace cppast
/// \exclude
namespace type_safe
{
template <>
struct flag_set_traits<cppast::cpp_virtual_flags> : std::true_type
{
static constexpr std::size_t size() noexcept
{
return 3u;
}
_flag_set_size, //< \exclude
};
} // namespace type_safe
namespace cppast
{
/// The `virtual` information of a member function.
///
/// This is an optional of the combination of the [cppast::cpp_virtual_flags]().
@ -161,6 +147,9 @@ namespace cppast
{
}
protected:
std::string do_get_signature() const override;
private:
std::unique_ptr<cpp_type> return_type_;
cpp_virtual virtual_;

View file

@ -434,6 +434,9 @@ namespace cppast
// write prefix, variadic, name, suffix
void write_type(code_generator::output& output, const cpp_type& type, std::string name,
bool is_variadic = false);
// simple to_string() for types
std::string to_string(const cpp_type& type);
} // namespace detail
} // namespace cppast