24 #ifndef __DOTS_INTERNAL_TYPE_UTILITIES_H__
25 #define __DOTS_INTERNAL_TYPE_UTILITIES_H__
27 #include <Safir/Dob/Typesystem/ToolSupport/Internal/BasicTypeOperations.h>
40 namespace TypeUtilities
49 template <
class RepositoryT>
50 const char*
GetTypeName(
const RepositoryT* repository, DotsC_TypeId typeId)
52 return Safir::Dob::Typesystem::ToolSupport::Internal::BasicTypeOperations::TypeIdToTypeName(repository, typeId);
57 return LlufId_Generate64(name.c_str());
68 return Safir::Dob::Typesystem::ToolSupport::Internal::BasicTypeOperations::MemberTypeToString(memberType).c_str();
79 template <
class RepositoryT>
80 bool IsOfType(
const RepositoryT* repository, DotsC_TypeId tid, DotsC_TypeId ofTid)
96 template <
class EnumDescriptionT>
99 size_t pos=valueName.rfind(
'.');
100 if (pos==std::string::npos)
102 for (
int i=0; i<description->GetNumberOfValues(); ++i)
104 if (valueName==description->GetValueName(i))
112 std::string strippedValueName=valueName.substr(pos+1);
113 for (
int i=0; i<description->GetNumberOfValues(); ++i)
115 if (strippedValueName==description->GetValueName(i))
131 template <
class PropertyDescriptionT,
class MemberDescriptionT>
134 for (
int i=0; i<pd->GetNumberOfMembers(); ++i)
136 const MemberDescriptionT* md=pd->GetMember(i);
137 if (memberName==md->GetName())
139 return static_cast<DotsC_MemberIndex
>(i);
153 template <
class ClassDescriptionT,
class ParameterDescriptionT>
154 const ParameterDescriptionT*
GetParameterByName(
const ClassDescriptionT* cd,
const std::string& paramName)
156 size_t dot=paramName.rfind(
'.');
157 if (dot==std::string::npos)
159 for (
int i=0; i<cd->GetNumberOfParameters(); ++i)
161 const ParameterDescriptionT* pd=cd->GetParameter(i);
162 if (paramName==pd->GetName())
170 std::string shortName=paramName.substr(dot+1);
171 for (
int i=0; i<cd->GetNumberOfParameters(); ++i)
173 const ParameterDescriptionT* pd=cd->GetParameter(i);
174 if (shortName==pd->GetName())
186 template <
class RepT,
class Traits=Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepT> >
201 size_t pos=parameterName.rfind(
'.');
202 if (pos==std::string::npos)
207 std::string className=parameterName.substr(0, pos);
214 return GetParameterByName<ClassDescriptionType, ParameterDescriptionType>(cd, parameterName.substr(pos+1));