Package pygccxml :: Package declarations :: Module type_traits |

# Module type_traits

source code

defines few algorithms, that deals with different properties of C++ types

Do you aware of boost::type_traits library? pygccxml has functionality similar to it. Using functions defined in this module you can

- find out some properties of the type
- modify type

Those functions are very valuable for code generation. Almost all functions within this module works on type_t class hierarchy and\or class_t.

Classes
declaration_xxx_traits this class implements the functionality needed for convinient work with declaration classes
impl_details implementation details
smart_pointer_traits implements functionality, needed for convinient work with smart pointers
auto_ptr_traits implements functionality, needed for convinient work with std::auto_ptr pointers

Functions
remove_alias(type_) returns type without typedefs | source code
create_cv_types(base) implementation details | source code
decompose_type(tp) implementation details | source code
decompose_class(type) implementation details | source code
base_type(type) returns base type. | source code
does_match_definition(given, main, secondary) implementation details | source code
is_bool(type_) returns True, if type represents `bool`, False otherwise | source code
is_void(type) returns True, if type represents `void`, False otherwise | source code
is_void_pointer(type) returns True, if type represents `void*`, False otherwise | source code
is_integral(type) returns True, if type represents C++ integral type, False otherwise | source code
is_floating_point(type) returns True, if type represents C++ floating point type, False otherwise | source code
is_arithmetic(type) returns True, if type represents C++ integral or floating point type, False otherwise | source code
is_pointer(type) returns True, if type represents C++ pointer type, False otherwise | source code
is_calldef_pointer(type) returns True, if type represents pointer to free/member function, False otherwise | source code
remove_pointer(type) removes pointer from the type definition | source code
is_reference(type) returns True, if type represents C++ reference type, False otherwise | source code
is_array(type) returns True, if type represents C++ array type, False otherwise | source code
array_size(type) returns array size | source code
array_item_type(type_) returns array item type | source code
remove_reference(type) removes reference from the type definition | source code
is_const(type) returns True, if type represents C++ const type, False otherwise | source code
remove_const(type) removes const from the type definition | source code
remove_declarated(type) removes type-declaration class-binder declarated_t from the type | source code
is_same(type1, type2) returns True, if type1 and type2 are same types | source code
is_volatile(type) returns True, if type represents C++ volatile type, False otherwise | source code
remove_volatile(type) removes volatile from the type definition | source code
remove_cv(type) removes const and volatile from the type definition | source code
is_fundamental(type) returns True, if type represents C++ fundamental type | source code
is_enum(type) returns True, if type represents C++ enumeration declaration, False otherwise | source code
enum_declaration(type) returns reference to enum declaration | source code
is_class(type) returns True, if type represents C++ class definition, False otherwise | source code
is_class_declaration(type) returns True, if type represents C++ class declaration, False otherwise | source code
find_trivial_constructor(type) returns reference to trivial constructor or None | source code
has_trivial_constructor(class_) if class has public trivial constructor, this function will return reference to it, None otherwise | source code
has_copy_constructor(class_) if class has public copy constructor, this function will return reference to it, None otherwise | source code
has_destructor(class_) if class has destructor, this function will return reference to it, None otherwise | source code
has_public_constructor(class_) if class has any public constructor, this function will return list of them, otherwise None | source code
has_public_assign(class_) returns True, if class has public assign operator, False otherwise | source code
has_public_destructor(type) returns True, if class has public destructor, False otherwise | source code
is_base_and_derived(based, derived) returns True, if there is "base and derived" relationship between classes, False otherwise | source code
has_any_non_copyconstructor(type) if class has any public constructor, which is not copy constructor, this function will return list of them, otherwise None | source code
has_public_binary_operator(type, operator_symbol) returns True, if type has public binary operator, otherwise False | source code
has_public_equal(type) returns True, if class has public operator==, otherwise False | source code
has_public_less(type) returns True, if class has public operator<, otherwise False | source code
is_unary_operator(oper) returns True, if operator is unary operator, otherwise False | source code
is_binary_operator(oper) returns True, if operator is binary operator, otherwise False | source code
is_convertible(source, target) returns True, if source could be converted to target, otherwise False | source code
is_noncopyable(class_) returns True, if class is noncopyable, False otherwise | source code
is_defined_in_xxx(xxx, cls) small helper function, that checks whether class ( `cls` ) is defined under `::xxx` namespace | source code
is_std_string(type) returns True, if type represents C++ std::string, False otherwise | source code
is_std_wstring(type) returns True, if type represents C++ std::wstring, False otherwise | source code
is_std_ostream(type) returns True, if type represents C++ std::string, False otherwise | source code
is_std_wostream(type) returns True, if type represents C++ std::string, False otherwise | source code

Variables
| enum_traits = `declaration_xxx_traits(enumeration.enumeration_t)` implements functionality, needed for convinient work with C++ enums
| class_traits = `declaration_xxx_traits(class_declaration.class_t)` implements functionality, needed for convinient work with C++ classes
| class_declaration_traits = `declaration_xxx_traits(class_declar`...`` implements functionality, needed for convinient work with C++ class declarations

Function Details

### base_type(type) | source code
returns base type. For `const int` will return `int`

### remove_pointer(type) | source code
removes pointer from the type definition If type is not pointer type, it will be returned as is.

### remove_reference(type) | source code
removes reference from the type definition If type is not reference type, it will be returned as is.

### remove_const(type) | source code
removes const from the type definition If type is not const type, it will be returned as is

### remove_declarated(type) | source code
removes type-declaration class-binder declarated_t from the type If type is not declarated_t, it will be returned as is

### remove_volatile(type) | source code
removes volatile from the type definition If type is not volatile type, it will be returned as is

### enum_declaration(type) | source code
returns reference to enum declaration

Variables Details

  ### class_declaration_traits implements functionality, needed for convinient work with C++ class declarations Value:
      declaration_xxx_traits(class_declaration.class_declaration_t)