OpenClonk
StdBuf Class Reference

#include <StdBuf.h>

Inheritance diagram for StdBuf:
[legend]

Public Member Functions

 StdBuf ()=default
 
 StdBuf (StdBuf &Buf2, bool fCopy=false)
 
 StdBuf (const StdBuf &Buf2, bool fCopy=true)
 
 StdBuf (StdBuf &&Buf2) noexcept
 
 StdBuf (const void *pData, size_t iSize, bool fCopy=false)
 
 ~StdBuf ()
 
bool isNull () const
 
const void * getData () const
 
void * getMData ()
 
size_t getSize () const
 
bool isRef () const
 
const void * getPtr (size_t i) const
 
void * getMPtr (size_t i)
 
StdBuf getPart (size_t iStart, size_t inSize) const
 
void Ref (const void *pnData, size_t inSize)
 
void Take (void *pnData, size_t inSize)
 
void * GrabPointer ()
 
void New (size_t inSize)
 
void Write (const void *pnData, size_t inSize, size_t iAt=0)
 
void Move (size_t iFrom, size_t inSize, size_t iTo=0)
 
int Compare (const void *pCData, size_t iCSize, size_t iAt=0) const
 
void Grow (size_t iGrow)
 
void Shrink (size_t iShrink)
 
void Clear ()
 
void SetSize (size_t inSize)
 
void Write (const StdBuf &Buf2, size_t iAt=0)
 
int Compare (const StdBuf &Buf2, size_t iAt=0) const
 
void Copy (size_t inSize)
 
void Copy ()
 
void Copy (const void *pnData, size_t inSize)
 
void Copy (const StdBuf &Buf2)
 
StdBuf Duplicate () const
 
void Append (const void *pnData, size_t inSize)
 
void Append (const StdBuf &Buf2)
 
void Ref (const StdBuf &Buf2)
 
StdBuf getRef () const
 
void Take (StdBuf &Buf2)
 
void Take (StdBuf &&Buf2)
 
bool LoadFromFile (const char *szFile)
 
bool SaveToFile (const char *szFile) const
 
bool operator! () const
 
StdBuf operator+= (const StdBuf &Buf2)
 
StdBuf operator+ (const StdBuf &Buf2) const
 
bool operator== (const StdBuf &Buf2) const
 
bool operator!= (const StdBuf &Buf2) const
 
StdBufoperator= (StdBuf &&Buf2)
 
int GetHash () const
 
void CompileFunc (class StdCompiler *pComp, int iType=0)
 

Static Public Member Functions

static void DeletePointer (void *data)
 

Protected Attributes

bool fRef = true
 
union {
const void * pData = nullptr
 
void * pMData
 
}; 
 
unsigned int iSize = 0
 

Detailed Description

Definition at line 29 of file StdBuf.h.

Constructor & Destructor Documentation

◆ StdBuf() [1/5]

StdBuf::StdBuf ( )
default

Referenced by getPart(), and getRef().

Here is the caller graph for this function:

◆ StdBuf() [2/5]

StdBuf::StdBuf ( StdBuf Buf2,
bool  fCopy = false 
)
inline

Definition at line 40 of file StdBuf.h.

41  : pData(nullptr)
42  {
43  if (fCopy)
44  Copy(Buf2);
45  else if (!Buf2.isRef())
46  Take(std::move(Buf2));
47  else
48  Ref(Buf2);
49  }
void Copy()
Definition: StdBuf.h:233
void Take(void *pnData, size_t inSize)
Definition: StdBuf.h:124
bool isRef() const
Definition: StdBuf.h:102
void Ref(const void *pnData, size_t inSize)
Definition: StdBuf.h:118

References Copy(), isRef(), Ref(), and Take().

Here is the call graph for this function:

◆ StdBuf() [3/5]

StdBuf::StdBuf ( const StdBuf Buf2,
bool  fCopy = true 
)
inline

Definition at line 50 of file StdBuf.h.

51  : pData(nullptr)
52  {
53  if (fCopy)
54  Copy(Buf2);
55  else
56  Ref(Buf2);
57  }

References Copy(), and Ref().

Here is the call graph for this function:

◆ StdBuf() [4/5]

StdBuf::StdBuf ( StdBuf &&  Buf2)
inlinenoexcept

Definition at line 58 of file StdBuf.h.

59  : pData(nullptr)
60  {
61  if (!Buf2.isRef())
62  Take(std::move(Buf2));
63  else
64  Ref(Buf2);
65  }

