|
MocoExtendProblem: Interface Between OpenSim and MATLAB for Rapidly Developing Direct Collocation Goals in Moco 1.1.0
add custom Moco goals to existing matlab scripts
|
Utility to parse input arguments. More...
#include <arguments.h>
Classes | |
| struct | CaseInsensitiveComparator |
| Case-insensitive comparator for std::string. More... | |
Public Types | |
| typedef std::map< std::string, const mxArray *, CaseInsensitiveComparator > | OptionMap |
Public Member Functions | |
| InputArguments () | |
| Empty constructor. | |
| InputArguments (int nrhs, const mxArray *prhs[], int mandatory_size=1, int option_size=0,...) | |
| Shorthand constructor for a single argument definition. | |
| virtual | ~InputArguments () |
| void | define (const std::string name, int mandatory_size, int option_size=0,...) |
| Define a new argument format. | |
| void | parse (int nrhs, const mxArray *prhs[], bool ignore_multi_signatures=false) |
| Parse arguments from mexFunction input. | |
| bool | is (const std::string &name) const |
| Return which format is chosen. | |
| const mxArray * | get (size_t index) const |
| Get a parsed mandatory argument. | |
| template<typename T > | |
| T | get (size_t index) const |
| Get a parsed mandatory argument. | |
| template<typename T > | |
| void | get (size_t index, T *value) const |
| const mxArray * | get (const std::string &option_name) const |
| Get a parsed optional argument. | |
| template<typename T > | |
| T | get (const std::string &option_name, const T &default_value) const |
| Get a parsed optional argument. | |
| template<typename T > | |
| void | get (const std::string &option_name, const T &default_value, T *value) const |
| const mxArray * | operator[] (size_t index) const |
| Access raw mxArray* pointer. | |
| const mxArray * | operator[] (const std::string &option_name) const |
| Access raw mxArray* pointer. | |
Private Member Functions | |
| void | fillOptionalDefinition (int option_size, OptionMap *optionals, va_list variable_list) |
| Fill in optional arguments definition. | |
| bool | parseDefinition (size_t nrhs, const mxArray *prhs[], Definition *definition) |
| Try to parse one definition or return false on failure. | |
Private Attributes | |
| std::map< std::string, Definition > | definitions_ |
| Format definitions. | |
| std::string | error_message_ |
| Last error message. | |
Utility to parse input arguments.
Example: parse 2 mandatory and 2 optional arguments.
InputArguments input(nrhs, prhs, 2, 2, "option1", "option2");
myFunction2(input.get<double>(0),
input.get<int>(1),
input.get<string>("option1", "foo"),
input.get<int>("option2", 10));
Example: parse 1 + 2 argument format or 2 + 2 argument format.
InputArguments input;
input.define("format1", 1, 2, "option1", "option2");
input.define("format2", 2, 2, "option1", "option2");
input.parse(nrhs, prhs);
if (input.is("format1"))
myFunction(input.get<int>(0),
input.get<string>("option1", "foo"),
input.get<int>("option2", 10));
else if (input.is("format2"))
myFunction2(input.get<int>(0),
input.get<string>(1),
input.get<string>("option1", "foo"),
input.get<int>("option2", 10));
| typedef std::map<std::string, const mxArray*, CaseInsensitiveComparator> OptionMap |
|
inline |
Empty constructor.
|
inline |
Shorthand constructor for a single argument definition.

|
inlinevirtual |
|
inline |
Define a new argument format.

|
inlineprivate |
Fill in optional arguments definition.

|
inline |
Get a parsed optional argument.
| T get | ( | const std::string & | option_name, |
| const T & | default_value ) const |
Get a parsed optional argument.

| void get | ( | const std::string & | option_name, |
| const T & | default_value, | ||
| T * | value ) const |

|
inline |
Get a parsed mandatory argument.

| T get | ( | size_t | index | ) | const |
Get a parsed mandatory argument.

| void get | ( | size_t | index, |
| T * | value ) const |

|
inline |
Return which format is chosen.
|
inline |
Access raw mxArray* pointer.

|
inline |
Access raw mxArray* pointer.

|
inline |
Parse arguments from mexFunction input.


|
inlineprivate |
Try to parse one definition or return false on failure.


|
private |
Format definitions.
|
private |
Last error message.