parsem

버전 1.0.1 (3.95 KB) 작성자: tommsch
Another input parser, very easy to use.
다운로드 수: 20
업데이트 날짜: 2020/12/18

라이선스 보기

Another input parser, very easy to use
Most recent version can probably be found at gitlab: https://gitlab.com/tommsch/m

Features:
- parsing of:
- flags: check which flag of a set of flags is given (see Note (A) )
- name-value pairs: incl. support of alias names, position independent
- key-words: for simple arguments taking only boolean values
- input checks
- set/conditionally-set/read options
- help text generation
- check for unkown options
- passing of unkown options to other parsers
- fully documented
- no splitting of parsing informations between place-of-definition and place-of-parsing

Note:
(A) *** This type of parsing is, to my knowledge, only possible with this parsing function `parsem()` and with `ltfatarghelper()`, the latter part of the LTFAT library, available at github. In particular, Matlabs inputParser also does not support this
(B) Roughly 2x slower than Matlabs inputParser

Example:
varargin = {'abc', 'tommsch',4, 'opt2'};
[ val ] = parsem( 'tommsch', varargin, 2 );
% yields: val=4;

varargin = {'abc', 'tommsch',4, 'opt2'};
[ val ] = parsem( 'tommsch', varargin, 2, 'expect',{0,1,2} );
% yields: val=4;
% and a warning that 'tommsch' only wants values 0, 1 or 2.

varargin = {'abc', 'tommsch',4, 'opt2'};
[val,arg] = parsem( 'Olga', varargin );
% yields: val=false; arg={'abc', 'tommsch',4, 'opt2'},
% Since 'Olga' was not given, val is set to false
% Output argument arg contains all so-far unparsed parts of varargin

varargin = {'abc', 'tommsch',4, 'opt2'};
[val,arg,cc] = parsem( {'opt1','opt2','opt3'}, varargin );
%yields: val=1, cc='opt2', arg={'abc', 'tommsch',4},
% val indicates that one of the options 'op1','opt2','opt3' has been found
% in cc it is stored which option was passed exactly

More options are available.

If you like my parser, please let me know,
Furthermore, please report any bugs you found.

인용 양식

tommsch (2024). parsem (https://www.mathworks.com/matlabcentral/fileexchange/83293-parsem), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.1

Only changed description

1.0.0