acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_str_impl.h
1#pragma once
2
3
4template < prototype_character CHAR_TYPE >
5inline string_base < const CHAR_TYPE * > str::repeat(const CHAR_TYPE * psz, character_count c)
6{
7
8 auto itemLen = string_safe_length(psz);
9
10 auto itemByteCount = itemLen * sizeof(CHAR_TYPE);
11
12 auto len = itemLen * c;
13
14 string str;
15
16 if (len > 0)
17 {
18
19 auto p = str.get_buffer(len);
20
21 while (c > 0)
22 {
23
24 auto psource = psz;
25
26 auto ptarget = p;
27
28 auto copyLength = itemLen;
29
30 while (copyLength > 0)
31 {
32
33 *ptarget++ = *psource++;
34
35 copyLength--;
36
37 }
38
39 p += itemLen;
40
41 c--;
42
43 }
44
45 str.release_buffer(len);
46
47 }
48
49 return str;
50
51}
52
53
54