stdex
Additional custom or not Standard C++ covered algorithms
Loading...
Searching...
No Matches
include
stdex
string.h
1
/*
2
SPDX-License-Identifier: MIT
3
Copyright © 2016-2022 Amebis
4
*/
5
6
#pragma once
7
8
#include "sal.h"
9
10
namespace
stdex
11
{
19
template
<
class
T>
20
inline
size_t
strlen(_In_z_
const
T* str)
21
{
22
size_t
i;
23
for
(i = 0; str[i]; i++);
24
return
i;
25
}
26
36
template
<
class
T>
37
inline
const
T* strnchr(
38
_In_reads_or_z_(count)
const
T* str,
39
_In_ T chr,
40
_In_
size_t
count)
41
{
42
for
(
size_t
i = 0; i < count && str[i]; i++)
43
if
(str[i] == chr)
return
str + i;
44
return
NULL;
45
}
46
56
template
<
class
T>
57
inline
size_t
crlf2nl(_Out_writes_z_(strlen(src)) T* dst, _In_z_
const
T* src)
58
{
59
size_t
i, j;
60
for
(i = j = 0; src[j];) {
61
if
(src[j] != (T)
'\r'
|| src[j + 1] != (T)
'\n'
)
62
dst[i++] = src[j++];
63
else
{
64
dst[i++] = (T)
'\n'
;
65
j += 2;
66
}
67
}
68
dst[i] = (T)0;
69
return
i;
70
}
71
}
Generated on Wed Mar 8 2023 12:00:41 for stdex by
1.9.6