Report a bug
		
				If you spot a problem with this page, click here to create a GitHub issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	mir.reflection
Base reflection utilities.
License: 
Authors: 
Ilia Ki
- enumreflectSerde;
- Attribute to force member serialization for static fields, compiletime enum members and non-property methods.
- enum boolisStdNullable(T);
- Match types like std.typeconst: Nullable.Examples:import std.typecons; static assert(isStdNullable!(Nullable!double)); Examples:import mir.algebraic; static assert(isStdNullable!(Nullable!double)); 
- structreflectDeprecated(string target);
- Attribute for deprecated API- stringmsg;
- uintissueNumber;
- Number in an issue tracker. Not mandatory.
- stringremovalTime;
- Should be kind of version number if one can be given. Can be something else if that's not possible. Not mandatory.
 
- templateReflectName(string target)
 autoreflectName(string target = null, Args...)(stringname);
- Attribute to rename methods, types and functionsExamples:enum E { A, B, C } struct S { @reflectName("A") int a; @reflectName!"c++"("B") int b; @reflectName!("C", double)("cd") @reflectName!("C", float)("cf") F c(F)() { return b; } } import std.traits: hasUDA; alias UniName = ReflectName!null; alias CppName = ReflectName!"c++"; alias CName = ReflectName!"C"; static assert(hasUDA!(S.a, UniName!()("A"))); static assert(hasUDA!(S.b, CppName!()("B"))); // static assert(hasUDA!(S.c, ReflectName)); // doesn't work for now static assert(hasUDA!(S.c, CName)); static assert(hasUDA!(S.c, CName!double)); static assert(hasUDA!(S.c, CName!float)); static assert(hasUDA!(S.c, CName!double("cd"))); static assert(hasUDA!(S.c, CName!float("cf"))); - structReflectName(Args...);
- 
- stringname;
 
 
- templateReflectMeta(string target, string[] fields)
 templatereflectMeta(string target, string[] fields)
- Attribute to rename methods, types and functionsExamples:enum E { A, B, C } struct S { int a; @reflectMeta!("c++", ["type"])(E.C) int b; } import std.traits: hasUDA; alias CppMeta = ReflectMeta!("c++", ["type"]); static assert(CppMeta!E(E.C).type == E.C); static assert(!hasUDA!(S.a, CppMeta!E(E.A))); static assert(hasUDA!(S.b, CppMeta!E(E.C))); - structReflectMeta(Args...);
- 
- Argsargs;
 
 
- templatereflectIgnore(string target)
- Attribute to ignore a reflection targetExamples:struct S { @reflectIgnore!"c++" int a; } import std.traits: hasUDA; static assert(hasUDA!(S.a, reflectIgnore!"c++")); 
- structReflectDoc(string target);
- Attribute for documentation and unittests- stringtext;
- reflectUnittest!targettest;
- pure nothrow @nogc @safe this(stringtext);
- pure nothrow @nogc @safe this(stringtext, reflectUnittest!targettest);
- const scope voidtoString(W)(ref scope Ww);
- const pure nothrow scope @safe stringtoString()();
 
- ReflectDoc!targetreflectDoc(string target = null)(stringtext);
- Attribute for documentation.
- templatereflectGetDocs(string target, alias symbol)
 templatereflectGetDocs(string target)
- Examples:enum E { @reflectDoc("alpha") a, @reflectDoc!"C#"("Beta", reflectUnittest!"C#"("some c# code")) @reflectDoc("beta") b, c, } alias Doc = ReflectDoc!null; alias CSDoc = ReflectDoc!"C#"; static assert(reflectGetDocs!null(E.a) == [Doc("alpha")]); static assert(reflectGetDocs!"C#"(E.b) == [CSDoc("Beta", reflectUnittest!"C#"("some c# code"))]); static assert(reflectGetDocs!null(E.b) == [Doc("beta")]); static assert(reflectGetDocs!null(E.c) is null); struct S { @reflectDoc("alpha") @reflectDoc!"C#"("Alpha") int a; } static assert(reflectGetDocs!(null, S.a) == [Doc("alpha")]); static assert(reflectGetDocs!("C#", S.a) == [CSDoc("Alpha")]); import std.conv: to; static assert(CSDoc("Beta", reflectUnittest!"C#"("some c# code")).to!string == "Beta\nExample usage:\nsome c# code"); 
- structreflectUnittest(string target);
- Attribute for extern unit-test.- stringtext;
 
