OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdCopyBuf Class Reference

#include <StdBuf.h>

Inheritance diagram for StdCopyBuf:
[legend]
Collaboration diagram for StdCopyBuf:
[legend]

Public Member Functions

 StdCopyBuf ()=default
 
 StdCopyBuf (const StdBuf &Buf2, bool fCopy=true)
 
 StdCopyBuf (const StdCopyBuf &Buf2, bool fCopy=true)
 
 StdCopyBuf (StdBuf &Buf2) noexcept
 
 StdCopyBuf (StdCopyBuf &&Buf2) noexcept
 
 StdCopyBuf (const void *pData, size_t iSize, bool fCopy=true)
 
StdCopyBufoperator= (const StdBuf &Buf2)
 
StdCopyBufoperator= (const StdCopyBuf &Buf2)
 
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 Ref (const StdBuf &Buf2)
 
void Take (void *pnData, size_t inSize)
 
void Take (StdBuf &Buf2)
 
void Take (StdBuf &&Buf2)
 
void * GrabPointer ()
 
void New (size_t inSize)
 
void Write (const void *pnData, size_t inSize, size_t iAt=0)
 
void Write (const StdBuf &Buf2, 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
 
int Compare (const StdBuf &Buf2, size_t iAt=0) const
 
void Grow (size_t iGrow)
 
void Shrink (size_t iShrink)
 
void Clear ()
 
void SetSize (size_t inSize)
 
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)
 
StdBuf getRef () const
 
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
 
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 = 0
 
void * pMData
 
}; 
 
unsigned int iSize = 0
 

Detailed Description

Definition at line 359 of file StdBuf.h.

Constructor & Destructor Documentation

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

Definition at line 366 of file StdBuf.h.

367  : StdBuf(Buf2.getRef(), fCopy)
368  { }
StdBuf getRef() const
Definition: StdBuf.h:279
StdBuf()=default
StdCopyBuf::StdCopyBuf ( const StdCopyBuf Buf2,
bool  fCopy = true 
)
inline

Definition at line 371 of file StdBuf.h.

372  : StdBuf(Buf2.getRef(), fCopy)
373  { }
StdBuf getRef() const
Definition: StdBuf.h:279
StdBuf()=default
StdCopyBuf::StdCopyBuf ( StdBuf Buf2)
inlinenoexcept

Definition at line 374 of file StdBuf.h.

375  : StdBuf(std::move(Buf2))
376  { }
StdBuf()=default
StdCopyBuf::StdCopyBuf ( StdCopyBuf &&  Buf2)
inlinenoexcept

Definition at line 377 of file StdBuf.h.

378  : StdBuf(std::move(Buf2))
379  { }
StdBuf()=default
StdCopyBuf::StdCopyBuf ( const void *  pData,
size_t  iSize,
bool  fCopy = true 
)
inline

Definition at line 382 of file StdBuf.h.

383  : StdBuf(pData, iSize, fCopy)
384  { }
StdBuf()=default
unsigned int iSize
Definition: StdBuf.h:100

Member Function Documentation

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

Definition at line 262 of file StdBuf.h.

References StdBuf::Grow(), and StdBuf::Write().

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

263  {
264  Grow(inSize);
265  Write(pnData, inSize, iSize - inSize);
266  }
void Grow(size_t iGrow)
Definition: StdBuf.h:179
void Write(const void *pnData, size_t inSize, size_t iAt=0)
Definition: StdBuf.h:161
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::Append ( const StdBuf Buf2)
inlineinherited

Definition at line 268 of file StdBuf.h.

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

269  {
270  Append(Buf2.getData(), Buf2.getSize());
271  }
const void * getData() const
Definition: StdBuf.h:107
size_t getSize() const
Definition: StdBuf.h:109
void Append(const void *pnData, size_t inSize)
Definition: StdBuf.h:262

Here is the call graph for this function:

void StdBuf::Clear ( )
inlineinherited

Definition at line 198 of file StdBuf.h.

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

