voile.misc

便利関数
ref auto assumeAttr(alias fn, alias attrs, Args...)(auto ref Args args)
if(isFunction!fn);
ref auto assumeAttr(alias fn, alias attrs, Args...)(auto ref Args args)
if(__traits(isTemplate, fn) && isCallable!(fn!Args));
auto assumeAttr(alias attrs, Fn)(Fn t)
if(isFunctionPointer!Fn || isDelegate!Fn);
template getFunctionAttributes(T...)
ref auto assumePure(alias fn, Args...)(auto ref Args args);
auto assumePure(T)(T t)
if(isFunctionPointer!T || isDelegate!T);
ref auto assumeNogc(alias fn, Args...)(auto ref Args args);
auto assumeNogc(T)(T t)
if(isFunctionPointer!T || isDelegate!T);
ref auto assumeNothrow(alias fn, Args...)(auto ref Args args);
auto assumeNothrow(T)(T t)
if(isFunctionPointer!T || isDelegate!T);
@property ref auto assumeUnshared(T)(ref T x);
@property ref auto assumeShared(T)(ref T x);
template nogcEnforce(E : Throwable = Exception) if (is(typeof(new E(string.init, string.init, size_t.init)) : Throwable) || is(typeof(new E(string.init, size_t.init)) : Throwable))
@nogc @safe T nogcEnforce(T, Dg, string file = __FILE__, size_t line = __LINE__)(T value, scope Dg dg)
if(isSomeFunction!Dg && is(typeof(dg())) && is(typeof(() { if (!value) { } } )));
template TemplateSpecializedTypeTuple(T)
CommonType!(staticMap!(ReturnType, T)) variantSwitch(T...)(auto ref Variant var, T caseFunctions);
CommonType!(staticMap!(ReturnType, T)) castSwitch(Base, T...)(Base inst, T caseFunctions);
S indent(S)(S s, S indentStr = "\t");
void truncate(ref File f, size_t fileSize = -1);
void addPathAfter(string newpath);
新しいパスを現在のパスの後ろに追加します
void addPathBefore(string newpath);
新しいパスを現在のパスの前に追加します
string fromMBS(in ubyte[] data, uint codePage = 0);
MBS(ZeroNIL)文字列からUTF8に変換
string fromUTF16z(in wchar* data);
UTF16(ZeroNIL)文字列からUTF8に変換
const(char)[] toMBS(in char[] data, uint codePage = 0);
UTF8からMBS(ZeroNIL)文字列に変換
enum MacroType: int;
str
$xxx, ${xxx}
expr
!!!!! UNDEFINED MACRO: "xxx" !!!!!!
T expandMacro(T, Func)(in T str, Func mapFunc)
if(isSomeString!T && isCallable!Func && is(ReturnType!Func : bool) && (ParameterTypeTuple!Func.length >= 1) && is(T : ParameterTypeTuple!Func[0]) && ((ParameterStorageClassTuple!Func[0] & ParameterStorageClass.ref_) == ParameterStorageClass.ref_));
T expandMacro(T, Func)(in T str, Func mapFunc)
if(isSomeString!T && isCallable!Func && is(ReturnType!Func : T) && (ParameterTypeTuple!Func.length >= 1) && is(T : ParameterTypeTuple!Func[0]));
T expandMacro(T, MAP)(in T str, MAP map)
if(isSomeString!T && is(typeof(() { auto p = T.init in map; T tmp = *p; } )));
Expands macro variables contained within a str
T expandVariable(T, MAP)(in T str, MAP map)
if(isSomeString!T && is(typeof(() { auto p = T.init in map; T var = *p; } )));
T expandVariable(T, Func)(in T str, Func mapFunc)
if(isSomeString!T && isCallable!Func && is(ReturnType!Func : T) && (ParameterTypeTuple!Func.length == 1) && is(T : ParameterTypeTuple!Func[0]));
文字列内に含まれる変数を展開します。
aaa%VAR%bbbのVAR変数を展開します。変数が存在しない場合は何もしません。 VARがxxxであれば、aaaxxxbbbとなります。 VARが存在しなければ、aaa%VAR%bbbのままです。
struct RotationSerial(T, T start = T.min + 1, T end = T.max) if (isIntegral!T && isUnsigned!T);
Examples:
// シリアル値。範囲は10~249の間で、ローテーションする
alias SerialNum = RotationSerial!(ubyte, 10, 250);

// シリアル値はインクリメントで値が増加する
auto ser = SerialNum(10);
++ser;
assert(ser > SerialNum(10));
assert(ser == SerialNum(11));

// 値の範囲の終端まで行くとローテーションする
// ローテーションしても、ローテーション前の値よりは大きくなるという判定を行う。
ser = SerialNum(249);
++ser;
assert(ser > SerialNum(249));
assert(ser == SerialNum(10));
enum auto min;
enum auto max;
this(T val);
const bool isUninitialized();
const bool isValid();
const T value();
ref RotationSerial opUnary(string op)()
if(op == "++");
const int opCmp(RotationSerial rhs);
auto combinationMatrix(R)(R matrix)
if(isInputRange!R && isInputRange!(ElementType!R));
auto combinationMatrix(K, R)(R[K] matrixAA)
if(isInputRange!R);
Create combinations matrix from specified lists of conditional patterns
Parameters:
R matrix Matrix of conditional patterns.
ex; Input [["1", "2"], ["A", "B"]]
Results [["1", "A"], ["1", "B"], ["2", "A"], ["2", "B"]]
R[K] matrixAA Matrix of conditional patterns. For each column, the name is represented by an associative array key.
ex; Input ["P1": ["1", "2"], "P2": ["A", "B"]]
Results [["P1": "1", "P2": "A"], ["P1": "1", "P2": "B"], ["P1": "2", "P2": "A"], ["P1": "2", "P2": "B"]]
Returns: Matrix of combination
Examples:
import std.algorithm: equal;
assert(combinationMatrix([["a", "b"], ["A", "B", "C"], ["1", "2"]]).equal([
	["a", "A", "1"],
	["a", "A", "2"],
	["a", "B", "1"],
	["a", "B", "2"],
	["a", "C", "1"],
	["a", "C", "2"],
	["b", "A", "1"],
	["b", "A", "2"],
	["b", "B", "1"],
	["b", "B", "2"],
	["b", "C", "1"],
	["b", "C", "2"],
]));
Examples:
import std.algorithm: equal;
assert(combinationMatrix(["P1": ["a", "b"], "P2": ["A", "B", "C"], "P3": ["1", "2"]]).equal([
	["P1": "a", "P2": "A", "P3": "1"],
	["P1": "a", "P2": "A", "P3": "2"],
	["P1": "a", "P2": "B", "P3": "1"],
	["P1": "a", "P2": "B", "P3": "2"],
	["P1": "a", "P2": "C", "P3": "1"],
	["P1": "a", "P2": "C", "P3": "2"],
	["P1": "b", "P2": "A", "P3": "1"],
	["P1": "b", "P2": "A", "P3": "2"],
	["P1": "b", "P2": "B", "P3": "1"],
	["P1": "b", "P2": "B", "P3": "2"],
	["P1": "b", "P2": "C", "P3": "1"],
	["P1": "b", "P2": "C", "P3": "2"],
]));
auto shuffle(R)(R ary)
if(isRandomAccessRange!R);
Shuffle elements of specified range