Represents a <Class> node.
- constants
- constructors
- destructor
- methods
- namespaces
- pure_virtual?
- superclass
- superclasses
- variables
Find all constants under this class. See Node#namespaces
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 64
64: def constants(name = nil, &block)
65: NodeCache.find_children_of_type(self, "Variable", name)
66: end
Find all the constructors for this class.
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 16
16: def constructors
17: NodeCache.find_children_of_type(self, "Constructor")
18: end
Find the destructor for this class. To tell if a destructor is gcc-generated or not, check the ‘artificial’ attribute:
class_node.destructor.artificial?
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 26
26: def destructor
27: NodeCache.find_children_of_type(self, "Destructor")[0]
28: end
Find all methods for this class. See Node#namespaces
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 54
54: def methods(name = nil)
55: NodeCache.find_children_of_type(self, "Method", name)
56: end
Disabled: Classes cannot have nested namespaces
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 6 6: def namespaces(name = nil) 7: raise NotQueryableException.new("Cannot query for Namespaces while in a Class") 8: end
Is this class pure virtual?
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 11
11: def pure_virtual?
12: attributes["abstract"] ? attributes["abstract"] == "1" : false
13: end
Find the superclass for this class. By default, this will find the superclass of any access type, pass in the type of access you‘re looking for if you want specific types (e.g. public, private, protected).
If there is more than one superclass to this class, this method will only return the first superclass. # If you know or expect there to be multiple superclasses, use superclasses instead
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 38
38: def superclass(access_type = nil)
39: found = superclasses(access_type)
40: found.empty? ? nil : found[0]
41: end
Like superclass above, this will find all superclasses for this class. Functions the same as superclass except this method always returns a QueryResult
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 45
45: def superclasses(access_type = nil)
46: [
47: NodeCache.find_children_of_type(self, "Base").select do |base|
48: access_type.nil? ? true : base.send("#{access_type}?")
49: end
50: ].flatten.map {|base| base.cpp_type }
51: end
Find all instance variables for this class. See Node#namespaces
[ show source ]
# File lib/rbgccxml/nodes/class.rb, line 59
59: def variables(name = nil, &block)
60: NodeCache.find_children_of_type(self, "Field", name)
61: end