132
|
1 /*******************************************************************************
|
|
2
|
|
3 copyright: Copyright (c) 2007 Kris Bell. All rights reserved
|
|
4
|
|
5 license: BSD style: $(LICENSE)
|
|
6
|
|
7 version: Jan 2007 : initial release
|
|
8
|
|
9 author: Kris
|
|
10
|
|
11 *******************************************************************************/
|
|
12
|
|
13 module tango.io.protocol.PickleProtocol;
|
|
14
|
|
15 /*******************************************************************************
|
|
16
|
|
17 *******************************************************************************/
|
|
18
|
|
19 version (BigEndian)
|
|
20 {
|
|
21 private import tango.io.protocol.NativeProtocol;
|
|
22 public alias NativeProtocol PickleProtocol;
|
|
23 }
|
|
24 else
|
|
25 {
|
|
26 private import tango.io.protocol.EndianProtocol;
|
|
27 public alias EndianProtocol PickleProtocol;
|
|
28 }
|
|
29
|
|
30
|
|
31 /*******************************************************************************
|
|
32
|
|
33 *******************************************************************************/
|
|
34
|
|
35 debug (UnitTest)
|
|
36 {
|
|
37 import tango.io.Buffer;
|
|
38
|
|
39 unittest
|
|
40 {
|
|
41 int test = 0xcc55ff00;
|
|
42
|
|
43 auto protocol = new PickleProtocol (new Buffer(32));
|
|
44 protocol.write (&test, test.sizeof, protocol.Type.Int);
|
|
45
|
|
46 auto ptr = protocol.buffer.slice (test.sizeof, false).ptr;
|
|
47 protocol.read (&test, test.sizeof, protocol.Type.Int);
|
|
48
|
|
49 assert (test == 0xcc55ff00);
|
|
50
|
|
51 version (LittleEndian)
|
|
52 assert (*cast(int*) ptr == 0x00ff55cc);
|
|
53 }
|
|
54 }
|
|
55
|
|
56
|
|
57
|
|
58
|
|
59
|