199  {
200  if (!fRef) free(pMData);
201  pMData = nullptr; fRef = true; iSize = 0;
202  }
bool fRef
Definition: StdBuf.h:90
unsigned int iSize
Definition: StdBuf.h:100

Here is the caller graph for this function:

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

Definition at line 173 of file StdBuf.h.

References StdBuf::getPtr(), and StdBuf::getSize().

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

174  {
175  assert(iAt + iCSize <= getSize());
176  return std::memcmp(getPtr(iAt), pCData, iCSize);
177  }
size_t getSize() const
Definition: StdBuf.h:109
const void * getPtr(size_t i) const
Definition: StdBuf.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 227 of file StdBuf.h.

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

228  {
229  return Compare(Buf2.getData(), Buf2.getSize(), iAt);
230  }
const void * getData() const
Definition: StdBuf.h:107
size_t getSize() const
Definition: StdBuf.h:109
int Compare(const void *pCData, size_t iCSize, size_t iAt=0) const
Definition: StdBuf.h:173

Here is the call graph for this function:

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

Definition at line 121 of file StdBuf.cpp.

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

122 {
123  // Size (guess it is a small value most of the time - if it's big, an extra byte won't hurt anyway)
124  uint32_t tmp = iSize; pComp->Value(mkIntPackAdapt(tmp)); iSize = tmp;
125  pComp->Separator(StdCompiler::SEP_PART2);
126  // Read/write data
127  if (pComp->isDeserializer())
128  {
129  New(iSize);
130  pComp->Raw(getMData(), iSize, StdCompiler::RawCompileType(iType));
131  }
132  else
133  {
134  pComp->Raw(const_cast<void *>(getData()), iSize, StdCompiler::RawCompileType(iType));
135  }
136 }
const void * getData() const
Definition: StdBuf.h:107
void New(size_t inSize)
Definition: StdBuf.h:154
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:757
unsigned int iSize
Definition: StdBuf.h:100
void * getMData()
Definition: StdBuf.h:108

Here is the call graph for this function:

void StdBuf::Copy ( size_t  inSize)
inlineinherited

Definition at line 233 of file StdBuf.h.

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

Referenced by C4PktBuf::C4PktBuf(), StdBuf::Duplicate(), and C4Network2HTTPClient::UnpackPacket().

234  {
235  if (isNull() && !inSize) return;
236  const void *pOldData = getData();
237  size_t iOldSize = iSize;
238  New(inSize);
239  Write(pOldData, std::min(iOldSize, inSize));
240  }
const void * getData() const
Definition: StdBuf.h:107
bool isNull() const
Definition: StdBuf.h:106
void New(size_t inSize)
Definition: StdBuf.h:154
void Write(const void *pnData, size_t inSize, size_t iAt=0)
Definition: StdBuf.h:161
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::Copy ( )
inlineinherited

Definition at line 241 of file StdBuf.h.

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

242  {
243  Copy(iSize);
244  }
void Copy()
Definition: StdBuf.h:241
unsigned int iSize
Definition: StdBuf.h:100

Here is the caller graph for this function:

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

Definition at line 246 of file StdBuf.h.

References StdBuf::Copy(), and StdBuf::Ref().

247  {
248  Ref(pnData, inSize); Copy();
249  }
void Copy()
Definition: StdBuf.h:241
void Ref(const void *pnData, size_t inSize)
Definition: StdBuf.h:126

Here is the call graph for this function:

void StdBuf::Copy ( const StdBuf Buf2)
inlineinherited

Definition at line 251 of file StdBuf.h.

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

252  {
253  Copy(Buf2.getData(), Buf2.getSize());
254  }
const void * getData() const
Definition: StdBuf.h:107
void Copy()
Definition: StdBuf.h:241
size_t getSize() const
Definition: StdBuf.h:109

Here is the call graph for this function:

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

Definition at line 204 of file StdBuf.h.

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

205  {
206  free(data);
207  }

Here is the caller graph for this function:

StdBuf StdBuf::Duplicate ( ) const
inlineinherited

Definition at line 256 of file StdBuf.h.

References StdBuf::Copy().

Referenced by C4NetIOPacket::Duplicate().

257  {
258  StdBuf Buf; Buf.Copy(*this); return Buf;
259  }
Definition: StdBuf.h:37
void Copy(size_t inSize)
Definition: StdBuf.h:233

Here is the call graph for this function:

Here is the caller graph for this function:

const void* StdBuf::getData ( ) const
inlineinherited
int StdBuf::GetHash ( ) const
inlineinherited

Definition at line 330 of file StdBuf.h.

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

Referenced by StdStrBuf::GetHash().

331  {
332  if (isNull()) return 0;
333  return crc32(0, reinterpret_cast<const Bytef *>(getData()), getSize());
334  }
const void * getData() const
Definition: StdBuf.h:107
bool isNull() const
Definition: StdBuf.h:106
size_t getSize() const
Definition: StdBuf.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

void* StdBuf::getMData ( )
inlineinherited

Definition at line 108 of file StdBuf.h.

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

108 { assert(!fRef); return pMData; }
bool fRef
Definition: StdBuf.h:90

Here is the caller graph for this function:

void* StdBuf::getMPtr ( size_t  i)
inlineinherited

Definition at line 113 of file StdBuf.h.

References StdBuf::getMData().

Referenced by StdBuf::Move(), and StdBuf::Write().

113 { return reinterpret_cast<char*>(getMData()) + i; }
void * getMData()
Definition: StdBuf.h:108

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 115 of file StdBuf.h.

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

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

116  {
117  assert(iStart + inSize <= iSize);
118  return StdBuf(getPtr(iStart), inSize);
119  }
StdBuf()=default
unsigned int iSize
Definition: StdBuf.h:100
const void * getPtr(size_t i) const
Definition: StdBuf.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 112 of file StdBuf.h.

References StdBuf::getData().

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

112 { return reinterpret_cast<const char*>(getData()) + i; }
const void * getData() const
Definition: StdBuf.h:107

Here is the call graph for this function:

Here is the caller graph for this function:

StdBuf StdBuf::getRef ( ) const
inlineinherited

Definition at line 279 of file StdBuf.h.

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

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

280  {
281  return StdBuf(getData(), getSize());
282  }
const void * getData() const
Definition: StdBuf.h:107
size_t getSize() const
Definition: StdBuf.h:109
StdBuf()=default

Here is the call graph for this function:

Here is the caller graph for this function:

size_t StdBuf::getSize ( ) const
inlineinherited

Definition at line 109 of file StdBuf.h.

References StdBuf::iSize.

Referenced by C4Group::Add(), C4NetIOUDP::Packet::AddFragment(), C4Network2ResChunk::AddTo(), StdBuf::Append(), C4Record::ClearStreamingBuf(), StdBuf::Compare(), StdBuf::Copy(), CStdVectorFont::CStdVectorFont(), C4NetIOUDP::DoLoopbackTest(), C4StartupNetDlg::DoOK(), C4Network2::DrawStatus(), GetDbgRecPktData(), StdBuf::GetHash(), C4NetIOPacket::getPBuf(), C4NetIOPacket::getPData(), C4Network2::getPendingStreamData(), C4NetIOPacket::getPSize(), StdBuf::getRef(), StdCompilerBinRead::getRemainingBytes(), C4PktBuf::getSize(), StdStrBuf::getSize(), C4NetIOPacket::getStatus(), C4Network2IO::HandlePacket(), C4TextureShape::Load(), C4SoundEffect::Load(), StdBuf::LoadFromFile(), C4SolidMask::LoadMaskFromFile(), C4Network2IODiscover::OnPacket(), C4Network2IODiscoverClient::OnPacket(), C4Network2IO::OnPacket(), C4NetIOUDP::Peer::OnRecv(), StdBuf::operator==(), C4NetIOTCP::PackPacket(), C4NetpuncherPacket::PackTo(), C4Network2HTTPClient::Query(), StdCompilerBinRead::Raw(), StdCompilerINIRead::Raw(), C4Playback::ReadBinary(), StdCompilerBinRead::ReadValue(), C4Record::Rec(), StdBuf::Ref(), C4Playback::ReWriteBinary(), StdBuf::SaveToFile(), C4NetIOSimpleUDP::Send(), C4Network2::StreamIn(), C4Playback::StreamToRecord(), StdCompilerBinRead::String(), StdBuf::Take(), C4Network2RefServer::UnpackPacket(), C4Network2HTTPClient::UnpackPacket(), C4NetIOTCP::UnpackPacket(), and StdBuf::Write().

