1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#ifndef ARES_CRT_H_
#define ARES_CRT_H_
class AresCRT {
public:
// these two are saner mechanisms for string copying
// copy up to Count chars using strncpy
// force (Count - 1)th char to \0
// which means you pass the full length of the char[]/wchar_t[] as Count and it will not overflow
// it doesn't mean you can copy strings without thinking
static void strCopy(char *Dest, const char *Source, size_t Count);
static void wstrCopy(wchar_t *Dest, const wchar_t *Source, size_t Count);
template<size_t Size>
static void strCopy(char (&Dest)[Size], const char *Source) {
strCopy(Dest, Source, Size);
}
template<size_t Size>
static void wstrCopy(wchar_t (&Dest)[Size], const wchar_t *Source) {
wstrCopy(Dest, Source, Size);
}
};
#endif
|