MeshLib C++ Docs
Loading...
Searching...
No Matches
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{
10
11
17[[nodiscard]] MRMESH_API size_t findSubstringCaseInsensitive( const std::string& string, const std::string& substring );
18
24[[nodiscard]] MRMESH_API int calcDamerauLevenshteinDistance( const std::string& stringA, const std::string& stringB,
25 bool caseSensitive = true, int* outLeftRightAddition = nullptr );
26
32[[nodiscard]] MRMESH_API std::vector<std::string> split( const std::string& string, const std::string& delimiter );
33
36template <typename F>
37bool split( std::string_view str, std::string_view sep, F&& func )
38{
39 std::size_t index = 0;
40
41 while ( true )
42 {
43 std::size_t newIndex = str.find( sep, index );
44 if ( func( str.substr( index, newIndex - index ) ) )
45 return true;
46 if ( newIndex == std::string_view::npos )
47 break;
48 index = newIndex + sep.size();
49 }
50 return false;
51}
52
54[[nodiscard]] MRMESH_API std::string replace( std::string target, std::string_view from, std::string_view to );
55
57MRMESH_API void replaceInplace( std::string& target, std::string_view from, std::string_view to );
58
60[[nodiscard]] MRMESH_API std::string_view trim( std::string_view str );
61
63[[nodiscard]] MRMESH_API std::string_view trimLeft( std::string_view str );
64
66[[nodiscard]] MRMESH_API std::string_view trimRight( std::string_view str );
67
68
70[[nodiscard]] MRMESH_API bool hasFormatPlaceholders( std::string_view str );
71
72}
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)
MRMESH_API std::string replace(std::string target, std::string_view from, std::string_view to)
Returns.
MRMESH_API bool hasFormatPlaceholders(std::string_view str)
Returns true if str has at least one {...} formatting placeholder.
MRMESH_API std::string_view trimLeft(std::string_view str)
Removes all whitespace character (detected by std::isspace) at the beginning of string view.
MRMESH_API std::string_view trim(std::string_view str)
Removes all whitespace character (detected by std::isspace) at the beginning and the end of string vi...
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.
only for bindings generation
Definition MRCameraOrientationPlugin.h:8