summaryrefslogtreecommitdiff
path: root/ace/OS_NS_string_base.h
blob: 76360ca7719dd1e9aa45469037c6e3e09c73bff6 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* -*- C++ -*- */
// $Id$
#ifndef OS_NS_STRING_BASE_H
#define OS_NS_STRING_BASE_H

#include "ace/config-lite.h"

#include <string.h>
// Standard library includes for wide functions declared in ace_wchar.h
// Do not include any ACE header files because this file is included from
// ace_wchar.h which is included at the config.h level.

namespace ACE_OS
{

/// Finds the length of a string (emulated version).
template <typename CHAR> inline
size_t strlen (const CHAR* s);

/// Finds the length of a string (char version).
template <> inline
size_t strlen (const char* s);

/// Finds the length of a string (wchar_t version).
#if !defined (ACE_LACKS_WCSLEN)
template <> inline
size_t strlen (const wchar_t* s);
#endif /* !ACE_LACKS_WCSLEN */

/// Copies an array (emulated version)
/// This method intentionally specifies
/// a uniform type for source and destination
/// Use ACE_OS::string_copy if the types may
/// not be uniform.
template <typename CHAR> inline
CHAR* strncpy (CHAR* dest, const CHAR* src, size_t len);

/// Copies an array (char version)
template <> inline
char* strncpy (char* dest, const char* src, size_t len);

/// Copies an array (wchar_t version)
#if !defined (ACE_LACKS_WCSNCPY)
template <> inline
wchar_t* strncpy (wchar_t* dest, const wchar_t* src, size_t len);
#endif /* !ACE_LACKS_WCSNCPY */

/// Compares two strings (emulated version).
/// This method intentionally specifies
/// a uniform type for source and destination.
/// The user has to specify the conversion is they differ.
template < typename CHAR > inline
int strcmp (const CHAR *lhs, const CHAR *rhs);

/// Compares two strings (char version).
template <> inline
int strcmp (const char *lhs, const char *rhs);

  /// Compares two strings (wchar_t version).
#if !defined (ACE_LACKS_WCSCMP)
template <> inline
int strcmp (const wchar_t *lhs, const wchar_t *rhs);
#endif /* !ACE_LACKS_WCSCMP */

#if !defined (ACE_LACKS_DEPRECATED_MACROS)
// Emulation
#if defined (ACE_LACKS_WCSLEN)
  /// Emulated wcslen - Returns the length of a string.
  size_t
  wcslen_emulation (const wchar_t* string)
    { return ACE_OS::strlen( string ); }
#endif /* ACE_LACKS_WCSLEN */

#if defined (ACE_LACKS_WCSNCPY)
  /// Emulated wcsncpy - Copies an array.
  wchar_t *
  wcsncpy_emulation (wchar_t *destination,
                     const wchar_t *source,
                     size_t len)
    { return ACE_OS::strncpy( destination, source, len ); }
#endif /* ACE_LACKS_WCSNCPY */

#endif

}

#include "ace/OS_NS_string_base.inl"

#endif