Skip to content

Commit

Permalink
Merge pull request opencv#25237 from YusukeKameda:4.x
Browse files Browse the repository at this point in the history
doc: add note on handling of spaces in CommandLineParser opencv#25237

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
Added note that this class will not work properly if tabs and other whitespace characters are included in the key.
The support of whitespace characters by istringstream, etc. is on hold because the future of this class is not clear compared to implementations in Python and other languages.
  • Loading branch information
YusukeKameda authored Mar 26, 2024
1 parent fc34554 commit 6e9dcb8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/core/include/opencv2/core/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ The sample below demonstrates how to use CommandLineParser:
The keys parameter is a string containing several blocks, each one is enclosed in curly braces and
describes one argument. Each argument contains three parts separated by the `|` symbol:
-# argument names is a space-separated list of option synonyms (to mark argument as positional, prefix it with the `@` symbol)
-# argument names is a list of option synonyms separated by standard space characters ' ' (to mark argument as positional, prefix it with the `@` symbol)
-# default value will be used if the argument was not provided (can be empty)
-# help message (can be empty)
Expand All @@ -796,6 +796,8 @@ For example:
Note that there are no default values for `help` and `timestamp` so we can check their presence using the `has()` method.
Arguments with default values are considered to be always present. Use the `get()` method in these cases to check their
actual value instead.
Note that whitespace characters other than standard spaces are considered part of the string.
Additionally, leading and trailing standard spaces around the help messages are ignored.
String keys like `get<String>("@image1")` return the empty string `""` by default - even with an empty default value.
Use the special `<none>` default value to enforce that the returned string must not be empty. (like in `get<String>("@image2")`)
Expand Down

0 comments on commit 6e9dcb8

Please sign in to comment.