От: | SchweinDeBurg | http://zarezky.spb.ru/ | |
Дата: | 02.08.06 04:43 | ||
Оценка: | 3 (1) |
Parse almost any of the standard command line formats in use today with the same code on both Windows and Un*x. Includes full processing of filename wildcards (glob). Fully MBCS and Unicode enabled.
Features
public domain == free to use in all software (including GPL and commercial)
multi-platform (Windows 95/98/ME/NT/2K/XP, Linux, Unix)
supports all types of options:
— switch character only (e.g. use stdin for input)
-o short (single character)
-long long (multiple character, single switch character)
--longer long (multiple character, multiple switch characters)
word special word construed as an option, no switch characters
supports all types of arguments for options:
--option short/long option flag (no argument)
--option ARG short/long option with separate required argument
--option=ARG short/long option with combined required argument
--option[=ARG] short/long option with combined optional argument
-oARG short option with combined required argument
-o[ARG] short option with combined optional argument
supports clumping of multiple short options (no arguments) in a string, e.g. "foo.exe -abcdef file1" <==> "foo.exe -a -b -c -d -e -f file1"
automatic recognition of a single slash as equivalent to a single hyphen on Windows, e.g. "/f FILE" <==> "-f FILE".
file arguments can appear anywhere in the argument list: "foo.exe file1.txt -a ARG file2.txt --flag file3.txt file4.txt"
file arguments will be returned to the application in the same order they were supplied on the command line
short-circuit option matching: "--man" will match "--mandate"
invalid options can be handled while continuing to parse the command line
valid options list can be changed dynamically during command line processing, i.e. accept different options depending on an option supplied earlier in the command line.
implemented with only a single C++ header file
uses no C runtime or OS functions
char, wchar_t and Windows TCHAR in the same program
complete working examples included
compiles cleanly at warning level 4 (Windows/VC.NET 2003), warning level 3 (Windows/VC6) and -Wall (Linux/gcc)