References Ref(), and Take().

Here is the call graph for this function:

◆ StdBuf() [5/5]

StdBuf::StdBuf ( const void *  pData,
size_t  iSize,
bool  fCopy = false 
)
inline

Definition at line 68 of file StdBuf.h.

69  : pData(pData), iSize(iSize)
70  {
71  if (fCopy) Copy();
72  }
unsigned int iSize
Definition: StdBuf.h:92

References Copy().

Here is the call graph for this function:

◆ ~StdBuf()

StdBuf::~StdBuf ( )
inline

Definition at line 74 of file StdBuf.h.

75  {
76  Clear();
77  }
void Clear()
Definition: StdBuf.h:190

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Append() [1/2]

void StdBuf::Append ( const StdBuf Buf2)
inline

Definition at line 260 of file StdBuf.h.

261  {
262  Append(Buf2.getData(), Buf2.getSize());
263  }
size_t getSize() const
Definition: StdBuf.h:101
const void * getData() const
Definition: StdBuf.h:99
void Append(const void *pnData, size_t inSize)
Definition: StdBuf.h:254

References Append(), getData(), and getSize().

Here is the call graph for this function:

◆ Append() [2/2]

void StdBuf::Append ( const void *  pnData,
size_t  inSize 
)
inline

Definition at line 254 of file StdBuf.h.

255  {
256  Grow(inSize);
257  Write(pnData, inSize, iSize - inSize);
258  }
void Grow(size_t iGrow)
Definition: StdBuf.h:171
void Write(const void *pnData, size_t inSize, size_t iAt=0)
Definition: StdBuf.h:153

References Grow(), iSize, and Write().

Referenced by Append(), operator+(), operator+=(), C4Network2RefServer::PackPacket(), C4Playback::ReadBinary(), and CStdFile::SaveBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void StdBuf::Clear ( )
inline

Definition at line 190 of file StdBuf.h.

191  {
192  if (!fRef) free(pMData);
193  pMData = nullptr; fRef = true; iSize = 0;
194  }
bool fRef
Definition: StdBuf.h:82

References fRef, and iSize.

Referenced by C4ControlReInitScenario::C4ControlReInitScenario(), C4Playback::Clear(), StdStrBuf::Clear(), C4HTTPClient::Clear(), C4NetIOPacket::Clear(), C4Record::ClearStreamingBuf(), CStdVectorFont::CStdVectorFont(), C4Group::LoadEntry(), New(), C4Playback::ReadBinary(), Ref(), C4Network2::StopStreaming(), Take(), and ~StdBuf().

Here is the caller graph for this function:

◆ Compare() [1/2]

int StdBuf::Compare ( const StdBuf Buf2,
size_t  iAt = 0 
) const
inline

Definition at line 219 of file StdBuf.h.

220  {
221  return Compare(Buf2.getData(), Buf2.getSize(), iAt);
222  }
int Compare(const void *pCData, size_t iCSize, size_t iAt=0) const
Definition: StdBuf.h:165

References Compare(), getData(), and getSize().

Here is the call graph for this function:

◆ Compare() [2/2]

int StdBuf::Compare ( const void *  pCData,
size_t  iCSize,
size_t  iAt = 0 
) const
inline

Definition at line 165 of file StdBuf.h.

166  {
167  assert(iAt + iCSize <= getSize());
168  return std::memcmp(getPtr(iAt), pCData, iCSize);
169  }
const void * getPtr(size_t i) const
Definition: StdBuf.h:104

References getPtr(), and getSize().

Referenced by Compare(), StdStrBuf::Compare(), C4NetIOUDP::DoLoopbackTest(), and operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompileFunc()

void StdBuf::CompileFunc ( class StdCompiler pComp,
int  iType = 0 
)

Definition at line 114 of file StdBuf.cpp.

115 {
116  // Size (guess it is a small value most of the time - if it's big, an extra byte won't hurt anyway)
117  uint32_t tmp = iSize; pComp->Value(mkIntPackAdapt(tmp)); iSize = tmp;
118  pComp->Separator(StdCompiler::SEP_PART2);
119  // Read/write data
120  if (pComp->isDeserializer())
121  {
122  New(iSize);
123  pComp->Raw(getMData(), iSize, StdCompiler::RawCompileType(iType));
124  }
125  else
126  {
127  pComp->Raw(const_cast<void *>(getData()), iSize, StdCompiler::RawCompileType(iType));
128  }
129 }
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:791
void * getMData()
Definition: StdBuf.h:100
void New(size_t inSize)
Definition: StdBuf.h:146

