8#include "Arp/System/Core/Exception.hpp"
9#include "Arp/System/Core/RuntimeTypeInfo.hpp"
23 static size_t FindNamespaceEndPosition(
const String& typeName,
bool isCommon)
25 char separator = isCommon ?
'.' :
':';
27 size_t lastPos = typeName.FindFirstOf(
'<');
30 return typeName.FindLastOf(separator);
33 return typeName.FindLastOf(separator, lastPos);
36 static String GetNamespace(
const String& typeName,
bool isCommon)
38 size_t pos = FindNamespaceEndPosition(typeName, isCommon);
44 return isCommon ? typeName.
Substr(0, pos) : typeName.
Substr(0, pos - 1);
47 static String GetClassName(
const String& typeName,
bool isCommon)
49 size_t pos = FindNamespaceEndPosition(typeName, isCommon);
55 return typeName.Substr(pos + 1);
65template<
class T =
void>
107 operator const String& (void)
const;
110 operator const char*(void)
const;
121 TypeName(
const char* typeName,
bool isCommon =
false);
124 void AssignTypeName(
const char* typeName,
bool isCommon);
131 bool isCommon =
false;
140 this->AssignTypeName(
typeid(T).name(),
false);
146 this->AssignTypeName(typeName, isCommonArg);
158 String result(this->Value);
166 String result(this->Value);
185 return __Internal::TypeNameHelper::GetNamespace(this->Value, this->isCommon);
191 return __Internal::TypeNameHelper::GetClassName(this->Value, this->isCommon);
197 this->isCommon = isCommonArg;
201 this->Value = typeName;
206 if (this->Value.IsEmpty())
208 throw Exception(
"Demangling of type name '{0}' failed.",
typeid(T).name());
228 return this->Value.CStr();
234 return this->Value == other.
Value;
240 return !(*
this == other);
250 os << typeName.
Value;
275 return GetFrom(&instance);
285 const char* pResult =
typeid(*pInstance).name();
296 return __Internal::TypeNameHelper::GetNamespace(typeName, isCommon);
305 return __Internal::TypeNameHelper::GetClassName(typeName, isCommon);
static String DemangleSymbol(const char *symbolName)
Demangles a symbol
static String GetClassName(const String &typeName, bool isCommon)
Extracts the classname of the given typename.
Definition: TypeName.hxx:303
static TypeName< T2 > GetFrom(T2 *pInstance)
Creates the TypeName from the as argument passed variable pointer.
Definition: TypeName.hxx:283
static String GetNamespace(const String &typeName, bool isCommon)
Extracts the namespace of the given typename.
Definition: TypeName.hxx:294
static TypeName< T2 > GetFrom(T2 &instance)
Creates the TypeName from the as argument passed variable.
Definition: TypeName.hxx:273
This (meta programming) class provides the C++ typename of the as template argument passed type.
Definition: TypeName.hxx:67
String GetNamespace(void) const
Gets the namespace of the as template parameter given type.
Definition: TypeName.hxx:183
TypeName(TypeName &&arg) noexcept=default
The default move constructor.
String Value
The resulting typename.
Definition: TypeName.hxx:128
String GetSafeName(void) const
Gets a safe name of the as template parameter given type.
Definition: TypeName.hxx:164
bool operator!=(const TypeName &other)
Determines if this instance is not equal to other .
Definition: TypeName.hxx:238
String GetCommonName(void) const
Gets the common name of the as template parameter given type according to the CLS.
Definition: TypeName.hxx:156
TypeName & operator=(const TypeName &arg)=default
The default assignment operator.
~TypeName(void)=default
The default destructor..
TypeName(const TypeName &arg)=default
The default copy constructor.
String GetFullName(void) const
Gets the full typename of this instance.
Definition: TypeName.hxx:150
TypeName(void)
Constructs a CommonTypeName instance and determines the typename of the of T.
Definition: TypeName.hxx:138
String GetClassName(void) const
Gets the classname of the as template parameter given type.
Definition: TypeName.hxx:189
bool operator==(const TypeName &other)
Determines if this instance is equal to other .
Definition: TypeName.hxx:232
SelfType Substr(size_type offset=0, size_type count=NPos) const
Gets a substring of this string.
Definition: BasicString.hxx:1550
static const size_type NPos
This position value is returned when find operations do not match, or is used as default value for an...
Definition: BasicString.hxx:221
std::ostream & operator<<(std::ostream &os, const BasicString< CharType, Alloc > &right)
Streams the right string to the outstream os .
Definition: BasicString.hxx:1740
SelfType & ReplaceAll(const SelfType &pattern, const SelfType &replacement)
Replaces a given pattern by a replacement string.
Definition: BasicString.hxx:824
static const SelfType Empty
An emtpy static string instance.
Definition: BasicString.hxx:225
Arp::BasicString< char8 > String
The Arp String class.
Definition: TypeSystem.h:27
Root namespace for the PLCnext API