Base Module  VST 3.7
SDK for developing VST plug-in
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Steinberg::CommandLine Namespace Reference

Very simple command-line parser. More...

Classes

class  VariablesMap
 Command-line parsing result. More...
 
class  Description
 The description of one single command-line option. More...
 
class  Descriptions
 List of command-line option descriptions. 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
 

Functions

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

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;
CommandLine::Descriptions desc;
CommandLine::VariablesMap valueMap;
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;
}
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

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

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

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
std::ostream & operator<< ( std::ostream &  os,
const Descriptions &  desc 
)

Make Descriptions stream able.

Empty

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