References getData(), getMData(), StdCompiler::isDeserializer(), iSize, mkIntPackAdapt(), New(), StdCompiler::Raw(), StdCompiler::SEP_PART2, StdCompiler::Separator(), and StdCompiler::Value().

Here is the call graph for this function:

◆ Copy() [1/4]

void StdBuf::Copy ( )
inline

Definition at line 233 of file StdBuf.h.

234  {
235  Copy(iSize);
236  }

References iSize.

Referenced by StdStrBuf::Copy(), Copy(), GrabPointer(), Grow(), StdCopyBuf::operator=(), Shrink(), and StdBuf().

Here is the caller graph for this function:

◆ Copy() [2/4]

void StdBuf::Copy ( const StdBuf Buf2)
inline

Definition at line 243 of file StdBuf.h.

244  {
245  Copy(Buf2.getData(), Buf2.getSize());
246  }

References Copy(), getData(), and getSize().

Here is the call graph for this function:

◆ Copy() [3/4]

void StdBuf::Copy ( const void *  pnData,
size_t  inSize 
)
inline

Definition at line 238 of file StdBuf.h.

239  {
240  Ref(pnData, inSize); Copy();
241  }

References Copy(), and Ref().

Here is the call graph for this function:

◆ Copy() [4/4]

void StdBuf::Copy ( size_t  inSize)
inline

Definition at line 225 of file StdBuf.h.

226  {
227  if (isNull() && !inSize) return;
228  const void *pOldData = getData();
229  size_t iOldSize = iSize;
230  New(inSize);
231  Write(pOldData, std::min(iOldSize, inSize));
232  }
bool isNull() const
Definition: StdBuf.h:98

References getData(), iSize, isNull(), New(), and Write().

Referenced by Duplicate(), and C4PktBuf::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeletePointer()

static void StdBuf::DeletePointer ( void *  data)
inlinestatic

Definition at line 196 of file StdBuf.h.

197  {
198  free(data);
199  }

Referenced by C4ID::CompileFunc(), and C4GroupEntry::~C4GroupEntry().

Here is the caller graph for this function:

◆ Duplicate()

StdBuf StdBuf::Duplicate ( ) const
inline

Definition at line 248 of file StdBuf.h.

249  {
250  StdBuf Buf; Buf.Copy(*this); return Buf;
251  }
Definition: StdBuf.h:30
void Copy(size_t inSize)
Definition: StdBuf.h:225

References Copy().

Referenced by C4NetIOPacket::Duplicate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getData()

const void* StdBuf::getData ( ) const
inline

Definition at line 99 of file StdBuf.h.

99 { return fRef ? pData : pMData; }

References fRef.

Referenced by C4Network2ResChunk::AddTo(), Append(), Compare(), CompileFunc(), Copy(), CStdVectorFont::CStdVectorFont(), getBufPtr(), C4PktBuf::getData(), GetDbgRecPktData(), GetHash(), getPtr(), getRef(), isNull(), C4KeyboardInput::LoadCustomConfig(), C4Network2IODiscoverClient::OnPacket(), C4HTTPClient::Query(), StdCompilerINIRead::ReadString(), C4Record::Rec(), Ref(), SaveToFile(), C4Network2::StreamOut(), and Write().

Here is the caller graph for this function:

◆ GetHash()

int StdBuf::GetHash ( ) const
inline

Definition at line 322 of file StdBuf.h.

323  {
324  if (isNull()) return 0;
325  return crc32(0, reinterpret_cast<const Bytef *>(getData()), getSize());
326  }

References getData(), getSize(), and isNull().

Referenced by StdStrBuf::GetHash().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMData()

void* StdBuf::getMData ( )
inline

Definition at line 100 of file StdBuf.h.

100 { assert(!fRef); return pMData; }

References fRef.

Referenced by C4Group::Add(), C4Playback::Check(), CompileFunc(), CStdVectorFont::CStdVectorFont(), getMBufPtr(), getMPtr(), GrabPointer(), C4TextureShape::Load(), C4SoundEffect::Load(), C4Group::LoadEntry(), LoadFromFile(), C4SolidMask::LoadMaskFromFile(), C4Playback::NextSequentialChunk(), and C4Network2::StartStreaming().

Here is the caller graph for this function:

◆ getMPtr()

void* StdBuf::getMPtr ( size_t  i)
inline

Definition at line 105 of file StdBuf.h.

