@@ -169,32 +169,31 @@ class bf_write
169
169
void SetDebugName ( const char *pDebugName );
170
170
171
171
172
- // Seek to a specific position.
173
172
public:
174
-
173
+ // Seek to a specific position.
175
174
void SeekToBit ( intp bitPos );
176
175
177
176
178
177
// Bit functions.
179
178
public:
180
179
181
- void WriteOneBit (int nValue);
182
- void WriteOneBitNoCheck (int nValue);
180
+ void WriteOneBit ( int nValue );
181
+ void WriteOneBitNoCheck ( int nValue );
183
182
void WriteOneBitAt ( int iBit, int nValue );
184
183
185
184
// Write signed or unsigned. Range is only checked in debug.
186
- void WriteUBitLong ( unsigned int data, int numbits, bool bCheckRange=true );
187
- void WriteSBitLong ( int data, int numbits );
185
+ void WriteUBitLong ( uint32 data, int numbits, bool bCheckRange=true );
186
+ void WriteSBitLong ( int32 data, int numbits );
188
187
189
188
// Tell it whether or not the data is unsigned. If it's signed,
190
189
// cast to unsigned before passing in (it will cast back inside).
191
- void WriteBitLong (unsigned int data, int numbits, bool bSigned);
190
+ void WriteBitLong ( uint32 data, int numbits, bool bSigned );
192
191
193
192
// Write a list of bits in.
194
- bool WriteBits (const void *pIn, int nBits);
193
+ bool WriteBits ( const void *pIn, intp nBits );
195
194
196
195
// writes an unsigned integer with variable bit length
197
- void WriteUBitVar ( unsigned int data );
196
+ void WriteUBitVar ( uint32 data );
198
197
199
198
// writes a varint encoded integer
200
199
void WriteVarInt32 ( uint32 data );
@@ -208,12 +207,12 @@ class bf_write
208
207
209
208
// Copy the bits straight out of pIn. This seeks pIn forward by nBits.
210
209
// Returns an error if this buffer or the read buffer overflows.
211
- bool WriteBitsFromBuffer ( class bf_read *pIn, int nBits );
210
+ bool WriteBitsFromBuffer ( class bf_read *pIn, intp nBits );
212
211
213
212
void WriteBitAngle ( float fAngle , int numbits );
214
- void WriteBitCoord ( const float f);
213
+ void WriteBitCoord ( const float f );
215
214
void WriteBitCoordMP ( const float f, bool bIntegral, bool bLowPrecision );
216
- void WriteBitFloat (float val);
215
+ void WriteBitFloat ( float val );
217
216
void WriteBitVec3Coord ( const Vector& fa );
218
217
void WriteBitNormal ( float f );
219
218
void WriteBitVec3Normal ( const Vector& fa );
@@ -232,7 +231,7 @@ class bf_write
232
231
void WriteLongLong (int64 val);
233
232
void WriteULongLong (uint64 val);
234
233
void WriteFloat (float val);
235
- bool WriteBytes ( const void *pBuf, int nBytes );
234
+ bool WriteBytes ( const void *pBuf, intp nBytes );
236
235
237
236
// Returns false if it overflows the buffer.
238
237
bool WriteString (const char *pStr);
@@ -247,8 +246,8 @@ class bf_write
247
246
[[nodiscard]] intp GetMaxNumBits () const ;
248
247
[[nodiscard]] intp GetNumBitsLeft () const ;
249
248
[[nodiscard]] intp GetNumBytesLeft () const ;
250
- [[nodiscard]] unsigned char * GetData ();
251
- [[nodiscard]] const unsigned char * GetData () const ;
249
+ [[nodiscard]] byte * GetData ();
250
+ [[nodiscard]] const byte * GetData () const ;
252
251
253
252
// Has the buffer overflowed?
254
253
[[nodiscard]] bool CheckForOverflow (intp nBits);
@@ -306,14 +305,14 @@ inline intp bf_write::GetNumBytesLeft() const
306
305
return GetNumBitsLeft () >> 3 ;
307
306
}
308
307
309
- inline unsigned char * bf_write::GetData () // -V524
308
+ inline byte * bf_write::GetData () // -V524
310
309
{
311
- return (unsigned char *) m_pData;
310
+ return (byte *) m_pData;
312
311
}
313
312
314
- inline const unsigned char * bf_write::GetData () const
313
+ inline const byte * bf_write::GetData () const
315
314
{
316
- return (unsigned char *) m_pData;
315
+ return (byte *) m_pData;
317
316
}
318
317
319
318
BITBUF_INLINE bool bf_write::CheckForOverflow (intp nBits)
@@ -391,7 +390,7 @@ inline void bf_write::WriteOneBitAt( int iBit, int nValue )
391
390
#endif
392
391
}
393
392
394
- BITBUF_INLINE void bf_write::WriteUBitLong ( unsigned int curData, int numbits, [[maybe_unused]] bool bCheckRange )
393
+ BITBUF_INLINE void bf_write::WriteUBitLong ( uint32 curData, int numbits, [[maybe_unused]] bool bCheckRange )
395
394
{
396
395
#ifdef _DEBUG
397
396
// Make sure it doesn't overflow.
@@ -444,7 +443,7 @@ BITBUF_INLINE void bf_write::WriteUBitLong( unsigned int curData, int numbits, [
444
443
}
445
444
446
445
// writes an unsigned integer with variable bit length
447
- BITBUF_INLINE void bf_write::WriteUBitVar ( unsigned int data )
446
+ BITBUF_INLINE void bf_write::WriteUBitVar ( uint32 data )
448
447
{
449
448
/* Reference:
450
449
if ( data < 0x10u )
@@ -544,7 +543,7 @@ class bf_read
544
543
// Get the base pointer.
545
544
[[nodiscard]] const unsigned char * GetBasePointer () const { return m_pData; }
546
545
547
- [[nodiscard]] BITBUF_INLINE intp TotalBytesAvailable ( void ) const
546
+ [[nodiscard]] BITBUF_INLINE intp TotalBytesAvailable () const
548
547
{
549
548
return m_nDataBytes;
550
549
}
@@ -554,23 +553,23 @@ class bf_read
554
553
// Read a list of bits in, but don't overrun the destination buffer.
555
554
// Returns the number of bits read into the buffer. The remaining
556
555
// bits are skipped over.
557
- int ReadBitsClamped_ptr (void *pOut, size_t outSizeBytes, size_t nBits);
556
+ intp ReadBitsClamped_ptr (void *pOut, intp outSizeBytes, intp nBits);
558
557
// Helper 'safe' template function that infers the size of the destination
559
558
// array. This version of the function should be preferred.
560
559
// Usage: char databuffer[100];
561
560
// ReadBitsClamped( dataBuffer, msg->m_nLength );
562
- template <typename T, size_t N>
563
- int ReadBitsClamped ( T (&pOut)[N], size_t nBits )
561
+ template <typename T, intp N>
562
+ intp ReadBitsClamped ( T (&pOut)[N], intp nBits )
564
563
{
565
564
return ReadBitsClamped_ptr ( pOut, N * sizeof (T), nBits );
566
565
}
567
566
568
567
[[nodiscard]] float ReadBitAngle ( int numbits );
569
568
570
- [[nodiscard]] unsigned int ReadUBitLong ( int numbits );
571
- [[nodiscard]] unsigned int ReadUBitLongNoInline ( int numbits );
572
- [[nodiscard]] unsigned int PeekUBitLong ( int numbits );
573
- [[nodiscard]] int ReadSBitLong ( int numbits );
569
+ [[nodiscard]] uint32 ReadUBitLong ( int numbits );
570
+ [[nodiscard]] uint32 ReadUBitLongNoInline ( int numbits );
571
+ [[nodiscard]] uint32 PeekUBitLong ( int numbits );
572
+ [[nodiscard]] int32 ReadSBitLong ( int numbits );
574
573
575
574
// reads an unsigned integer with variable bit length
576
575
[[nodiscard]] unsigned int ReadUBitVar ();
@@ -792,7 +791,7 @@ BITBUF_INLINE unsigned int bf_read::ReadUBitVar()
792
791
return sixbits >> 2 ;
793
792
}
794
793
795
- BITBUF_INLINE unsigned int bf_read::ReadUBitLong ( int numbits )
794
+ BITBUF_INLINE uint32 bf_read::ReadUBitLong ( int numbits )
796
795
{
797
796
Assert ( numbits > 0 && numbits <= 32 );
798
797
0 commit comments