Class CmdLineUtil
Util class for simple file checks, listings and error handling.
Note: Do not use this class, internal use only!public static class CmdLineUtil
- Inheritance
-
CmdLineUtil
- Inherited Members
Fields
IoBufferSize
public const int IoBufferSize = 1048576
Field Value
Methods
CheckInputFile(string, FileInfo)
Check that the given input file is valid.
To pass the test it must:
- exist
- not be a directory
- accessibly
public static void CheckInputFile(string name, FileInfo inFile)
Parameters
namestringthe name which is used to refer to the file in an error message, it should start with a capital letter.
inFileFileInfothe particular file to check to qualify an input file
Exceptions
- TerminateToolException
if the test does not pass this exception is thrown and an error message is printed to the console.
CheckLanguageCode(string)
public static void CheckLanguageCode(string code)
Parameters
codestring
CheckOutputFile(string, FileInfo)
Tries to ensure that it is possible to write to an output file.
The method does nothing if it is possible to write, otherwise it prints an appropriate error message and a TerminateToolException is thrown.
Computing the contents of an output file (e.g. ME model) can be very time consuming. Prior to this computation it should be checked once that writing this output file is possible to be able to fail fast if not.
public static void CheckOutputFile(string name, FileInfo outFile)
Parameters
ContainsParam(string, string[])
public static bool ContainsParam(string param, string[] args)
Parameters
Returns
CreateInputStreamFactory(FileInfo)
public static IInputStreamFactory CreateInputStreamFactory(FileInfo file)
Parameters
fileFileInfo
Returns
CreateObjectStreamError(IOException)
public static TerminateToolException CreateObjectStreamError(IOException e)
Parameters
Returns
GetDoubleParameter(string, string[])
Retrieves the specified parameter from the specified arguments.
public static double? GetDoubleParameter(string param, string[] args)
Parameters
Returns
GetIntParameter(string, string[])
Retrieves the specified parameter from the specified arguments.
public static int? GetIntParameter(string param, string[] args)
Parameters
Returns
- int?
GetParameter(string, string[])
Retrieves the specified parameter from the given arguments.
public static string? GetParameter(string param, string[] args)
Parameters
Returns
GetParameterIndex(string, string[])
Returns the index of the parameter in the arguments, or -1 if the parameter is not found.
public static int GetParameterIndex(string param, string[] args)
Parameters
Returns
HandleCreateObjectStreamError(IOException)
public static void HandleCreateObjectStreamError(IOException e)
Parameters
HandleStdinIoError(IOException)
public static void HandleStdinIoError(IOException e)
Parameters
LoadTrainingParameters(string?, bool)
Loads the training parameters from paramFile, which is
optional: passing null is allowed and yields null.
public static TrainingParameters? LoadTrainingParameters(string? paramFile, bool supportSequenceTraining)
Parameters
Returns
OpenInFile(FileInfo)
public static Stream OpenInFile(FileInfo file)
Parameters
fileFileInfo
Returns
WriteModel(string, FileInfo, BaseModel)
Writes a BaseModel to disk. Occurring errors are printed to the console to inform the user.
public static void WriteModel(string modelName, FileInfo modelFile, BaseModel model)