105 { return reinterpret_cast<char*>(getMData()) + i; }

References getMData().

Referenced by Move(), and Write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPart()

StdBuf StdBuf::getPart ( size_t  iStart,
size_t  inSize 
) const
inline

Definition at line 107 of file StdBuf.h.

108  {
109  assert(iStart + inSize <= iSize);
110  return StdBuf(getPtr(iStart), inSize);
111  }
StdBuf()=default

References getPtr(), iSize, and StdBuf().

Referenced by C4NetIOPacket::getPBuf(), C4NetIOTCP::Peer::OnRecv(), C4Playback::ReadBinary(), and C4NetIOTCP::UnpackPacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPtr()

const void* StdBuf::getPtr ( size_t  i) const
inline

Definition at line 104 of file StdBuf.h.

104 { return reinterpret_cast<const char*>(getData()) + i; }

References getData().

Referenced by Compare(), getPart(), Move(), StdCompilerBinRead::Raw(), and StdCompilerBinRead::String().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRef()

StdBuf StdBuf::getRef ( ) const
inline

Definition at line 271 of file StdBuf.h.

272  {
273  return StdBuf(getData(), getSize());
274  }

References getData(), getSize(), and StdBuf().

Referenced by C4NetIOPacket::getRef(), operator+(), and C4Playback::ReadBinary().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSize()

◆ GrabPointer()

void* StdBuf::GrabPointer ( )
inline

Definition at line 133 of file StdBuf.h.

134  {
135  if (isNull()) return nullptr;
136  // Do not give out a buffer which someone else will free
137  if (fRef) Copy();
138  void *pMData = getMData();
139  pData = pMData; fRef = true;
140  return pMData;
141  }

References Copy(), fRef, getMData(), and isNull().

Referenced by C4Group::Add(), StdStrBuf::GrabPointer(), and Take().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Grow()

void StdBuf::Grow ( size_t  iGrow)
inline

Definition at line 171 of file StdBuf.h.

172  {
173  // Grow dereferences
174  if (fRef) { Copy(iSize + iGrow); return; }
175  if (!iGrow) return;
176  // Realloc
177  pMData = realloc(pMData, iSize += iGrow);
178  }

References Copy(), fRef, and iSize.

Referenced by Append(), StdStrBuf::Grow(), C4NetIOTCP::PackPacket(), C4Playback::ReWriteBinary(), SetSize(), C4Network2::StreamIn(), and C4Playback::StreamToRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNull()

bool StdBuf::isNull ( ) const
inline

Definition at line 98 of file StdBuf.h.

98 { return ! getData(); }

References getData().

Referenced by Copy(), C4NetIOUDP::Packet::Empty(), GetHash(), GrabPointer(), C4NetIOTCP::Peer::hasWaitingData(), C4NetIOUDP::InitBroadcast(), StdStrBuf::isNull(), and operator!().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRef()

bool StdBuf::isRef ( ) const
inline

Definition at line 102 of file StdBuf.h.

102 { return fRef; }

References fRef.

Referenced by StdStrBuf::isRef(), and StdBuf().

Here is the caller graph for this function:

◆ LoadFromFile()

bool StdBuf::LoadFromFile ( const char *  szFile)

Definition at line 32 of file StdBuf.cpp.

33 {
34  // Open file
35 #ifdef _WIN32
36  int fh = _wopen(::GetWideChar(szFile), O_BINARY | O_RDONLY | O_SEQUENTIAL, S_IREAD | S_IWRITE);
37 #else
38  int fh = open(szFile, O_BINARY | O_CLOEXEC | O_RDONLY | O_SEQUENTIAL, S_IREAD | S_IWRITE);
39 #endif
40  if (fh < 0) return false;
41  // Create buf
42  New(FileSize(fh));
43  // Read
44  if (read(fh, getMData(), getSize()) != (signed int) getSize())
45  {
46  close(fh);
47  return false;
48  }
49  close(fh);
50  // Ok
51  return true;
52 }
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
#define O_CLOEXEC
#define O_BINARY
Definition: StdBuf.cpp:25
#define O_SEQUENTIAL
Definition: StdBuf.cpp:26
size_t FileSize(const char *fname)

References FileSize(), getMData(), getSize(), GetWideChar(), New(), O_BINARY, O_CLOEXEC, and O_SEQUENTIAL.

Referenced by C4ControlJoinPlayer::C4ControlJoinPlayer(), C4ControlReInitScenario::C4ControlReInitScenario(), C4Playback::StreamToRecord(), and C4ControlJoinPlayer::Strip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Move()

