1 /*****************************************************************************
2 
3         Proxy.hpp
4         Author: Laurent de Soras, 2012
5 
6 --- Legal stuff ---
7 
8 This program is free software. It comes without any warranty, to
9 the extent permitted by applicable law. You can redistribute it
10 and/or modify it under the terms of the Do What The Fuck You Want
11 To Public License, Version 2, as published by Sam Hocevar. See
12 http://sam.zoy.org/wtfpl/COPYING for more details.
13 
14 *Tab=3***********************************************************************/
15 
16 
17 
18 #if ! defined (fmtcl_Proxy_CODEHEADER_INCLUDED)
19 #define	fmtcl_Proxy_CODEHEADER_INCLUDED
20 
21 
22 
23 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
24 
25 #include "fstb/fnc.h"
26 
27 #include <cstddef>
28 #include <cstring>
29 
30 
31 
32 namespace fmtcl
33 {
34 
35 
36 
37 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
38 
39 
40 
41 template <class T>
make_ptr(const uint8_t * ptr)42 typename Proxy::Ptr1 <T>::Type	Proxy::Ptr1 <T>::make_ptr (const uint8_t *ptr)
43 {
44 	return (T *) ptr;
45 }
46 
47 template <class T>
jump(Type & ptr,int stride)48 void	Proxy::Ptr1 <T>::jump (Type &ptr, int stride)
49 {
50 	ptr += stride;
51 }
52 
53 template <class T>
check_ptr(const Type & ptr,int align)54 bool	Proxy::Ptr1 <T>::check_ptr (const Type &ptr, int align)
55 {
56 	const ptrdiff_t   x = reinterpret_cast <ptrdiff_t> (ptr);
57 
58 	return (x != 0 && (x & (align - 1)) == 0);
59 }
60 
61 template <class T>
copy(const Type & dst_ptr,const typename Ptr1<const T>::Type & src_ptr,size_t nbr_elt)62 void	Proxy::Ptr1 <T>::copy (const Type &dst_ptr, const typename Ptr1 <const T>::Type &src_ptr, size_t nbr_elt)
63 {
64 	memcpy (dst_ptr, src_ptr, nbr_elt * sizeof (DataType));
65 }
66 
67 
68 
69 /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
70 
71 
72 
73 /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
74 
75 
76 
77 }	// namespace fmtcl
78 
79 
80 
81 #endif	// fmtcl_Proxy_CODEHEADER_INCLUDED
82 
83 
84 
85 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
86