OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm::input::Tokenizer Class Reference

Stateless multi-delimiter tokenizer for SWMM input lines. More...

#include <Tokenizer.hpp>

Collaboration diagram for openswmm::input::Tokenizer:

Public Member Functions

 Tokenizer ()=delete
 

Static Public Member Functions

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.
 

Detailed Description

Stateless multi-delimiter tokenizer for SWMM input lines.

All methods are static and stateless. Instantiation is not needed.

Constructor & Destructor Documentation

◆ Tokenizer()

openswmm::input::Tokenizer::Tokenizer ( )
delete

Member Function Documentation

◆ 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"

Here is the call graph for this function:

◆ parse_boolean()

bool openswmm::input::Tokenizer::parse_boolean ( std::string_view  sv)
staticnoexcept

Parse a boolean token.

Parameters
svToken (YES/NO/TRUE/FALSE/1/0, case-insensitive).
Returns
true for YES/TRUE/1, false otherwise.
Here is the caller graph for this function:

◆ 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
lineInput 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.
Here is the caller graph for this function:

◆ to_upper()

std::string openswmm::input::Tokenizer::to_upper ( std::string_view  s)
static

Convert a string to uppercase (returns new string).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_upper_inplace()

void openswmm::input::Tokenizer::to_upper_inplace ( std::string &  s)
staticnoexcept

Convert a string to uppercase in-place.

Parameters
sString to uppercase.
Here is the caller graph for this function:

◆ 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
lineInput 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
lineInput line.
stripped[out] If provided, receives the comment-stripped line.
Returns
Vector of string_view tokens.
Here is the call graph for this function:

◆ trim()

std::string_view openswmm::input::Tokenizer::trim ( std::string_view  s)
staticnoexcept

Trim leading and trailing whitespace from a string_view.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: