42 std::move(std::begin(src), std::end(src), std::back_inserter(dst));
47 template<
typename TCollectionSrc,
typename TCollectionDest,
typename TPredicate>
49 for(
auto it = src.begin(); it != src.end();) {
60 template<
class CharT,
class Traits = std::
char_traits<CharT>,
class Allocator = std::allocator<CharT>>
61 void replace(std::basic_string<CharT, Traits, Allocator>&
s,
const std::basic_string<CharT, Traits, Allocator>& from,
62 const std::basic_string<CharT, Traits, Allocator>& to) {
63 using T = std::basic_string<CharT, Traits, Allocator>;
64 for(
typename T::size_type
pos = 0; (
pos =
s.find(from,
pos)) != T::npos;
pos += to.size()) {
65 s.replace(
pos, from.size(), to);
70 template<
class CharT,
class Traits = std::
char_traits<CharT>,
class Allocator = std::allocator<CharT>>
71 void replace(std::basic_string<CharT, Traits, Allocator>&
s,
const char* from,
const char* to) {
72 Replace(
s, std::basic_string<CharT, Traits, Allocator>(from), std::basic_string<CharT, Traits, Allocator>(to));
76 template<
class CharT,
class Traits = std::
char_traits<CharT>,
class Allocator = std::allocator<CharT>>
77 void replace(std::basic_string<CharT, Traits, Allocator>&
s,
const std::basic_string<CharT, Traits, Allocator>& from,
const char* to) {
78 Replace(
s, from, std::basic_string<CharT, Traits, Allocator>(to));
82 template<
class CharT,
class Traits = std::
char_traits<CharT>,
class Allocator = std::allocator<CharT>>
83 void replace(std::basic_string<CharT, Traits, Allocator>&
s,
const char* from,
const std::basic_string<CharT, Traits, Allocator>& to) {
84 Replace(
s, std::basic_string<CharT, Traits, Allocator>(from), to);
89 throw std::runtime_error(
"default template of fromStringOrDefault<T> not implemented");
97 return std::stoi(std::string(
s),
nullptr, (
isHexLiteral(
s) ? 16 : 10));
98 }
catch(
const std::exception&) {
105 return std::stoll(std::string(
s),
nullptr, (
isHexLiteral(
s) ? 16 : 10));
106 }
catch(
const std::exception&) {
113 return std::stoul(std::string(
s),
nullptr, (
isHexLiteral(
s) ? 16 : 10));
114 }
catch(
const std::exception&) {
121 return std::stof(std::string(
s));
122 }
catch(
const std::exception&) {
129 return std::stod(std::string(
s));
130 }
catch(
const std::exception&) {
141 template<
typename T,
typename Allocator>
143 const auto nDst = dst.size();
144 const auto nSrc = src.size();
161 dst.append(src.substr(
i));
168 s << prefix << std::setfill(
'0') << std::setw(
sizeof(
T) * 2) << std::hex <<
i;
174 static_assert(std::is_integral<T>::value,
"NumDigits template only allows integral types");
176 int digits = (
n < 0 ? 1 : 0);
203 if constexpr(
sizeof(
T) == 1) {
207 if constexpr(std::is_same_v<T, UInt16> || std::is_same_v<T, Int16>) {
209 }
else if constexpr(std::is_same_v<T, UInt32> || std::is_same_v<T, Int32>) {
211 }
else if constexpr(std::is_same_v<T, UInt64> || std::is_same_v<T, Int64>) {
214#elif CE_COMPILER_MSVC
215 if constexpr(std::is_same_v<T, UInt16> || std::is_same_v<T, Int16>) {
217 }
else if constexpr(std::is_same_v<T, UInt32> || std::is_same_v<T, Int32>) {
219 }
else if constexpr(std::is_same_v<T, UInt64> || std::is_same_v<T, Int64>) {
224 static_assert(
sizeof(
Byte) == 1);
232 for(
size_t k = 0;
k <
sizeof(
T);
k++) {
250 template<Endian E,
typename T>
Basic string that uses framework's memory allocators.
Definition String.hpp:60
Definition Application.hpp:19
int numDigits(T n)
Definition Utility.hpp:173
Byte
Definition DataTypes.hpp:40
bool isHexLiteral(const StringView &s)
Definition Utility.hpp:93
std::shared_ptr< T > SPtr
SPtr is a smart pointer that retains shared ownership of an object through a pointer.
Definition SmartPtr.hpp:37
void mergeString(BasicString< T, Allocator > &dst, const BasicString< T, Allocator > &src, const T &keepDst, const T &ignoreSrc)
Merges the source string 'src' into the destination string 'dst', keeps the destination characters sp...
Definition Utility.hpp:142
BasicStringStream< char > StringStream
Wide string stream used for primarily for constructing narrow strings.
Definition StringStream.hpp:32
unsigned long fromStringOrDefault< unsigned long >(const StringView &s)
Definition Utility.hpp:111
void eraseAllIf(TCollection &collection, TPredicate pred)
Definition Utility.hpp:36
float fromStringOrDefault< float >(const StringView &s)
Definition Utility.hpp:119
SPtr< T > exchangeWithNull(SPtr< T > &ptr)
Definition Utility.hpp:187
T fromStringOrDefault(const StringView &s)
Definition Utility.hpp:88
void moveAll(TCollectionSrc &src, TCollectionDest &dst)
Definition Utility.hpp:41
Endian
A enumeration for possible endinesses.
Definition Utility.hpp:194
void moveAllIf(TCollectionSrc &src, TCollectionDest &dst, TPredicate pred)
Definition Utility.hpp:48
@ Replace
Set the stencil data to the reference value.
double fromStringOrDefault< double >(const StringView &s)
Definition Utility.hpp:127
std::uint8_t UInt8
Definition DataTypes.hpp:17
void toUpper(T &s)
Definition Utility.hpp:136
void eraseAll(TCollection &collection, const TValue &value)
Definition Utility.hpp:31
T byteswap(T u)
Swaps the byte to/from the native byte-order to the target E byte-order.
Definition Utility.hpp:251
String toHexString(const T &i, const String &prefix="0x")
Definition Utility.hpp:166
long long fromStringOrDefault< long long >(const StringView &s)
Definition Utility.hpp:103
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
int fromStringOrDefault< int >(const StringView &s)
Definition Utility.hpp:95
void replace(std::basic_string< CharT, Traits, Allocator > &s, const std::basic_string< CharT, Traits, Allocator > &from, const std::basic_string< CharT, Traits, Allocator > &to)
Definition Utility.hpp:61
T operator()(T u)
Definition Utility.hpp:242
Definition Utility.hpp:201
T operator()(T u)
Definition Utility.hpp:202