TestStructure

auto hasAttribute = items.where.any.attributes.name.equal!"test".exists;

version(unittest)
struct TestStructure

Examples

Filter callables by type name

1 import introspection.aggregate;
2 
3 enum item = describeAggregate!TestStructure;
4 enum items = [ item ];
5 
6 items.where.type.name.equal!"TestStructure".and.exists.should.equal(true);
7 items.where.type.fullyQualifiedName.equal!"selectors.where.TestStructure".and.exists.should.equal(true);
8 items.where.type.fullyQualifiedName.equal!"selectors.where.OtherStructure".and.exists.should.equal(false);
9 
10 items.where.type.name.isAnyOf!"TestStructure".and.exists.should.equal(true);
11 items.where.type.fullyQualifiedName.isAnyOf!"selectors.where.TestStructure".and.exists.should.equal(true);
12 items.where.type.fullyQualifiedName.isAnyOf!"selectors.where.OtherStructure".and.exists.should.equal(false);
13 
14 items.where.type.name.not.equal!"TestStructure".and.exists.should.equal(false);
15 items.where.type.fullyQualifiedName.not.equal!"selectors.where.TestStructure".and.exists.should.equal(false);
16 items.where.type.fullyQualifiedName.not.equal!"selectors.where.OtherStructure".and.exists.should.equal(true);
17 
18 items.where.type.name.not.isAnyOf!"TestStructure".and.exists.should.equal(false);
19 items.where.type.fullyQualifiedName.not.isAnyOf!"selectors.where.TestStructure".and.exists.should.equal(false);
20 items.where.type.fullyQualifiedName.not.isAnyOf!"selectors.where.OtherStructure".and.exists.should.equal(true);

Can iterate over filtered values

1 import introspection.callable;
2 
3 @("test")
4 void foo() { }
5 
6 enum item = describeCallable!foo;
7 enum items = [ item ];
8 
9 /// iterate without index
10 size_t index;
11 foreach(element; items.where.any.attributes.name.equal!`"test"`) {
12   index.should.equal(0);
13   element.name.should.equal("foo");
14   index++;
15 }
16 
17 index = 0;
18 foreach(_; items.where.any.attributes.name.equal!`"other"`) {
19   index++;
20 }
21 index.should.equal(0);
22 
23 /// iterate with index
24 foreach(i, element; items.where.any.attributes.name.equal!`"test"`) {
25   i.should.equal(0);
26   element.name.should.equal("foo");
27 }

Meta