summaryrefslogtreecommitdiff
path: root/TAO/tests/Sequence_Unit_Tests/testing_string_traits.hpp
blob: 0c316da6dc3512e507c954ad20371cbe65d17776 (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
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef guard_testing_string_traits_hpp
#define guard_testing_string_traits_hpp
/**
 * @file
 *
 * @brief Specialize the string traits so they can be used in testing.
 *
 * $Id$
 *
 * @author Carlos O'Ryan
 */

#include "testing_exception.hpp"
#include "tao/String_Traits_T.h"
#include "testing_counters.hpp"

template<typename charT>
struct testing_string_traits
  : public TAO::details::string_traits_base<charT>
  , public TAO::details::string_traits_decorator<charT,testing_string_traits<charT> >
{
  static call_counter default_initializer_calls;
  static call_counter duplicate_calls;
  static call_counter release_calls;
  static call_counter not_released_from_const_calls;
  static call_counter not_released_from_managed_calls;

  typedef charT char_type;
  typedef TAO::details::string_traits<charT,false> real_traits;

  static char_type * default_initializer()
  {
    default_initializer_calls();
    return real_traits::default_initializer();
  }

  static char_type * duplicate(char_type const * s)
  {
    duplicate_calls();
    return real_traits::duplicate(s);
  }

  static void release(char_type * s)
  {
    release_calls();
    return real_traits::release(s);
  }

  static void not_released_from_const(
      char_type * & dst, char_type const * src)
  {
    not_released_from_const_calls();
    real_traits::not_released_from_const(dst, src);
  }

  static void not_released_from_managed(
      char_type * & dst, char_type const * src)
  {
    not_released_from_managed_calls();
    real_traits::not_released_from_managed(dst, src);
  }
};

template<typename charT> call_counter
testing_string_traits<charT>::default_initializer_calls;

template<typename charT> call_counter
testing_string_traits<charT>::duplicate_calls;

template<typename charT> call_counter
testing_string_traits<charT>::release_calls;

template<typename charT> call_counter
testing_string_traits<charT>::not_released_from_const_calls;

template<typename charT> call_counter
testing_string_traits<charT>::not_released_from_managed_calls;

TAO_BEGIN_VERSIONED_NAMESPACE_DECL
namespace TAO
{
namespace details
{

template<>
struct string_traits<char,true>
  : public testing_string_traits<char>
{
};

template<>
struct string_traits<CORBA::WChar,true>
  : public testing_string_traits<CORBA::WChar>
{
};

} // namespace details
} // namespace TAO
TAO_END_VERSIONED_NAMESPACE_DECL

#endif // guard_testing_string_traits_hpp