MeshLib
 
Loading...
Searching...
No Matches
MRMesh/MRString.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#include <string>
4#include <typeinfo>
5
6namespace MR
7{
8
14[[nodiscard]] MRMESH_API size_t findSubstringCaseInsensitive( const std::string& string, const std::string& substring );
15
21[[nodiscard]] MRMESH_API int calcDamerauLevenshteinDistance( const std::string& stringA, const std::string& stringB,
22 bool caseSensitive = true, int* outLeftRightAddition = nullptr );
23
29[[nodiscard]] MRMESH_API std::vector<std::string> split( const std::string& string, const std::string& delimiter );
30
31// This version of `split()` passes the segments to a callback, to avoid heap allocations.
32// If the callback returns true, stops immediately and also returns true.
33template <typename F>
34bool split( std::string_view str, std::string_view sep, F&& func )
35{
36 std::size_t index = 0;
37
38 while ( true )
39 {
40 std::size_t newIndex = str.find( sep, index );
41 if ( func( str.substr( index, newIndex - index ) ) )
42 return true;
43 if ( newIndex == std::string_view::npos )
44 break;
45 index = newIndex + sep.size();
46 }
47 return false;
48}
49
51[[nodiscard]] MRMESH_API std::string replace( std::string target, std::string_view from, std::string_view to );
52
54MRMESH_API void replaceInplace( std::string& target, std::string_view from, std::string_view to );
55
57[[nodiscard]] MRMESH_API std::string_view trimRight( std::string_view str );
58
59} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
MRMESH_API size_t findSubstringCaseInsensitive(const std::string &string, const std::string &substring)
MRMESH_API std::vector< std::string > split(const std::string &string, const std::string &delimiter)
MRMESH_API int calcDamerauLevenshteinDistance(const std::string &stringA, const std::string &stringB, bool caseSensitive=true, int *outLeftRightAddition=nullptr)
Definition MRCameraOrientationPlugin.h:8
MRMESH_API std::string replace(std::string target, std::string_view from, std::string_view to)
Returns.
MRMESH_API void replaceInplace(std::string &target, std::string_view from, std::string_view to)
Replaces.
MRMESH_API std::string_view trimRight(std::string_view str)
Removes all whitespace character (detected by std::isspace) at the end of string view.