109 { return iSize; }
unsigned int iSize
Definition: StdBuf.h:100

Here is the caller graph for this function:

void* StdBuf::GrabPointer ( )
inlineinherited

Definition at line 141 of file StdBuf.h.

References StdBuf::Copy(), StdBuf::getMData(), and StdBuf::isNull().

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

142  {
143  if (isNull()) return nullptr;
144  // Do not give out a buffer which someone else will free
145  if (fRef) Copy();
146  void *pMData = getMData();
147  pData = pMData; fRef = true;
148  return pMData;
149  }
void Copy()
Definition: StdBuf.h:241
bool isNull() const
Definition: StdBuf.h:106
bool fRef
Definition: StdBuf.h:90
void * getMData()
Definition: StdBuf.h:108

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::Grow ( size_t  iGrow)
inlineinherited

Definition at line 179 of file StdBuf.h.

References StdBuf::Copy().

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

180  {
181  // Grow dereferences
182  if (fRef) { Copy(iSize + iGrow); return; }
183  if (!iGrow) return;
184  // Realloc
185  pMData = realloc(pMData, iSize += iGrow);
186  }
void Copy()
Definition: StdBuf.h:241
bool fRef
Definition: StdBuf.h:90
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdBuf::isNull ( ) const
inlineinherited

Definition at line 106 of file StdBuf.h.

References StdBuf::getData().

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

106 { return ! getData(); }
const void * getData() const
Definition: StdBuf.h:107

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdBuf::isRef ( ) const
inlineinherited

Definition at line 110 of file StdBuf.h.

References StdBuf::fRef.

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

110 { return fRef; }
bool fRef
Definition: StdBuf.h:90

Here is the caller graph for this function:

bool StdBuf::LoadFromFile ( const char *  szFile)
inherited

Definition at line 39 of file StdBuf.cpp.

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

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

40 {
41  // Open file
42 #ifdef _WIN32
43  int fh = _wopen(::GetWideChar(szFile), O_BINARY | O_RDONLY | O_SEQUENTIAL, S_IREAD | S_IWRITE);
44 #else
45  int fh = open(szFile, O_BINARY | O_CLOEXEC | O_RDONLY | O_SEQUENTIAL, S_IREAD | S_IWRITE);
46 #endif
47  if (fh < 0) return false;
48  // Create buf
49  New(FileSize(fh));
50  // Read
51  if (read(fh, getMData(), getSize()) != (signed int) getSize())
52  {
53  close(fh);
54  return false;
55  }
56  close(fh);
57  // Ok
58  return true;
59 }
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
#define O_BINARY
Definition: StdBuf.cpp:28
#define O_CLOEXEC
size_t getSize() const
Definition: StdBuf.h:109
void New(size_t inSize)
Definition: StdBuf.h:154
size_t FileSize(const char *szFilename)
Definition: StdFile.cpp:448
#define O_SEQUENTIAL
Definition: StdBuf.cpp:29
void * getMData()
Definition: StdBuf.h:108

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 167 of file StdBuf.h.

References StdBuf::getMPtr(), and StdBuf::getPtr().

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

