Base Module VST 3.7
SDK for developing VST plug-in
Steinberg::CommandLine Namespace Reference

Very simple command-line parser. More...

Classes

class  Description
 The description of one single command-line option. More...
 
class  Descriptions
 List of command-line option descriptions. More...
 
class  VariablesMap
 Command-line parsing result. More...
 

Typedefs

using FilesVector = std::vector< std::string >
 type of the list of elements on the command line that are not handled by options parsing More...
 

Functions

bool parse (int ac, char *av[], const Descriptions &desc, VariablesMap &result, FilesVector *files=nullptr)
 Parse the command - line. More...
 
std::ostream & operator<< (std::ostream &os, const Descriptions &desc)
 Make Descriptions stream able. More...
 

Detailed Description

Very simple command-line parser.

Parses the command-line into a CommandLine::VariablesMap.
The command-line parser uses CommandLine::Descriptions to define the available options.

Example:

#include <iostream>
int main (int argc, char* argv[])
{
using namespace std;
desc.addOptions ("myTool")
("help", "produce help message")
("opt1", string(), "option 1")
("opt2", string(), "option 2")
;
CommandLine::parse (argc, argv, desc, valueMap);
if (valueMap.hasError () || valueMap.count ("help"))
{
cout << desc << "\n";
return 1;
}
if (valueMap.count ("opt1"))
{
cout << "Value of option 1 " << valueMap["opt1"] << "\n";
}
if (valueMap.count ("opt2"))
{
cout << "Value of option 2 " << valueMap["opt2"] << "\n";
}
return 0;
}
List of command-line option descriptions.
Definition: fcommandline.h:162
Descriptions & addOptions(const std::string &caption="", std::initializer_list< Description > &&options={})
Sets the command-line tool caption and starts adding Descriptions.
Definition: fcommandline.h:290
Command-line parsing result.
Definition: fcommandline.h:114
bool hasError() const
Returns true when an error has occurred.
Definition: fcommandline.h:121
VariablesMapContainer::size_type count(const VariablesMapContainer::key_type k) const
Returns != 0 if command-line contains option k.
Definition: fcommandline.h:209
Very simple command-line parser.
bool parse(int ac, char *av[], const Descriptions &desc, VariablesMap &result, FilesVector *files=nullptr)
Parse the command - line.
Definition: fcommandline.h:384
Note
This is a "header only" implementation.
If you need the declarations in more than one cpp file, you have to define SMTG_NO_IMPLEMENTATION in all but one file.

Typedef Documentation

◆ FilesVector

using FilesVector = std::vector<std::string>

type of the list of elements on the command line that are not handled by options parsing

Function Documentation

◆ parse()

bool parse ( int  ac,
char *  av[],
const Descriptions desc,
VariablesMap result,
FilesVector files 
)

Parse the command - line.

Parameters
[in]account of command-line parameters
[in]avcommand-line as array of strings
[in]descDescriptions including all allowed options
[out]resultthe parsing result
[out]filesoptional list of elements on the command line that are not handled by options parsing

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const Descriptions desc 
)

Make Descriptions stream able.

Empty

Copyright © Steinberg Media Technologies GmbH. All Rights Reserved. This documentation is under this license.