poodinis/source/poodinis/imports.d
2022-02-18 00:45:03 +03:00

34 lines
997 B
D

/**
* This module contains instance factory facilities
*
* Authors:
* Mike Bierlee, m.bierlee@lostmoment.com
* Copyright: 2014-2022 Mike Bierlee
* License:
* This software is licensed under the terms of the MIT license.
* The full terms of the license can be found in the LICENSE file.
*/
module poodinis.imports;
import std.meta : staticIndexOf;
import std.traits : moduleName, TemplateArgsOf, isBuiltinType, isType;
public static string createImportsString(Type, ParentTypeList...)()
{
string imports = `import ` ~ moduleName!Type ~ `;`;
static if (__traits(compiles, TemplateArgsOf!Type))
{
foreach (TemplateArgType; TemplateArgsOf!Type)
{
static if (isType!TemplateArgType &&
(!isBuiltinType!TemplateArgType && staticIndexOf!(TemplateArgType, ParentTypeList) == -1))
{
imports ~= createImportsString!(TemplateArgType, ParentTypeList, Type);
}
}
}
return imports;
}