void StdBuf::Move ( size_t  iFrom,
size_t  inSize,
size_t  iTo = 0 
)
inline

Definition at line 159 of file StdBuf.h.

160  {
161  assert(iFrom + inSize <= iSize); assert(iTo + inSize <= iSize);
162  std::memmove(getMPtr(iTo), getPtr(iFrom), inSize);
163  }
void * getMPtr(size_t i)
Definition: StdBuf.h:105

References getMPtr(), getPtr(), and iSize.

Referenced by C4Record::ClearStreamingBuf(), StdStrBuf::Move(), C4NetIOTCP::Peer::OnRecv(), C4Playback::ReadBinary(), and C4Network2::StreamOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ New()

void StdBuf::New ( size_t  inSize)
inline

Definition at line 146 of file StdBuf.h.

147  {
148  Clear();
149  pMData = malloc(iSize = inSize);
150  fRef = false;
151  }

References Clear(), fRef, and iSize.

Referenced by StdCompilerBinWrite::BeginSecond(), C4NetIOPacket::C4NetIOPacket(), CompileFunc(), Copy(), C4NetIOSimpleUDP::Execute(), C4Group::LoadEntry(), LoadFromFile(), C4Playback::NextSequentialChunk(), C4NetpuncherPacket::PackTo(), StdCompilerINIRead::ReadString(), StdStrBuf::Replace(), C4Network2::StartStreaming(), and C4Playback::StreamToRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!()

bool StdBuf::operator! ( ) const
inline

Definition at line 292 of file StdBuf.h.

292 { return isNull(); }

References isNull().

Here is the call graph for this function:

◆ operator!=()

bool StdBuf::operator!= ( const StdBuf Buf2) const
inline

Definition at line 312 of file StdBuf.h.

312 { return ! operator == (Buf2); }
bool operator==(const StdBuf &Buf2) const
Definition: StdBuf.h:308

References operator==().

Here is the call graph for this function:

◆ operator+()

StdBuf StdBuf::operator+ ( const StdBuf Buf2) const
inline

Definition at line 300 of file StdBuf.h.

301  {
302  StdBuf Buf(getRef());
303  Buf.Append(Buf2);
304  return Buf;
305  }
StdBuf getRef() const
Definition: StdBuf.h:271

References Append(), and getRef().

Here is the call graph for this function:

◆ operator+=()

StdBuf StdBuf::operator+= ( const StdBuf Buf2)
inline

Definition at line 295 of file StdBuf.h.

296  {
297  Append(Buf2);
298  return *this;
299  }

References Append().

Here is the call graph for this function:

◆ operator=()

StdBuf& StdBuf::operator= ( StdBuf &&  Buf2)
inline

Definition at line 315 of file StdBuf.h.

316  {
317  if (Buf2.isRef()) Ref(Buf2); else Take(std::move(Buf2));
318  return *this;
319  }

References Ref(), and Take().

Here is the call graph for this function:

◆ operator==()

bool StdBuf::operator== ( const StdBuf Buf2) const
inline

Definition at line 308 of file StdBuf.h.

309  {
310  return getSize() == Buf2.getSize() && !Compare(Buf2);
311  }

References Compare(), and getSize().

Referenced by operator!=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ref() [1/2]

void StdBuf::Ref ( const StdBuf Buf2)
inline

Definition at line 266 of file StdBuf.h.

267  {
268  Ref(Buf2.getData(), Buf2.getSize());
269  }

References getData(), getSize(), and Ref().

Here is the call graph for this function:

◆ Ref() [2/2]

void StdBuf::Ref ( const void *  pnData,
size_t  inSize 
)
inline

Definition at line 118 of file StdBuf.h.

119  {
120  Clear();
121  fRef = true; pData = pnData; iSize = inSize;
122  }

References Clear(), fRef, and iSize.

Referenced by Copy(), operator=(), StdStrBuf::Ref(), Ref(), and StdBuf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveToFile()

bool StdBuf::SaveToFile ( const char *  szFile) const

Definition at line 53 of file StdBuf.cpp.

54 {
55  // Open file
56 #ifdef _WIN32
57  int fh = _wopen(::GetWideChar(szFile), O_BINARY | O_CREAT | O_WRONLY | O_SEQUENTIAL | O_TRUNC, S_IREAD | S_IWRITE);
58 #else
59  int fh = open(szFile, O_BINARY | O_CLOEXEC | O_CREAT | O_WRONLY | O_SEQUENTIAL | O_TRUNC, S_IREAD | S_IWRITE);
60 #endif
61  if (fh < 0) return false;
62  // Write data
63  if (write(fh, getData(), getSize()) != (signed int) getSize())
64  {
65  close(fh);
66  return false;
67  }
68  close(fh);
69  // Ok
70  return true;
71 }

