9 #include "Reflex/Object.h"
10 #include "Reflex/Base.h"
24 m_type.Destruct( ptr );
29 static std::string
const prefix(
"LCGReflex/");
32 throwException(
"Failure while loading dictionary for class \""+className+
"\".",
"ClassUtils::loadDictionary" );
40 if( type == castType ){
42 }
else if( type.HasBase( castType )){
43 Reflex::Object theObj( type, ptr );
44 ret = theObj.CastObject( castType ).Address();
52 if( type == baseType || type.HasBase( baseType )){
60 for (
unsigned int i=0;
i<type.BaseSize() && !
found;
i++){
64 func = base.OffsetFP();
76 char* realname = abi::__cxa_demangle( typeInfo.name(), 0, 0, &
status);
77 if( status == 0 && realname ){
86 if( typeInfo ==
typeid(std::string) ){
88 type = Reflex::Type::ByName(
"std::string");
92 type = Reflex::Type::ByTypeInfo( typeInfo );
94 if( !type && throwFlag ){
96 "ClassUtils::lookupDictionary" );
103 if( className ==
"std::basic_string<char>" ){
105 type = Reflex::Type::ByName(
"std::string");
109 type = Reflex::Type::ByName( className );
111 if( !type && throwFlag ){
112 throwException(
"Class \""+className+
"\" has not been found in the dictionary.",
113 "ClassUtils::lookupDictionary" );
120 if( typ.Name(Reflex::SCOPED)==
"std::string"){
121 ptr =
new std::string(
"");
123 ptr = typ.Construct().Address();
129 std::string
name = typ.Name(Reflex::SCOPED|Reflex::FINAL);
130 return ( name ==
"std::string" ||
131 name ==
"std::basic_string<char>" );
135 return ( typ.IsFundamental() || typ.IsEnum() ||
isTypeString( typ ) );
139 Reflex::TypeTemplate templ = typ.TemplateFamily();
143 std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
144 if( contName ==
"std::vector" ||
145 contName ==
"std::list" ||
146 contName ==
"std::deque" ||
147 contName ==
"std::stack" ||
148 contName ==
"std::set" ||
149 contName ==
"std::multiset" ||
150 contName ==
"__gnu_cxx::hash_set" ||
151 contName ==
"__gnu_cxx::hash_multiset" ||
152 contName ==
"std::map" ||
153 contName ==
"std::multimap" ||
154 contName ==
"__gnu_cxx::hash_map" ||
155 contName ==
"__gnu_cxx::hash_multimap" ||
156 contName ==
"ora::PVector" ||
157 contName ==
"ora::QueryableVector" ){
165 Reflex::TypeTemplate tt = typ.TemplateFamily();
169 std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
170 if( contName ==
"std::map" ||
171 contName ==
"std::multimap" ||
172 contName ==
"std::set" ||
173 contName ==
"std::multiset" ||
174 contName ==
"__gnu_cxx::hash_set" ||
175 contName ==
"__gnu_cxx::hash_multiset" ||
176 contName ==
"__gnu_cxx::hash_map" ||
177 contName ==
"__gnu_cxx::hash_multimap" ){
185 Reflex::TypeTemplate templ = typ.TemplateFamily();
189 std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
190 if( contName ==
"std::vector" ||
191 contName ==
"std::list" ||
192 contName ==
"std::deque" ||
193 contName ==
"std::stack" ||
194 contName ==
"ora::PVector" ||
195 contName ==
"ora::QueryableVector" ){
203 Reflex::TypeTemplate tt = typ.TemplateFamily();
207 std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
208 if( contName ==
"std::map" ||
209 contName ==
"std::multimap" ||
210 contName ==
"__gnu_cxx::hash_map" ||
211 contName ==
"__gnu_cxx::hash_multimap" ){
219 Reflex::TypeTemplate tt = typ.TemplateFamily();
223 std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
224 if( contName ==
"std::vector" ||
225 contName ==
"std::list" ||
226 contName ==
"std::deque" ||
227 contName ==
"std::stack" ||
228 contName ==
"std::set" ||
229 contName ==
"std::multiset" ||
230 contName ==
"__gnu_cxx::hash_set" ||
231 contName ==
"__gnu_cxx::hash_multiset" ||
232 contName ==
"ora::PVector" ||
233 contName ==
"ora::QueryableVector"){
242 Reflex::TypeTemplate templ = typ.TemplateFamily();
246 std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
247 if( contName ==
"ora::Ptr" ){
255 return typ.HasBase(Reflex::Type::ByTypeInfo(
typeid(
ora::Reference)));
263 Reflex::TypeTemplate templ = typ.TemplateFamily();
267 std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
268 if( contName ==
"ora::UniqueRef" ){
276 Reflex::TypeTemplate templ = typ.TemplateFamily();
280 std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
281 if( contName ==
"ora::PVector" ){
289 Reflex::TypeTemplate templ = typ.TemplateFamily();
293 std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
294 if( contName ==
"ora::QueryableVector" ){
307 if( resType.IsArray() )
return false;
320 size_t subTypeSize = typ.SubTypeSize();
322 while(i<subTypeSize){
324 if(sti.Name()==
"value_type") {
336 size_t subTypeSize = typ.SubTypeSize();
338 while(i<subTypeSize){
340 if(sti.Name()==
"key_type") {
352 size_t subTypeSize = typ.SubTypeSize();
354 while(i<subTypeSize){
356 if(sti.Name()==
"mapped_type") {
367 size_t subTypeSize = typ.SubTypeSize();
369 while(i<subTypeSize){
371 if(sti.Name()==subTypeName) {
382 while(resolvedType.IsTypedef()){
383 resolvedType = resolvedType.ToType();
bool isTypeOraPointer(const Reflex::Type &typ)
bool isTypeNonKeyedContainer(const Reflex::Type &typ)
bool isTypeAssociativeContainer(const Reflex::Type &typ)
bool isTypeString(const Reflex::Type &typ)
void * constructObject(const Reflex::Type &typ)
bool isTypePVector(const Reflex::Type &typ)
bool isTypeOraReference(const Reflex::Type &typ)
void operator()(void *ptr)
bool findBaseType(Reflex::Type &type, Reflex::Type &baseType, Reflex::OffsetFunction &func)
bool isTypeUniqueReference(const Reflex::Type &typ)
std::string demangledName(const std::type_info &typeInfo)
Reflex::Type containerSubType(const Reflex::Type &typ, const std::string &subTypeName)
Reflex::Type containerDataType(const Reflex::Type &typ)
void loadDictionary(const std::string &className)
RflxDeleter(const Reflex::Type &type)
bool isTypeContainer(const Reflex::Type &typ)
static PluginCapabilities * get()
Reflex::Type containerKeyType(const Reflex::Type &typ)
Reflex::Type containerValueType(const Reflex::Type &typ)
Reflex::Type resolvedType(const Reflex::Type &typ)
bool isTypeKeyedContainer(const Reflex::Type &typ)
bool isTypePrimitive(const Reflex::Type &typ)
bool isTypeNamedReference(const Reflex::Type &typ)
void * upCast(const Reflex::Type &type, void *ptr, const Reflex::Type &asType)
void throwException(const std::string &message, const std::string &methodName)
void load(const std::string &iName)
bool isTypeNonAssociativeContainer(const Reflex::Type &typ)
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
bool isTypeObject(const Reflex::Type &typ)
std::string className(const T &t)
bool isType(const Reflex::Type &type, const Reflex::Type &baseType)
bool isTypeQueryableVector(const Reflex::Type &typ)