introspection: add more types to type_string
This commit is contained in:
parent
6e656444c6
commit
b1eb9982d1
@ -11,7 +11,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
*
|
||||||
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
|
* Copyright 2015-2016 Danny Robson <danny@nerdcruft.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "introspection.hpp"
|
#include "introspection.hpp"
|
||||||
@ -35,4 +35,4 @@ constexpr char util::type_string<double>::value[];
|
|||||||
|
|
||||||
constexpr char util::type_string<std::string>::value[];
|
constexpr char util::type_string<std::string>::value[];
|
||||||
constexpr char util::type_string<char*>::value[];
|
constexpr char util::type_string<char*>::value[];
|
||||||
constexpr char util::type_string<char[]>::value[];
|
constexpr char util::type_string<const char*>::value[];
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
*
|
||||||
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
|
* Copyright 2015-2016 Danny Robson <danny@nerdcruft.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __UTIL_INTROSPECTION_HPP
|
#ifndef __UTIL_INTROSPECTION_HPP
|
||||||
@ -21,6 +21,7 @@
|
|||||||
#include "./variadic.hpp"
|
#include "./variadic.hpp"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
@ -34,6 +35,9 @@ namespace util {
|
|||||||
|
|
||||||
template <> struct type_string<bool> { static constexpr const char value[] = "bool"; };
|
template <> struct type_string<bool> { static constexpr const char value[] = "bool"; };
|
||||||
|
|
||||||
|
template <> struct type_string<char> { static constexpr const char value[] = "char"; };
|
||||||
|
template <> struct type_string<void*> { static constexpr const char value[] = "void*"; };
|
||||||
|
|
||||||
template <> struct type_string< int8_t> { static constexpr const char value[] = "int8"; };
|
template <> struct type_string< int8_t> { static constexpr const char value[] = "int8"; };
|
||||||
template <> struct type_string< int16_t> { static constexpr const char value[] = "int16"; };
|
template <> struct type_string< int16_t> { static constexpr const char value[] = "int16"; };
|
||||||
template <> struct type_string< int32_t> { static constexpr const char value[] = "int32"; };
|
template <> struct type_string< int32_t> { static constexpr const char value[] = "int32"; };
|
||||||
@ -48,19 +52,18 @@ namespace util {
|
|||||||
template <> struct type_string<double > { static constexpr const char value[] = "float64"; };
|
template <> struct type_string<double > { static constexpr const char value[] = "float64"; };
|
||||||
|
|
||||||
template <> struct type_string<std::string> { static constexpr const char value[] = "string"; };
|
template <> struct type_string<std::string> { static constexpr const char value[] = "string"; };
|
||||||
template <> struct type_string<char*> { static constexpr const char value[] = "string"; };
|
template <> struct type_string<char*> { static constexpr const char value[] = "cstring"; };
|
||||||
template <> struct type_string<char[]> { static constexpr const char value[] = "string"; };
|
template <> struct type_string<const char*> { static constexpr const char value[] = "cstring"; };
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr
|
constexpr
|
||||||
const char* type_string_v = type_string<T>::value;
|
const char* type_string_v = type_string<T>::value;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto
|
const char*
|
||||||
to_string (void)
|
to_string (void)
|
||||||
{
|
{ return type_string_v<T>; }
|
||||||
return type_string<T>::value;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
/// Lists valid values of an enumeration
|
/// Lists valid values of an enumeration
|
||||||
|
Loading…
Reference in New Issue
Block a user