vibe_exec.dhover×93all
#!/usr/bin/env dub
/+ dub.sdl:
    name "vibe_exec"
    dependency "vibe-core" version="2.14.0"
    buildType "checked" {
        buildOptions "optimize" "inline" "debugInfo"
    }
    platforms "linux"
+/
import 
(package) std
std
.
(module) std.array

Functions and types that manipulate built-in arrays and associative arrays.

This module provides all kinds of functions to create, manipulate or convert arrays:

Function Name Description

| array | Returns a copy of the input in a newly allocated dynamic array. | | appender | Returns a new Appender or RefAppender initialized with a given array. | | assocArray | Returns a newly allocated associative array from a range/ranges of keys and values. | | byPair | Construct a range iterating over an associative array by key/value tuples. | | insertInPlace | Inserts into an existing array at a given position. | | join | Concatenates a range of ranges into one array. | | minimallyInitializedArray | Returns a new array of type T. | | replace | Returns a new array with all occurrences of a certain subrange replaced. | | replaceFirst | Returns a new array with the first occurrence of a certain subrange replaced. | | replaceInPlace | Replaces all occurrences of a certain subrange and puts the result into a given array. | | replaceInto | Replaces all occurrences of a certain subrange and puts the result into an output range. | | replaceLast | Returns a new array with the last occurrence of a certain subrange replaced. | | replaceSlice | Returns a new array with a given slice replaced. | | replicate | Creates a new array out of several copies of an input array or range. | | sameHead | Checks if the initial segments of two arrays refer to the same place in memory. | | sameTail | Checks if the final segments of two arrays refer to the same place in memory. | | split | Eagerly split a range or string into an array. | | staticArray | Creates a new static array from given data. | | uninitializedArray | Returns a new array of type T without initializing its elements. |

Source

std/array.d

@copyrightCopyright Andrei Alexandrescu 2008- and Jonathan M Davis 2011-.@licenseBoost License 1.0.@authorsAndrei Alexandrescu and Jonathan M Davis
array
:
(alias template) vibe_exec.appender = std.array.appender(A)() if (isDynamicArray!A)

Convenience function that returns an Appender instance, optionally initialized with array.

appender
;
import
(package) std
std
.
(module) std.stdio
Category Symbols
File handles _popen File isFileHandle openNetwork stderr stdin stdout
Reading chunks lines readf readfln readln
Writing toFile write writef writefln writeln
Misc KeepTerminator LockType StdioException

Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio is publically imported when importing std.stdio.

There are three layers of I/O:

  1. The lowest layer is the operating system layer. The two main schemes are Windows and Posix.

  2. C's stdio.h which unifies the two operating system schemes.

  3. std.stdio, this module, unifies the various stdio.h implementations into a high level package for D programs.

Source

std/stdio.d

@copyrightCopyright The D Language Foundation 2007-.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Alex Rønne Petersen
stdio
:
(alias template) vibe_exec.writeln = std.stdio.writeln(T...)(T args)

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
;
import
(package) vibe
vibe
.
(package) vibe.core
core
.
(module) vibe.core.core

This module contains the core functionality of the vibe.d framework.

@copyright© 2012-2020 Sönke Ludwig@licenseSubject to the terms of the MIT license, as written in the included LICENSE.txt file.@authorsSönke Ludwig
core
:
(alias template) vibe_exec.runTask = vibe.core.core.runTask(ARGS...)(void delegate(ARGS) nothrow @safe task, auto ref ARGS args)

Runs a new asynchronous task.

task will be called synchronously from within the vibeRunTask call. It will continue to run until vibeYield() or any of the I/O or wait functions is called.

Note that the maximum size of all args must not exceed maxTaskParameterSize.

runTask
;
import
(package) vibe
vibe
.
(package) vibe.core
core
.
(module) vibe.core.process

Functions and structures for dealing with subprocesses and pipes.

This module is modeled after std.process, but provides a fiber-aware alternative to it. All blocking operations will yield the calling fiber instead of blocking it.

process
:
(alias) vibe_exec.pipeProcess = vibe.core.process.ProcessPipes vibe.core.process.pipeProcess(scope string[] args, std.process.Redirect redirect = Redirect.all, const(string[string]) env = cast(const(string[string]))null, vibe.core.process.Config config = Config(Flags.none, null, null), scope vibe.core.path.GenericPath!(PosixPathFormat) workDir = GenericPath(null)) @trusted

Equivalent to std.process.pipeProcess``.

@returnsA struct containing the process and created pipes.@seespawnProcess, execute
pipeProcess
,
(enum) std.process.Redirect

Flags that can be passed to pipeProcess and pipeShell to specify which of the child process' standard streams are redirected. Use bitwise OR to combine flags.

