Base Module VST 3.7 SDK for developing VST plug-in

Loading...
Searching...
No Matches
Classes | Typedefs | Functions
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

## 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 "base/source/fcommandline.h"
#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;
}
Steinberg::CommandLine::Descriptions
List of command-line option descriptions.
Definition fcommandline.h:162
Steinberg::CommandLine::Descriptions::addOptions
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
Steinberg::CommandLine::VariablesMap
Command-line parsing result.
Definition fcommandline.h:114
Steinberg::CommandLine::VariablesMap::hasError
bool hasError() const
Returns true when an error has occurred.
Definition fcommandline.h:121
Steinberg::CommandLine::VariablesMap::count
VariablesMapContainer::size_type count(const VariablesMapContainer::key_type k) const
Returns != 0 if command-line contains option k.
Definition fcommandline.h:209
fcommandline.h
Very simple command-line parser.
Steinberg::CommandLine::parse
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] | ac | count of command-line parameters
  [in] | av | command-line as array of strings
  [in] | desc | Descriptions including all allowed options
  [out] | result | the parsing result
  [out] | files | optional 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.