168  {
169  assert(iFrom + inSize <= iSize); assert(iTo + inSize <= iSize);
170  std::memmove(getMPtr(iTo), getPtr(iFrom), inSize);
171  }
void * getMPtr(size_t i)
Definition: StdBuf.h:113
unsigned int iSize
Definition: StdBuf.h:100
const void * getPtr(size_t i) const
Definition: StdBuf.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::New ( size_t  inSize)
inlineinherited

Definition at line 154 of file StdBuf.h.

References StdBuf::Clear().

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

155  {
156  Clear();
157  pMData = malloc(iSize = inSize);
158  fRef = false;
159  }
void Clear()
Definition: StdBuf.h:198
bool fRef
Definition: StdBuf.h:90
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdBuf::operator! ( ) const
inlineinherited

Definition at line 300 of file StdBuf.h.

References StdBuf::isNull().

300 { return isNull(); }
bool isNull() const
Definition: StdBuf.h:106

Here is the call graph for this function:

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

Definition at line 320 of file StdBuf.h.

References StdBuf::operator==().

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

Here is the call graph for this function:

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

Definition at line 308 of file StdBuf.h.

References StdBuf::Append(), and StdBuf::getRef().

309  {
310  StdBuf Buf(getRef());
311  Buf.Append(Buf2);
312  return Buf;
313  }
Definition: StdBuf.h:37
StdBuf getRef() const
Definition: StdBuf.h:279

Here is the call graph for this function:

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

Definition at line 303 of file StdBuf.h.

References StdBuf::Append().

304  {
305  Append(Buf2);
306  return *this;
307  }
void Append(const void *pnData, size_t inSize)
Definition: StdBuf.h:262

Here is the call graph for this function:

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

Definition at line 386 of file StdBuf.h.

References StdBuf::Copy().

386 { Copy(Buf2); return *this; }
void Copy()
Definition: StdBuf.h:241

Here is the call graph for this function:

StdCopyBuf& StdCopyBuf::operator= ( const StdCopyBuf Buf2)
inline

Definition at line 387 of file StdBuf.h.

References StdBuf::Copy().

387 { Copy(Buf2); return *this; }
void Copy()
Definition: StdBuf.h:241

Here is the call graph for this function:

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

Definition at line 316 of file StdBuf.h.

References StdBuf::Compare(), and StdBuf::getSize().

Referenced by StdBuf::operator!=().

317  {
318  return getSize() == Buf2.getSize() && !Compare(Buf2);
319  }
size_t getSize() const
Definition: StdBuf.h:109
int Compare(const void *pCData, size_t iCSize, size_t iAt=0) const
Definition: StdBuf.h:173

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 126 of file StdBuf.h.

References StdBuf::Clear().

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

127  {
128  Clear();
129  fRef = true; pData = pnData; iSize = inSize;
130  }
void Clear()
Definition: StdBuf.h:198
bool fRef
Definition: StdBuf.h:90
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::Ref ( const StdBuf Buf2)
inlineinherited

Definition at line 274 of file StdBuf.h.

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

275  {
276  Ref(Buf2.getData(), Buf2.getSize());
277  }
const void * getData() const
Definition: StdBuf.h:107
size_t getSize() const
Definition: StdBuf.h:109
void Ref(const void *pnData, size_t inSize)
Definition: StdBuf.h:126

Here is the call graph for this function:

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

Definition at line 60 of file StdBuf.cpp.

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

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

61 {
62  // Open file
63 #ifdef _WIN32
64  int fh = _wopen(::GetWideChar(szFile), O_BINARY | O_CREAT | O_WRONLY | O_SEQUENTIAL | O_TRUNC, S_IREAD | S_IWRITE);
65 #else
66  int fh = open(szFile, O_BINARY | O_CLOEXEC | O_CREAT | O_WRONLY | O_SEQUENTIAL | O_TRUNC, S_IREAD | S_IWRITE);
67 #endif
68  if (fh < 0) return false;
69  // Write data
70  if (write(fh, getData(), getSize()) != (signed int) getSize())
71  {
72  close(fh);
73  return false;
74  }
75  close(fh);
76  // Ok
77  return true;
78 }
const void * getData() const
Definition: StdBuf.h:107
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
#define O_BINARY
Definition: StdBuf.cpp:28
#define O_CLOEXEC
size_t getSize() const
Definition: StdBuf.h:109
#define O_SEQUENTIAL
Definition: StdBuf.cpp:29

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::SetSize ( size_t  inSize)
inlineinherited

