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 "MRPch/MRBindingMacros.h"
4#include <string>
5#include <typeinfo>
6
7namespace MR
8{
11
12
19[[nodiscard]] MRMESH_API size_t findSubstringCaseInsensitive( const std::string& string, const std::string& substring );
20
27[[nodiscard]] MRMESH_API int calcDamerauLevenshteinDistance( const std::string& stringA, const std::string& stringB,
28 bool caseSensitive = true, int* outLeftRightAddition = nullptr );
29
37[[nodiscard]] MR_BIND_IGNORE MRMESH_API char32_t caseFold( char32_t ch );
38
45[[nodiscard]] MR_BIND_IGNORE MRMESH_API int calcDamerauLevenshteinDistance( const std::u32string& stringA, const std::u32string& stringB,
46 bool caseSensitive = true, int* outLeftRightAddition = nullptr );
47
53[[nodiscard]] MRMESH_API std::vector<std::string> split( const std::string& string, const std::string& delimiter );
54
57template <typename F>
58bool split( std::string_view str, std::string_view sep, F&& func )
59{
60 std::size_t index = 0;
61
62 while ( true )
63 {
64 std::size_t newIndex = str.find( sep, index );
65 if ( func( str.substr( index, newIndex - index ) ) )
66 return true;
67 if ( newIndex == std::string_view::npos )
68 break;
69 index = newIndex + sep.size();
70 }
71 return false;
72}
73
75[[nodiscard]] MRMESH_API std::string replace( std::string target, std::string_view from, std::string_view to );
76
78MRMESH_API void replaceInplace( std::string& target, std::string_view from, std::string_view to );
79
81[[nodiscard]] MRMESH_API std::string_view trim( std::string_view str );
82
84[[nodiscard]] MRMESH_API std::string_view trimLeft( std::string_view str );
85
87[[nodiscard]] MRMESH_API std::string_view trimRight( std::string_view str );
88
89
91[[nodiscard]] MRMESH_API bool hasFormatPlaceholders( std::string_view str );
92
93}
#define MRMESH_API
Definition MRMeshFwd.h:82
MR_BIND_IGNORE char32_t caseFold(char32_t ch)
int calcDamerauLevenshteinDistance(const std::string &stringA, const std::string &stringB, bool caseSensitive=true, int *outLeftRightAddition=nullptr)
std::vector< std::string > split(const std::string &string, const std::string &delimiter)
size_t findSubstringCaseInsensitive(const std::string &string, const std::string &substring)
void replaceInplace(std::string &target, std::string_view from, std::string_view to)
Replaces.
bool hasFormatPlaceholders(std::string_view str)
Returns true if str has at least one {...} formatting placeholder.
std::string_view trimRight(std::string_view str)
Removes all whitespace character (detected by std::isspace) at the end of string view.
std::string replace(std::string target, std::string_view from, std::string_view to)
Returns.
std::string_view trimLeft(std::string_view str)
Removes all whitespace character (detected by std::isspace) at the beginning of string view.
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...
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:13
only for bindings generation
Definition MRCameraOrientationPlugin.h:8