Stateless multi-delimiter tokenizer for SWMM input lines.
More...
#include <Tokenizer.hpp>
|
| static std::string_view | strip_comment (std::string_view line) noexcept |
| | Strip trailing semicolon comment from a line.
|
| |
| static std::vector< std::string > | tokenize (std::string_view line) |
| | Split a SWMM input line into tokens.
|
| |
| static std::vector< std::string_view > | tokenize_views (std::string_view line) |
| | Split a line and return string_view tokens (zero-allocation).
|
| |
| static void | to_upper_inplace (std::string &s) noexcept |
| | Convert a string to uppercase in-place.
|
| |
| static std::string | to_upper (std::string_view s) |
| | Convert a string to uppercase (returns new string).
|
| |
| static std::string_view | trim (std::string_view s) noexcept |
| | Trim leading and trailing whitespace from a string_view.
|
| |
| static bool | is_numeric (std::string_view sv) noexcept |
| | Returns true if sv represents a numeric value.
|
| |
| static bool | is_boolean (std::string_view sv) noexcept |
| | Returns true if sv represents a boolean YES/NO/TRUE/FALSE/1/0.
|
| |
| static bool | parse_boolean (std::string_view sv) noexcept |
| | Parse a boolean token.
|
| |
Stateless multi-delimiter tokenizer for SWMM input lines.
All methods are static and stateless. Instantiation is not needed.
◆ Tokenizer()
| openswmm::input::Tokenizer::Tokenizer |
( |
| ) |
|
|
delete |
◆ is_boolean()
| bool openswmm::input::Tokenizer::is_boolean |
( |
std::string_view |
sv | ) |
|
|
staticnoexcept |
Returns true if sv represents a boolean YES/NO/TRUE/FALSE/1/0.
◆ is_numeric()
| bool openswmm::input::Tokenizer::is_numeric |
( |
std::string_view |
sv | ) |
|
|
staticnoexcept |
Returns true if sv represents a numeric value.
Accepts integer and floating-point formats including: "3.14", "-1.5e-3", "42", "+0.5"
◆ parse_boolean()
| bool openswmm::input::Tokenizer::parse_boolean |
( |
std::string_view |
sv | ) |
|
|
staticnoexcept |
Parse a boolean token.
- Parameters
-
| sv | Token (YES/NO/TRUE/FALSE/1/0, case-insensitive). |
- Returns
- true for YES/TRUE/1, false otherwise.
◆ strip_comment()
| std::string_view openswmm::input::Tokenizer::strip_comment |
( |
std::string_view |
line | ) |
|
|
staticnoexcept |
Strip trailing semicolon comment from a line.
Removes everything from the first unquoted semicolon (;) to the end of the line. Works correctly when semicolons appear inside quoted strings.
- Parameters
-
| line | Input line (may contain comment). |
- Returns
- Line with comment stripped (may be empty or whitespace-only).
- Note
- Returns a view into
line; the returned view is valid only as long as line is alive.
◆ to_upper()
| std::string openswmm::input::Tokenizer::to_upper |
( |
std::string_view |
s | ) |
|
|
static |
Convert a string to uppercase (returns new string).
◆ to_upper_inplace()
| void openswmm::input::Tokenizer::to_upper_inplace |
( |
std::string & |
s | ) |
|
|
staticnoexcept |
Convert a string to uppercase in-place.
- Parameters
-
◆ tokenize()
| std::vector< std::string > openswmm::input::Tokenizer::tokenize |
( |
std::string_view |
line | ) |
|
|
static |
Split a SWMM input line into tokens.
Delimiters: comma (,), horizontal tab (\t), one-or-more ASCII spaces. Consecutive delimiters of the same type produce no empty tokens (e.g., "A B" → ["A", "B"], not ["A", "", "B"]).
Quoted strings (double-quoted "...") are treated as single tokens with the quotes stripped. Internal whitespace in quoted strings is preserved.
Comments are stripped before tokenizing (see strip_comment()).
- Parameters
-
| line | Input line (comment will be stripped internally). |
- Returns
- Vector of token strings (empty if line is blank/comment).
- Note
- Returns strings by value. Use tokenize_views() for zero-allocation views if performance is critical.
◆ tokenize_views()
| std::vector< std::string_view > openswmm::input::Tokenizer::tokenize_views |
( |
std::string_view |
line | ) |
|
|
static |
Split a line and return string_view tokens (zero-allocation).
Like tokenize(), but returns views into line. The views are only valid as long as line is alive.
- Warning
- NOT suitable for lines with quoted tokens (views can't escape quotes). Fall back to tokenize() if quoted tokens are expected.
- Parameters
-
| line | Input line. |
| stripped | [out] If provided, receives the comment-stripped line. |
- Returns
- Vector of string_view tokens.
◆ trim()
| std::string_view openswmm::input::Tokenizer::trim |
( |
std::string_view |
s | ) |
|
|
staticnoexcept |
Trim leading and trailing whitespace from a string_view.
The documentation for this class was generated from the following files:
- /home/runner/work/openswmm.engine/openswmm.engine/src/engine/input/Tokenizer.hpp
- /home/runner/work/openswmm.engine/openswmm.engine/src/engine/input/Tokenizer.cpp