Definition at line 212 of file StdBuf.h.

References StdBuf::Grow(), and StdBuf::Shrink().

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

213  {
214  if (inSize > iSize)
215  Grow(inSize - iSize);
216  else
217  Shrink(iSize - inSize);
218  }
void Grow(size_t iGrow)
Definition: StdBuf.h:179
void Shrink(size_t iShrink)
Definition: StdBuf.h:188
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::Shrink ( size_t  iShrink)
inlineinherited

Definition at line 188 of file StdBuf.h.

References StdBuf::Copy().

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

189  {
190  assert(iSize >= iShrink);
191  // Shrink dereferences
192  if (fRef) { Copy(iSize - iShrink); return; }
193  if (!iShrink) return;
194  // Realloc
195  pMData = realloc(pMData, iSize -= iShrink);
196  }
void Copy()
Definition: StdBuf.h:241
bool fRef
Definition: StdBuf.h:90
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 132 of file StdBuf.h.

References StdBuf::Clear().

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

133  {
134  Clear();
135  if (pnData)
136  {
137  fRef = false; pMData = pnData; iSize = inSize;
138  }
139  }
void Clear()
Definition: StdBuf.h:198
bool fRef
Definition: StdBuf.h:90
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

void StdBuf::Take ( StdBuf Buf2)
inlineinherited

Definition at line 284 of file StdBuf.h.

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

285  {
286  Take(Buf2.GrabPointer(), Buf2.getSize());
287  }
void Take(void *pnData, size_t inSize)
Definition: StdBuf.h:132
void * GrabPointer()
Definition: StdBuf.h:141
size_t getSize() const
Definition: StdBuf.h:109

Here is the call graph for this function:

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

Definition at line 288 of file StdBuf.h.

References StdBuf::Take().

289  {
290  Take(Buf2.GrabPointer(), Buf2.getSize());
291  }
void Take(void *pnData, size_t inSize)
Definition: StdBuf.h:132
void * GrabPointer()
Definition: StdBuf.h:141
size_t getSize() const
Definition: StdBuf.h:109

Here is the call graph for this function:

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

Definition at line 161 of file StdBuf.h.

References StdBuf::getMPtr().

Referenced by C4NetIOUDP::Packet::AddFragment(), StdBuf::Append(), StdStrBuf::Append(), C4NetIOPacket::C4NetIOPacket(), StdBuf::Copy(), C4NetIOUDP::Peer::DoCheck(), C4NetIOUDP::Packet::GetFragment(), C4NetpuncherPacket::PackTo(), StdCompilerBinWrite::Raw(), StdBuf::Write(), and StdCompilerBinWrite::WriteData().

162  {
163  assert(iAt + inSize <= iSize);
164  if (pnData && inSize) std::memcpy(getMPtr(iAt), pnData, inSize);
165  }
void * getMPtr(size_t i)
Definition: StdBuf.h:113
unsigned int iSize
Definition: StdBuf.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 221 of file StdBuf.h.

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

222  {
223  Write(Buf2.getData(), Buf2.getSize(), iAt);
224  }
const void * getData() const
Definition: StdBuf.h:107
size_t getSize() const
Definition: StdBuf.h:109
void Write(const void *pnData, size_t inSize, size_t iAt=0)
Definition: StdBuf.h:161

Here is the call graph for this function:

Member Data Documentation

union { ... }
bool StdBuf::fRef = true
protectedinherited

Definition at line 90 of file StdBuf.h.

Referenced by StdBuf::isRef().

unsigned int StdBuf::iSize = 0
protectedinherited

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