UDocumentation
UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NetBitStreamUtils.h
Go to the documentation of this file.
1
// Copyright Epic Games, Inc. All Rights Reserved.
2
3
#pragma once
4
5
#include "
CoreTypes.h
"
6
#include <stdlib.h>
7
#include "
Misc/ByteSwap.h
"
8
9
namespace
UE::Net::BitStreamUtils
10
{
11
12
// BitCount is in range [1, 31]
13
inline
uint32
GetBits
(
const
uint32
* Src,
uint32
SrcBit
,
uint32
BitCount)
14
{
15
const
uint32
ShiftAmount0
=
SrcBit
& 31U;
16
// Only masking with 31 to avoid undefined behavior. Otherwise 32U - ShiftAmount0 could have been used because Word1 would be masked away anyway.
17
const
uint32
ShiftAmount1
= (32U -
SrcBit
) & 31U;
18
19
const
uint32
WordOffset0
=
SrcBit
>> 5U;
20
const
uint32
WordOffset1
= (
SrcBit
+ BitCount - 1) >> 5U;
21
22
const
uint32
Word0 =
INTEL_ORDER32
(Src[
WordOffset0
]) >>
ShiftAmount0
;
23
const
uint32
Word1 =
INTEL_ORDER32
(Src[
WordOffset1
]) <<
ShiftAmount1
;
24
25
// WordOffset1 is either WordOffset0 or WordOffset0+1. By subtracting WordOffset0 from WordOffset1
26
// the desired mask 0xFFFFFFFF is produced if the offsets differ and 0 if they are the same.
27
const
uint32
Word1Mask
=
WordOffset0
-
WordOffset1
;
28
const
uint32
WordMask
= (1U << BitCount) - 1U;
29
30
const
uint32
Word
= ((Word1 &
Word1Mask
) | Word0) &
WordMask
;
31
return
Word
;
32
}
33
34
}
ByteSwap.h
INTEL_ORDER32
#define INTEL_ORDER32(x)
Definition
ByteSwap.h:140
CoreTypes.h
StaticCastSharedRef
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition
SharedPointer.h:127
ECursorMoveGranularity::Word
@ Word
uint32
uint32_t uint32
Definition
binka_ue_file_header.h:6
UE::Net::BitStreamUtils
Definition
NetBitStreamUtils.h:10
UE::Net::BitStreamUtils::GetBits
uint32 GetBits(const uint32 *Src, uint32 SrcBit, uint32 BitCount)
Definition
NetBitStreamUtils.h:13
Engine
Source
Runtime
Net
Iris
Private
Iris
Serialization
NetBitStreamUtils.h
Generated by
1.9.8