Class: Doxyparser::Type
Overview
Instance Attribute Summary collapse
-
#escaped_name ⇒ Object
readonly
Name of this Type without any reference/pointer symbols ‘* &’ or ‘const’ modifiers.
Attributes inherited from Node
#basename, #dir, #doc, #name, #node, #parent
Class Method Summary collapse
-
.nested_typenames(typename) ⇒ Array<String>
Returns the names for types nested in the parameter.
-
.template?(typename) ⇒ Boolean
True if the given type name has type parameters, false otherwise.
Instance Method Summary collapse
-
#name=(new_name) ⇒ Object
Setter for the name of this Type.
- #nested_local_types ⇒ Array<Type>
-
#nested_typenames ⇒ Array<String>
If this Type has type parameters (aka. template params), returns the names for types nested in this type’s name The ‘main’ type is always included, so for templates two or more names will be returned.
-
#template? ⇒ Boolean
True if this type has type parameters, false otherwise.
Methods inherited from Node
#==, #eql?, #initialize, #to_s, #to_str
Methods included from Util
#del_prefix_class, #del_prefix_file, #del_spaces, #do_filter, #escape_all, #escape_class_name, #escape_const_ref_ptr, escape_const_ref_ptr, #escape_file_name, #escape_template, home_dir, #match, read_file, write_file
Constructor Details
This class inherits a constructor from Doxyparser::Node
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Doxyparser::Node
Instance Attribute Details
#escaped_name ⇒ Object (readonly)
Name of this Doxyparser::Type without any reference/pointer symbols ‘* &’ or ‘const’ modifiers
8 9 10 |
# File 'lib/nodes/type.rb', line 8 def escaped_name @escaped_name end |
Class Method Details
.nested_typenames(typename) ⇒ Array<String>
Returns the names for types nested in the parameter.
The 'main' type is always included, so for templates two or more names will be returned.
Example: for mymap<std::string, MyClass, 4> the result is: [mymap, std::string, MyClass]
36 37 38 39 40 41 42 43 |
# File 'lib/nodes/type.rb', line 36 def self.nested_typenames(typename) escaped_typename = Doxyparser::Util.escape_const_ref_ptr(typename) escaped_typename.split(%r{[<,>]}).map{ |s| Doxyparser::Util.escape_const_ref_ptr(s) }.reject { |s| s.nil? || !valid_type?(s) } end |
.template?(typename) ⇒ Boolean
Returns true if the given type name has type parameters, false otherwise.
52 53 54 |
# File 'lib/nodes/type.rb', line 52 def self.template?(typename) typename.include? '<' end |
Instance Method Details
#name=(new_name) ⇒ Object
Setter for the name of this Doxyparser::Type. Use at your own risk!
57 58 59 60 61 |
# File 'lib/nodes/type.rb', line 57 def name=(new_name) @name = new_name @escaped_name = escape_const_ref_ptr(@name) @basename = del_prefix_class(escape_template(@escaped_name)) end |
#nested_local_types ⇒ Array<Type>
If this Doxyparser::Type has type parameters (aka. template params) finds nested Doxyparser::Types
for other {Class}es or {Struct}s parsed by Doxyparser.
The 'main' type is always included, so for templates two or more types will be returned.
Example: for MyNamespace::map<std::string, MyClass> the result is: [MyNamespace::map, MyNamespace::MyClass]
15 16 17 18 19 20 |
# File 'lib/nodes/type.rb', line 15 def nested_local_types return [] if @node.nil? refs = @node.xpath("ref") return [] if refs.nil? || refs.empty? refs.map { |r| Type.new(node: r, dir: @dir) } end |
#nested_typenames ⇒ Array<String>
If this Doxyparser::Type has type parameters (aka. template params), returns the names for types nested in this type’s name
The 'main' type is always included, so for templates two or more names will be returned.
Example: for MyNamespace::map<std::string, MyClass, 4> the result is: [MyNamespace::map, std::string, MyClass]
27 28 29 |
# File 'lib/nodes/type.rb', line 27 def nested_typenames Type.nested_typenames(@escaped_name) end |