8 #include "Arp/System/Core/Exception.hpp" 9 #include "Arp/System/Core/RuntimeTypeInfo.hpp" 23 static String GetNamespace(
const String& typeName,
bool isCommon)
25 size_t pos = isCommon ? typeName.
FindLastOf(
'.') : typeName.FindLastOf(
':');
31 return isCommon ? typeName.
Substr(0, pos) : typeName.
Substr(0, pos - 1);
34 static String GetClassName(
const String& typeName,
bool isCommon)
36 size_t pos = isCommon ? typeName.
FindLastOf(
'.') : typeName.FindLastOf(
':');
42 return typeName.Substr(pos + 1);
54 template<
class T =
void>
78 String GetCommonName(
void)
const;
82 String GetSafeName(
void)
const;
85 String GetNamespace(
void)
const;
88 String GetClassName(
void)
const;
93 operator const String& (void)
const;
96 operator const char*(void)
const;
107 TypeName(
const char* typeName,
bool isCommon =
false);
110 void AssignTypeName(
const char* typeName,
bool isCommon);
117 bool isCommon =
false;
126 this->AssignTypeName(
typeid(T).name(),
false);
132 this->AssignTypeName(typeName, isCommonArg);
138 String result(this->Value);
146 String result(this->Value);
162 return __Internal::TypeNameHelper::GetNamespace(this->Value, this->isCommon);
168 return __Internal::TypeNameHelper::GetClassName(this->Value, this->isCommon);
174 this->isCommon = isCommonArg;
178 this->Value = typeName;
183 if (this->Value.IsEmpty())
185 throw Exception(
"Demangling of type name '{0}' failed.",
typeid(T).name());
190 if (Value.Find(
"class ") == 0)
192 Value = Value.Substr(6);
194 else if (Value.Find(
"struct ") == 0)
196 Value = Value.Substr(7);
198 else if (Value.Find(
"enum ") == 0)
200 Value = Value.Substr(5);
214 return this->Value.CStr();
220 return this->Value == other.
Value;
226 return !(*
this == other);
234 inline std::ostream& operator<<(std::ostream& os, const TypeName<T>& typeName)
236 os << typeName.Value;
261 return GetFrom(&instance);
271 const char* pResult =
typeid(*pInstance).name();
282 return __Internal::TypeNameHelper::GetNamespace(typeName, isCommon);
291 return __Internal::TypeNameHelper::GetClassName(typeName, isCommon);
static String GetClassName(const String &typeName, bool isCommon)
Extracts the classname of the given typename.
Definition: TypeName.hxx:289
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:218
This (meta programming) class provides the C++ typename of the as template argument passed type...
Definition: TypeName.hxx:55
bool operator!=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string on inequality.
Definition: BasicString.hxx:1788
SelfType Substr(size_type offset=0, size_type count=NPos) const
Gets a substring of this string.
Definition: BasicString.hxx:1530
static TypeName< T2 > GetFrom(T2 &instance)
Creates the TypeName from the as argument passed variable.
Definition: TypeName.hxx:259
static TypeName< T2 > GetFrom(T2 *pInstance)
Creates the TypeName from the as argument passed variable pointer.
Definition: TypeName.hxx:269
size_type FindLastOf(const SelfType &chars, size_type offset=NPos) const
Finds the last occurence of any character in chars .
Definition: BasicString.hxx:1263
static String GetNamespace(const String &typeName, bool isCommon)
Extracts the namespace of the given typename.
Definition: TypeName.hxx:280
static const SelfType Empty
An emtpy static string instance.
Definition: BasicString.hxx:222
static String DemangleSymbol(const char *symbolName)
Demangles a symbol
Arp::BasicString< char8 > String
The Arp String class.
Definition: TypeSystem.h:27
SelfType & ReplaceAll(const SelfType &pattern, const SelfType &replacement)
Replaces a given pattern by a replacement string.
Definition: BasicString.hxx:836
bool operator!=(const TypeName &other)
Determines if this instance is not equal to other .
Definition: TypeName.hxx:224
String GetCommonName(void) const
Gets the common name of the as template parameter given type according to the CLS.
Definition: TypeName.hxx:136
TypeName(void)
Constructs a CommonTypeName instance and determines the typename of the of T.
Definition: TypeName.hxx:124
Root namespace for the PLCnext API
String GetNamespace(void) const
Gets the namespace of the as template parameter given type.
Definition: TypeName.hxx:160
bool operator==(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string on equality.
Definition: BasicString.hxx:1752
String Value
The resulting typename.
Definition: TypeName.hxx:114
This is the base class of all Arp exception classes.
Definition: Exception.hpp:15
String GetSafeName(void) const
Gets a safe name of the as template parameter given type.
Definition: TypeName.hxx:144
String GetClassName(void) const
Gets the classname of the as template parameter given type.
Definition: TypeName.hxx:166
bool operator==(const TypeName &other)
Determines if this instance is equal to other .
Definition: TypeName.hxx:218