@@ -1008,6 +1008,41 @@ def value_type( type ):
1008
1008
raise RuntimeError ( "Unable to find out shared_ptr value type. shared_ptr class is: %s" % cls .decl_string )
1009
1009
return ref
1010
1010
1011
+ class auto_ptr_traits :
1012
+ """implements functionality, needed for convinient work with std::auto_ptr pointers"""
1013
+
1014
+ @staticmethod
1015
+ def is_smart_pointer ( type ):
1016
+ """returns True, if type represents instantiation of C{boost::shared_ptr}, False otherwise"""
1017
+ type = remove_alias ( type )
1018
+ type = remove_cv ( type )
1019
+ type = remove_declarated ( type )
1020
+ if not isinstance ( type , ( class_declaration .class_declaration_t , class_declaration .class_t ) ):
1021
+ return False
1022
+ if not impl_details .is_defined_in_xxx ( 'std' , type ):
1023
+ return False
1024
+ return type .decl_string .startswith ( '::std::auto_ptr<' )
1025
+
1026
+ @staticmethod
1027
+ def value_type ( type ):
1028
+ """returns reference to boost::shared_ptr value type"""
1029
+ if not auto_ptr_traits .is_smart_pointer ( type ):
1030
+ raise TypeError ( 'Type "%s" is not instantiation of std::auto_ptr' % type .decl_string )
1031
+ type = remove_alias ( type )
1032
+ cls = remove_cv ( type )
1033
+ cls = remove_declarated ( type )
1034
+ if isinstance ( cls , class_declaration .class_t ):
1035
+ return remove_declarated ( cls .typedef ( "element_type" , recursive = False ).type )
1036
+ elif not isinstance ( cls , ( class_declaration .class_declaration_t , class_declaration .class_t ) ):
1037
+ raise RuntimeError ( "Unable to find out auto_ptr value type. auto_ptr class is: %s" % cls .decl_string )
1038
+ else :
1039
+ value_type_str = templates .args ( cls .name )[0 ]
1040
+ ref = impl_details .find_value_type ( cls .top_parent , value_type_str )
1041
+ if None is ref :
1042
+ raise RuntimeError ( "Unable to find out auto_ptr value type. shared_ptr class is: %s" % cls .decl_string )
1043
+ return ref
1044
+
1045
+
1011
1046
def is_std_string ( type ):
1012
1047
"""returns True, if type represents C++ std::string, False otherwise"""
1013
1048
decl_strings = [
0 commit comments