References getData(), getSize(), GetWideChar(), O_BINARY, O_CLOEXEC, and O_SEQUENTIAL.

Referenced by C4Playback::Open(), C4DownloadDlg::ShowModal(), C4Playback::StreamToRecord(), and C4ControlJoinPlayer::Strip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetSize()

void StdBuf::SetSize ( size_t  inSize)
inline

Definition at line 204 of file StdBuf.h.

205  {
206  if (inSize > iSize)
207  Grow(inSize - iSize);
208  else
209  Shrink(iSize - inSize);
210  }
void Shrink(size_t iShrink)
Definition: StdBuf.h:180

References Grow(), iSize, and Shrink().

Referenced by StdStrBuf::AppendFormatV(), C4Playback::Check(), C4Record::ClearStreamingBuf(), CStdVectorFont::CStdVectorFont(), C4NetIOSimpleUDP::Execute(), C4Playback::NextSequentialChunk(), C4Playback::ReWriteBinary(), and C4Playback::StreamToRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Shrink()

void StdBuf::Shrink ( size_t  iShrink)
inline

Definition at line 180 of file StdBuf.h.

181  {
182  assert(iSize >= iShrink);
183  // Shrink dereferences
184  if (fRef) { Copy(iSize - iShrink); return; }
185  if (!iShrink) return;
186  // Realloc
187  pMData = realloc(pMData, iSize -= iShrink);
188  }

References Copy(), fRef, and iSize.

Referenced by C4Playback::ReadBinary(), StdCompilerINIRead::ReadString(), SetSize(), and StdStrBuf::Shrink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Take() [1/3]

void StdBuf::Take ( StdBuf &&  Buf2)
inline

Definition at line 280 of file StdBuf.h.

281  {
282  Take(Buf2.GrabPointer(), Buf2.getSize());
283  }
void * GrabPointer()
Definition: StdBuf.h:133

References Take().

Here is the call graph for this function:

◆ Take() [2/3]

void StdBuf::Take ( StdBuf Buf2)
inline

Definition at line 276 of file StdBuf.h.

277  {
278  Take(Buf2.GrabPointer(), Buf2.getSize());
279  }

References getSize(), GrabPointer(), and Take().

Here is the call graph for this function:

◆ Take() [3/3]

void StdBuf::Take ( void *  pnData,
size_t  inSize 
)
inline

Definition at line 124 of file StdBuf.h.

125  {
126  Clear();
127  if (pnData)
128  {
129  fRef = false; pMData = pnData; iSize = inSize;
130  }
131  }

References Clear(), fRef, and iSize.

Referenced by C4Network2IO::HandlePacket(), operator=(), C4Network2ResChunk::Set(), StdBuf(), StdStrBuf::Take(), and Take().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Write() [1/2]

void StdBuf::Write ( const StdBuf Buf2,
size_t  iAt = 0 
)
inline

Definition at line 213 of file StdBuf.h.

214  {
215  Write(Buf2.getData(), Buf2.getSize(), iAt);
216  }

References getData(), getSize(), and Write().

Here is the call graph for this function:

◆ Write() [2/2]

void StdBuf::Write ( const void *  pnData,
size_t  inSize,
size_t  iAt = 0 
)
inline

Definition at line 153 of file StdBuf.h.

154  {
155  assert(iAt + inSize <= iSize);
156  if (pnData && inSize) std::memcpy(getMPtr(iAt), pnData, inSize);
157  }

References getMPtr(), and iSize.

Referenced by StdStrBuf::Append(), Append(), C4NetIOPacket::C4NetIOPacket(), Copy(), C4NetIOTCP::PackPacket(), StdCompilerBinWrite::Raw(), C4Playback::ReWriteBinary(), Write(), and StdCompilerBinWrite::WriteData().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ 

union { ... }

◆ fRef

bool StdBuf::fRef = true
protected

Definition at line 82 of file StdBuf.h.

Referenced by Clear(), getData(), getMData(), GrabPointer(), Grow(), isRef(), New(), Ref(), Shrink(), and Take().

◆ iSize

unsigned int StdBuf::iSize = 0
protected

The documentation for this class was generated from the following files: