Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
StringTools.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
11JPH_EXPORT String StringFormat(const char *inFMT, ...);
12
14template<typename T>
15String ConvertToString(const T &inValue)
16{
17 using OStringStream = std::basic_ostringstream<char, std::char_traits<char>, STLAllocator<char>>;
18 OStringStream oss;
19 oss << inValue;
20 return oss.str();
21}
22
25constexpr uint64 HashString(const char *inString)
26{
27 uint64 hash = 14695981039346656037UL;
28 for (const char *c = inString; *c != 0; ++c)
29 {
30 hash ^= *c;
31 hash = hash * 1099511628211UL;
32 }
33 return hash;
34}
35
37JPH_EXPORT void StringReplace(String &ioString, const string_view &inSearch, const string_view &inReplace);
38
40JPH_EXPORT void StringToVector(const string_view &inString, Array<String> &outVector, const string_view &inDelimiter = ",", bool inClearVector = true);
41
43JPH_EXPORT void VectorToString(const Array<String> &inVector, String &outString, const string_view &inDelimiter = ",");
44
46JPH_EXPORT String ToLower(const string_view &inString);
47
49JPH_EXPORT const char *NibbleToBinary(uint32 inNibble);
50
#define JPH_EXPORT
Definition: Core.h:227
std::uint64_t uint64
Definition: Core.h:443
#define JPH_NAMESPACE_END
Definition: Core.h:367
std::uint32_t uint32
Definition: Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
std::basic_string< char, std::char_traits< char >, STLAllocator< char > > String
Definition: STLAllocator.h:82
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
JPH_EXPORT String ToLower(const string_view &inString)
Convert a string to lower case.
Definition: StringTools.cpp:86
String ConvertToString(const T &inValue)
Convert type to string.
Definition: StringTools.h:15
JPH_EXPORT void VectorToString(const Array< String > &inVector, String &outString, const string_view &inDelimiter=",")
Convert an array strings to a delimited string.
Definition: StringTools.cpp:70
JPH_EXPORT void StringToVector(const string_view &inString, Array< String > &outVector, const string_view &inDelimiter=",", bool inClearVector=true)
Convert a delimited string to an array of strings.
Definition: StringTools.cpp:43
JPH_NAMESPACE_BEGIN JPH_EXPORT String StringFormat(const char *inFMT,...)
Definition: StringTools.cpp:15
constexpr uint64 HashString(const char *inString)
Definition: StringTools.h:25
JPH_EXPORT void StringReplace(String &ioString, const string_view &inSearch, const string_view &inReplace)
Replace substring with other string.
Definition: StringTools.cpp:28
JPH_EXPORT const char * NibbleToBinary(uint32 inNibble)
Converts the lower 4 bits of inNibble to a string that represents the number in binary format.
Definition: StringTools.cpp:95
STL allocator that forwards to our allocation functions.
Definition: STLAllocator.h:14