Redirect
;
import
(package) vibe
vibe
.
(package) vibe.core
core
.
(module) vibe.core.stream

Generic stream interface used by several stream-like classes.

This module defines the basic (buffered) stream primitives. For concrete stream types, take a look at the vibe.stream`` package. The vibe.stream.operations module contains additional high-level operations on streams, such as reading streams by line or as a whole.

Note that starting with vibe-core 1.0.0, streams can be of either struct or class type. Any APIs that take streams as a parameter should use a template type parameter that is tested using the appropriate trait (e.g. isInputStream) instead of assuming the specific interface type (e.g. InputStream).

@copyright© 2012-2016 Sönke Ludwig@licenseSubject to the terms of the MIT license, as written in the included LICENSE.txt file.@authorsSönke Ludwig
stream
:
(enum) eventcore.driver.IOMode
IOMode
;
void
void D main()
main
()
{ auto
(local variable) vibe.core.process.ProcessPipes pipes
pipes
=
vibe.core.process.ProcessPipes vibe.core.process.pipeProcess(scope string[] args, std.process.Redirect redirect = Redirect.all, const(string[string]) env = cast(const(string[string]))null, vibe.core.process.Config config = Config(Flags.none, null, null), scope vibe.core.path.GenericPath!(PosixPathFormat) workDir = GenericPath(null)) @trusted

Equivalent to std.process.pipeProcess``.

@returnsA struct containing the process and created pipes.@seespawnProcess, execute
pipeProcess
(["sh", "-c", "echo out; echo err >&2; exit 3"],
(enum) std.process.Redirect

Flags that can be passed to pipeProcess and pipeShell to specify which of the child process' standard streams are redirected. Use bitwise OR to combine flags.

Redirect
.
(enum value) std.process.Redirect.all = 7

Redirect all three streams. This is equivalent to Redirect.stdin | Redirect.stdout | Redirect.stderr.

all
);
auto
(local variable) std.array.Appender!string outBuf
outBuf
=
std.array.Appender!string std.array.appender!string() pure nothrow @safe

Convenience function that returns an Appender instance, optionally initialized with array.

appender
!
(alias) object.string = string
string
;
auto
(local variable) std.array.Appender!string errBuf
errBuf
=
std.array.Appender!string std.array.appender!string() pure nothrow @safe

Convenience function that returns an Appender instance, optionally initialized with array.

appender
!
(alias) object.string = string
string
;
// Must drain stdout and stderr concurrently to prevent pipe buffer deadlocks auto
(local variable) vibe.core.task.Task tOut
tOut
=
vibe.core.task.Task vibe.core.core.runTask!()(void delegate() nothrow @safe task) nothrow @safe

Runs a new asynchronous task.

task will be called synchronously from within the vibeRunTask call. It will continue to run until vibeYield() or any of the I/O or wait functions is called.

Note that the maximum size of all args must not exceed maxTaskParameterSize.

runTask
(() nothrow {
try { ubyte[128]
(local variable) ubyte[128] buf
buf
;
while (!
(local variable) vibe.core.process.ProcessPipes pipes
pipes
.
(field) vibe.core.process.PipeInputStream vibe.core.process.ProcessPipes.stdout
stdout
.
bool vibe.core.process.PipeInputStream.empty() @property @safe
empty
) {
const
(local variable) const(ulong) n
n
=
(local variable) vibe.core.process.ProcessPipes pipes
pipes
.
(field) vibe.core.process.PipeInputStream vibe.core.process.ProcessPipes.stdout
stdout
.
ulong vibe.core.process.PipeInputStream.read(scope ubyte[] dst, eventcore.driver.IOMode mode) @safe
read
(
(local variable) ubyte[128] buf
buf
[],
(enum) eventcore.driver.IOMode
IOMode
.
(enum value) eventcore.driver.IOMode.once = 1

Process as much as possible with a single call

once
);
(local variable) std.array.Appender!string outBuf
outBuf
.
void std.array.Appender!string.put!(const(char)[])(const(char)[] items) pure nothrow @safe

Appends an entire range to the managed array. Performs encoding for char elements if A is a differently typed char array.

@paramitems the range of items to append
put
(cast(const(char)[])
(local variable) ubyte[128] buf
buf
[0 ..
(local variable) const(ulong) n
n
]);
} } catch (
(class) object.Exception

The base class of all errors that are safe to catch and handle.

In principle, only thrown objects derived from this class are safe to catch inside a catch block. Thrown objects not derived from Exception represent runtime errors that should not be caught, as certain runtime guarantees may not hold, making it unsafe to continue program execution.

Examples

bool gotCaught;
try
{
    throw new Exception("msg");
}
catch (Exception e)
{
    gotCaught = true;
    assert(e.msg == "msg");
}
assert(gotCaught);
Exception
(local variable) object.Exception error
error
) { assert(false,
(local variable) object.Exception error
error
.
(field) string object.Throwable.msg

A message describing the error.

msg
); }
}); auto
(local variable) vibe.core.task.Task tErr
tErr
=
vibe.core.task.Task vibe.core.core.runTask!()(void delegate() nothrow @safe task) nothrow @safe

Runs a new asynchronous task.

task will be called synchronously from within the vibeRunTask call. It will continue to run until vibeYield() or any of the I/O or wait functions is called.

Note that the maximum size of all args must not exceed maxTaskParameterSize.

runTask
(() nothrow {
try { ubyte[128]
(local variable) ubyte[128] buf
buf
;
while (!
(local variable) vibe.core.process.ProcessPipes pipes
pipes
.
(field) vibe.core.process.PipeInputStream vibe.core.process.ProcessPipes.stderr
stderr
.
bool vibe.core.process.PipeInputStream.empty() @property @safe
empty
) {
const
(local variable) const(ulong) n
n
=
(local variable) vibe.core.process.ProcessPipes pipes
pipes
.
(field) vibe.core.process.PipeInputStream vibe.core.process.ProcessPipes.stderr
stderr
.
ulong vibe.core.process.PipeInputStream.read(scope ubyte[] dst, eventcore.driver.IOMode mode) @safe
read
(
(local variable) ubyte[128] buf
buf
[],
(enum) eventcore.driver.IOMode
IOMode
.
(enum value) eventcore.driver.IOMode.once = 1

Process as much as possible with a single call

once
);
(local variable) std.array.Appender!string errBuf
errBuf
.
void std.array.Appender!string.put!(const(char)[])(const(char)[] items) pure nothrow @safe

Appends an entire range to the managed array. Performs encoding for char elements if A is a differently typed char array.

@paramitems the range of items to append
put
(cast(const(char)[])
(local variable) ubyte[128] buf
buf
[0 ..
(local variable) const(ulong) n
n
]);
} } catch (
(class) object.Exception

The base class of all errors that are safe to catch and handle.

In principle, only thrown objects derived from this class are safe to catch inside a catch block. Thrown objects not derived from Exception represent runtime errors that should not be caught, as certain runtime guarantees may not hold, making it unsafe to continue program execution.

Examples

bool gotCaught;
try
{
    throw new Exception("msg");
}
catch (Exception e)
{
    gotCaught = true;
    assert(e.msg == "msg");
}
assert(gotCaught);
Exception
(local variable) object.Exception error
error
) { assert(false,
(local variable) object.Exception error
error
.
(field) string object.Throwable.msg

A message describing the error.

msg
); }
}); const
(local variable) const(int) status
status
=
(local variable) vibe.core.process.ProcessPipes pipes
pipes
.
(field) vibe.core.process.Process vibe.core.process.ProcessPipes.process
process
.
int vibe.core.process.Process.wait() @safe

Wait for the process to exit, allowing other fibers to continue in the meantime.

@paramtimeout Optionally wait until a timeout is reached.@returnsThe exit code of the process. If a timeout is given and reached, a null value is returned.
wait
();
(local variable) vibe.core.task.Task tOut
tOut
.
void vibe.core.task.Task.join() @trusted
join
();
(local variable) vibe.core.task.Task tErr
tErr
.
void vibe.core.task.Task.join() @trusted
join
();
assert(
(local variable) const(int) status
status
== 3);
assert(
(local variable) std.array.Appender!string outBuf
outBuf
.
string std.array.Appender!string.data() inout pure nothrow @nogc @property @safe

Use opSlice() from now on.

@returnsThe managed array.
data
== "out\n");
assert(
(local variable) std.array.Appender!string errBuf
errBuf
.
string std.array.Appender!string.data() inout pure nothrow @nogc @property @safe

Use opSlice() from now on.

@returnsThe managed array.
data
== "err\n");
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("stdout: ",
(local variable) std.array.Appender!string outBuf
outBuf
.
string std.array.Appender!string.data() inout pure nothrow @nogc @property @safe

Use opSlice() from now on.

@returnsThe managed array.
data
);
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("stderr: ",
(local variable) std.array.Appender!string errBuf
errBuf
.
string std.array.Appender!string.data() inout pure nothrow @nogc @property @safe

Use opSlice() from now on.

@returnsThe managed array.
data
);
void std.stdio.writeln!(string, const(int))(string __param_0, const(int) __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("exit code: ",
(local variable) const(int) status
status
);
}