aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/traits.txx
blob: f65ac806fb938dc017d3b93ad51aabb7f50fc8da (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// file      : odb/oracle/traits.txx
// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC
// license   : ODB NCUEL; see accompanying LICENSE file

namespace odb
{
  namespace oracle
  {
    //
    // default_value_traits<char[N], id_blob>
    //

    template <std::size_t N>
    bool default_value_traits<char[N], id_blob>::
    result_callback (void* c, ub4* position, void* b, ub4 s, chunk_position)
    {
      ub4 n (*position + s < N ? s : N - *position);
      std::memcpy (static_cast<char*> (c) + *position, b, n);
      *position += n;
      return true;
    }

    template <std::size_t N>
    bool default_value_traits<char[N], id_blob>::
    param_callback (const void* c,
                    ub4*,
                    const void** b,
                    ub4* s,
                    chunk_position* p,
                    void*,
                    ub4)
    {
      *p = chunk_one;
      *s = static_cast<ub4> (N);
      *b = c;
      return true;
    }

    //
    // default_value_traits<unsigned char[N], id_blob>
    //

    template <std::size_t N>
    bool default_value_traits<unsigned char[N], id_blob>::
    result_callback (void* c, ub4* position, void* b, ub4 s, chunk_position)
    {
      ub4 n (*position + s < N ? s : N - *position);
      std::memcpy (static_cast<unsigned char*> (c) + *position, b, n);
      *position += n;
      return true;
    }

    template <std::size_t N>
    bool default_value_traits<unsigned char[N], id_blob>::
    param_callback (const void* c,
                    ub4*,
                    const void** b,
                    ub4* s,
                    chunk_position* p,
                    void*,
                    ub4)
    {
      *p = chunk_one;
      *s = static_cast<ub4> (N);
      *b = c;
      return true;
    }

#ifdef ODB_CXX11
    //
    // default_value_traits<std::array<char, N>, id_blob>
    //

    template <std::size_t N>
    bool default_value_traits<std::array<char, N>, id_blob>::
    result_callback (void* c, ub4* position, void* b, ub4 s, chunk_position)
    {
      ub4 n (*position + s < N ? s : N - *position);
      std::memcpy (static_cast<char*> (c) + *position, b, n);
      *position += n;
      return true;
    }

    template <std::size_t N>
    bool default_value_traits<std::array<char, N>, id_blob>::
    param_callback (const void* c,
                    ub4*,
                    const void** b,
                    ub4* s,
                    chunk_position* p,
                    void*,
                    ub4)
    {
      *p = chunk_one;
      *s = static_cast<ub4> (N);
      *b = c;
      return true;
    }

    //
    // default_value_traits<std::array<unsigned char, N>, id_blob>
    //

    template <std::size_t N>
    bool default_value_traits<std::array<unsigned char, N>, id_blob>::
    result_callback (void* c, ub4* position, void* b, ub4 s, chunk_position)
    {
      ub4 n (*position + s < N ? s : N - *position);
      std::memcpy (static_cast<unsigned char*> (c) + *position, b, n);
      *position += n;
      return true;
    }

    template <std::size_t N>
    bool default_value_traits<std::array<unsigned char, N>, id_blob>::
    param_callback (const void* c,
                    ub4*,
                    const void** b,
                    ub4* s,
                    chunk_position* p,
                    void*,
                    ub4)
    {
      *p = chunk_one;
      *s = static_cast<ub4> (N);
      *b = c;
      return true;
    }
#endif
  }
}