docs/Writerside/topics/buffer.h.md

changeset 1260
56a019cdb055
parent 1259
7bc999fe285d
child 1261
6bbc308b7a20
equal deleted inserted replaced
1259:7bc999fe285d 1260:56a019cdb055
142 int cxBufferShiftRight(CxBuffer *buffer, size_t shift); 142 int cxBufferShiftRight(CxBuffer *buffer, size_t shift);
143 143
144 int cxBufferShiftLeft(CxBuffer *buffer, size_t shift); 144 int cxBufferShiftLeft(CxBuffer *buffer, size_t shift);
145 ``` 145 ```
146 146
147 <warning> 147 The function `cxBufferShift()` moves the contents within the buffer by the specified `shift` offset,
148 TODO: document 148 where a negative offset means a shift to the left, and a positive offset means a shift to the right.
149 </warning> 149 It also adjusts the current position within the buffer, and in case of a right shift also the size, by the same offset.
150
151 Data that is shift to the left, is always discarded when the new position of a byte would be smaller than zero.
152 If the new position would be smaller than zero, it is set exactly to zero.
153
154 When data is shift to the right, the behavior depends on the `CX_BUFFER_AUTO_EXTEND` flag.
155 If set, the function extends the buffer's capacity before moving the data.
156 Otherwise, the function discards all data that would exceed the buffer's capacity, and both the size and the position are equal to the capacity
157 (which means, `cxBufferEof()` returns `true` after the operation).
158
159 The functions `cxBufferShiftRight()` and `cxBufferShiftLeft()` accept a larger (but in both cases positive) shift offset,
160 which usually does not make much sense on a 64-bit platform where `off_t` is already large enough to represent any reasonable offset.
161 You may, however, still use those function to express more explicitly in your code in which direction you want the contents to be shifted.
150 162
151 ## Flushing 163 ## Flushing
152 164
153 ```C 165 ```C
154 #include <cx/buffer.h> 166 #include <cx/buffer.h>

mercurial