- templatereflectGetUnittest(string target, alias symbol)
 templatereflectGetUnittest(string target)
- Examples:enum E { @reflectUnittest!"c++"("assert(E::a == 0);") a, @reflectUnittest!"c++"("assert(E::b == 1);") b, c, } static assert(reflectGetUnittest!"c++"(E.a) == "assert(E::a == 0);"); static assert(reflectGetUnittest!"c++"(E.b) == "assert(E::b == 1);"); static assert(reflectGetUnittest!"c++"(E.c) is null); struct S { @reflectUnittest!"c++"("alpha") int a; } static assert(reflectGetUnittest!("c++", S.a) == "alpha"); 
- templategetUDA(alias symbol, alias attribute)
 templategetUDA(T, string member, alias attribute)
- Returns:single UDA.
- enum boolisOriginalMember(T, string member);
- Checks if T has a field member.Examples:struct D { int a; alias b = a; } static assert(isOriginalMember!(D, "a")); static assert(!isOriginalMember!(D, "b")); 
- enum boolhasField(T, string member);
- Checks if T has a field member.
- templateisProperty(T, string member)
- Checks if member is property.Examples:struct D { int y; void gf(double ) @property {} void gf(uint ) @property {} } struct I { int f; D base; alias base this; void gi(double ) @property {} void gi(uint ) @property {} } struct S { int d; I i; alias i this; int gm() @property {return 0;} int gc() const @property {return 0;} void gs(int) @property {} } static assert(isProperty!(S, "gf")); static assert(isProperty!(S, "gi")); static assert(isProperty!(S, "gs")); static assert(isProperty!(S, "gc")); static assert(isProperty!(S, "gm")); static assert(!isProperty!(S, "d")); static assert(!isProperty!(S, "f")); static assert(!isProperty!(S, "y")); 
- templategetSetters(T, string member)
- Returns:list of the setter properties.Note The implementation ignores templates. Examples:struct I { int f; void gi(double ) @property {} void gi(uint ) @property {} } struct S { int d; I i; alias i this; int gm() @property {return 0;} int gc() const @property {return 0;} void gs(int) @property {} } static assert(getSetters!(S, "gi").length == 2); static assert(getSetters!(S, "gs").length == 1); static assert(getSetters!(S, "gc").length == 0); static assert(getSetters!(S, "gm").length == 0); static assert(getSetters!(S, "d").length == 0); static assert(getSetters!(S, "f").length == 0); 
- enum string[]SerializableMembers(T);
- Returns:list of the serializable (public getters) members.Examples:struct D { int y; int gf() @property {return 0;} } struct I { int f; D base; alias base this; int gi() @property {return 0;} } struct S { int d; package int p; enum s = "str"; @reflectSerde enum t = "str"; int gm() @property {return 0;} private int q; I i; alias i this; int gc() const @property {return 0;} void gs(int) @property {} } static assert(SerializableMembers!S == ["y", "gf", "f", "gi", "d", "t", "gm", "gc"]); static assert(SerializableMembers!(const S) == ["y", "f", "d", "t", "gc"]); 
- enum string[]DeserializableMembers(T);
- Returns:list of the deserializable (public setters) members.Examples:struct I { int f; void ga(int) @property {} } struct S { int d; package int p; int gm() @property {return 0;} void gm(int) @property {} private int q; I i; alias i this; void gc(int, int) @property {} void gc(int) @property {} } S s; // s.gc(0); static assert (DeserializableMembers!S == ["f", "ga", "d", "gm", "gc"]); static assert (DeserializableMembers!(const S) == []); 
Copyright © 2016-2023 by Ilya Yaroshenko | Page generated by
Ddoc on Mon Nov  6 15:24:34 2023