-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add a PARSING.md doc in the user doc - Add links to it all over the doc - Fix a few doc issues - Fix #1572
- Loading branch information
Showing
7 changed files
with
179 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Parsing options | ||
|
||
When setting options from the [CLI Options](OPTIONS.md), the [commands](COMMANDS.md) or using the [libf3d options string API](../libf3d/OPTIONS.md#string-api), the values are parsed according to their type. If parsing fails, the value is not changed. | ||
|
||
The following types are supported: | ||
- bool: A boolean, true or false. | ||
- int: A signed integer. | ||
- double: A floating point number. | ||
- ratio: A double dividend over a double divisor, stored in a double. | ||
- string: A string of characters. | ||
|
||
As well as a list for each of these types, noted as | ||
- vector\<type\> | ||
|
||
## Bool | ||
|
||
The following formats are supported when parsing a bool, case insensitive: | ||
- true/false | ||
- yes/no | ||
- on/off | ||
- 1/0 | ||
|
||
When formatting a bool into a string, true/false is used. | ||
|
||
## Int | ||
|
||
Int parsing is supported using [std::stoi](https://en.cppreference.com/w/cpp/string/basic_string/stol) and check | ||
that the whole string is parsed. | ||
|
||
When formatting an int into a string, [std::to_string](https://en.cppreference.com/w/cpp/string/basic_string/to_string) is used. | ||
|
||
## Double | ||
|
||
Double parsing is supported using [std::stod](https://en.cppreference.com/w/cpp/string/basic_string/stol) and check | ||
that the whole string is parsed. | ||
|
||
When formatting a double into a string, [std::ostringstream](https://en.cppreference.com/w/cpp/io/basic_ostringstream) is used | ||
with removing the point and precision when the value is exactly an integer. | ||
|
||
## Ratio | ||
|
||
The following formats are supported when parsing a string into a ratio: | ||
- percent% where percent is a double | ||
- dividend/divisor where both are doubles | ||
- double | ||
|
||
Percent, dividend, divisor are then parsed as double. | ||
|
||
When formatting a ratio into a string, it is formatted as a double. | ||
|
||
## String | ||
|
||
String are parsed and formatted as is. | ||
|
||
## Vectors | ||
|
||
Vector tokens are separated by `,`, tokens are then parsed using their respective types. | ||
|
||
When formatting a vector into a string, individual token are formatted according to their type and separated using `,`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters