OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches

Case-insensitive string helpers matching legacy SWMM name semantics. More...

#include <cstddef>
#include <cstdint>
#include <string_view>
Include dependency graph for StringCase.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmm::CiHash
 Transparent case-insensitive hash (FNV-1a over the uppercase fold). More...
 
struct  openswmm::CiEqual
 Transparent case-insensitive equality for unordered containers. More...
 

Namespaces

namespace  openswmm
 

Functions

constexpr char openswmm::ci_upper (char c) noexcept
 ASCII-only uppercase fold; mirrors legacy hash.c UCHAR exactly.
 
bool openswmm::ieq (std::string_view a, std::string_view b) noexcept
 Case-insensitive equality (ASCII fold), matching legacy samestr().
 

Detailed Description

Case-insensitive string helpers matching legacy SWMM name semantics.

The legacy engine's hash table (src/legacy/engine/hash.c) compares and hashes object names case-insensitively via its UCHAR macro, which uppercases ASCII letters only. Every name lookup in the refactored engine that must be legacy-parity therefore folds case with the helpers here — ASCII-only, byte-for-byte the same fold as UCHAR — never with locale-dependent std::toupper.

CiHash/CiEqual are transparent (heterogeneous) functors so an unordered_map<std::string, T, CiHash, CiEqual> can be probed with a std::string_view without allocating a temporary key, while the stored keys keep their original spelling for faithful round-trip output.

See also
Legacy reference: src/legacy/engine/hash.cUCHAR, samestr(), hash()
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n Apache-2.0