diff --git a/include/cppast/cpp_array_type.hpp b/include/cppast/cpp_array_type.hpp new file mode 100644 index 0000000..808e7a9 --- /dev/null +++ b/include/cppast/cpp_array_type.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Jonathan Müller +// This file is subject to the license terms in the LICENSE file +// found in the top-level directory of this distribution. + +#ifndef CPPAST_CPP_ARRAY_TYPE_HPP_INCLUDED +#define CPPAST_CPP_ARRAY_TYPE_HPP_INCLUDED + +#include +#include + +namespace cppast +{ + /// An array of a [cppast::cpp_type](). + class cpp_array_type final : public cpp_type + { + public: + /// \returns A newly created array. + static std::unique_ptr build(std::unique_ptr type, + std::unique_ptr size) + { + return std::unique_ptr( + new cpp_array_type(std::move(type), std::move(size))); + } + + /// \returns A reference to the value [cppast::cpp_type](). + const cpp_type& value_type() const noexcept + { + return *type_; + } + + /// \returns A [cppast::cpp_expression]() that is the size of the array. + const cpp_expression& size() const noexcept + { + return *size_; + } + + private: + cpp_array_type(std::unique_ptr type, std::unique_ptr size) + : type_(std::move(type)), size_(std::move(size)) + { + } + + cpp_type_kind do_get_kind() const noexcept override + { + return cpp_type_kind::array; + } + + std::unique_ptr type_; + std::unique_ptr size_; + }; +} // namespace cppast + +#endif // CPPAST_CPP_ARRAY_TYPE_HPP_INCLUDED diff --git a/include/cppast/cpp_type.hpp b/include/cppast/cpp_type.hpp index 720bf8a..feb8d36 100644 --- a/include/cppast/cpp_type.hpp +++ b/include/cppast/cpp_type.hpp @@ -22,6 +22,8 @@ namespace cppast pointer, reference, + array, + unexposed, };