summaryrefslogtreecommitdiff
path: root/brillo/type_name_undecorate.h
blob: 2da657cef7d8eba62e0b8a04ceca9188fb72df2c (plain)
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
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBCHROMEOS_BRILLO_TYPE_NAME_UNDECORATE_H_
#define LIBCHROMEOS_BRILLO_TYPE_NAME_UNDECORATE_H_

#include <string>
#include <typeinfo>

#include <brillo/brillo_export.h>

namespace brillo {

// Use brillo::UndecorateTypeName() to obtain human-readable type from
// the decorated/mangled type name returned by std::type_info::name().
BRILLO_EXPORT std::string UndecorateTypeName(const char* type_name);

// A template helper function that returns the undecorated type name for type T.
template<typename T>
inline std::string GetUndecoratedTypeName() {
  return UndecorateTypeName(typeid(T).name());
}

}  // namespace brillo

#endif  // LIBCHROMEOS_BRILLO_TYPE_NAME_UNDECORATE_H_