wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 // Port of the ChannelBuffer struct from tclIO.h/tclIO.c
2 // and associated functionality
3 //
4 // Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
5 //$Header$
6  
7 using System;
8 namespace tcl.lang
9 {
10  
11 class ChannelBuffer
12 {
13  
14 // The next position into which a character
15 // will be put in the buffer.
16  
17 internal int nextAdded;
18  
19 // Position of next byte to be removed
20 // from the buffer.
21  
22 internal int nextRemoved;
23  
24 // How big is the buffer?
25  
26 internal int bufLength;
27  
28 // Next buffer in chain.
29  
30 internal ChannelBuffer next;
31  
32 // The actual bytes stored in the buffer
33  
34 internal byte[] buf;
35  
36 // A channel buffer has BUFFER_PADDING bytes extra at beginning to
37 // hold any bytes of a native-encoding character that got split by
38 // the end of the previous buffer and need to be moved to the
39 // beginning of the next buffer to make a contiguous string so it
40 // can be converted to UTF-8.
41 //
42 // A channel buffer has BUFFER_PADDING bytes extra at the end to
43 // hold any bytes of a native-encoding character (generated from a
44 // UTF-8 character) that overflow past the end of the buffer and
45 // need to be moved to the next buffer.
46  
47 internal const int BUFFER_PADDING = 16;
48  
49 /// <summary> AllocChannelBuffer -> ChannelBuffer
50 ///
51 /// Create a new ChannelBuffer object
52 /// </summary>
53  
54 internal ChannelBuffer( int length )
55 {
56 int n;
57  
58 n = length + BUFFER_PADDING + BUFFER_PADDING;
59 buf = new byte[n];
60 nextAdded = BUFFER_PADDING;
61 nextRemoved = BUFFER_PADDING;
62 bufLength = length + BUFFER_PADDING;
63 next = null;
64 }
65 }
66 }