16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

Merge commit 'd8170c932b448ba6888e702746b5ae22632062d8' into sim

This commit is contained in:
milek7
2022-01-05 01:02:56 +01:00
76 changed files with 9277 additions and 5749 deletions

View File

@@ -488,12 +488,33 @@ len_common_prefix( std::string const &Left, std::string const &Right ) {
// returns true if provided string ends with another provided string
bool
ends_with( std::string const &String, std::string const &Suffix ) {
ends_with( std::string_view String, std::string_view Suffix ) {
return ( String.size() >= Suffix.size() )
&& ( 0 == String.compare( String.size() - Suffix.size(), Suffix.size(), Suffix ) );
}
// returns true if provided string begins with another provided string
bool
starts_with( std::string_view const String, std::string_view Prefix ) {
return ( String.size() >= Prefix.size() )
&& ( 0 == String.compare( 0, Prefix.size(), Prefix ) );
}
// returns true if provided string contains another provided string
bool
contains( std::string_view const String, std::string_view Substring ) {
return ( String.find( Substring ) != std::string::npos );
}
bool
contains( std::string_view const String, char Character ) {
return ( String.find( Character ) != std::string::npos );
}
// helper, restores content of a 3d vector from provided input stream
// TODO: review and clean up the helper routines, there's likely some redundant ones