TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MemoryStream Struct Reference

Represents an in-memory input byte stream. More...

#include <memorystream.h>

Public Types

typedef char Ch
 

Public Member Functions

 MemoryStream (const Ch *src, size_t size)
 
Ch Peek () const
 
Ch Take ()
 
size_t Tell () const
 
ChPutBegin ()
 
void Put (Ch)
 
void Flush ()
 
size_t PutEnd (Ch *)
 
const ChPeek4 () const
 

Public Attributes

const Chsrc_
 Current read position. More...
 
const Chbegin_
 Original head of the string. More...
 
const Chend_
 End of stream. More...
 
size_t size_
 Size of the stream. More...
 

Detailed Description

Represents an in-memory input byte stream.

This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream.

It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file.

Differences between MemoryStream and StringStream:

  1. StringStream has encoding but MemoryStream is a byte stream.
  2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source.
  3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4().
    Note
    implements Stream concept

Member Typedef Documentation

typedef char MemoryStream::Ch

Constructor & Destructor Documentation

MemoryStream::MemoryStream ( const Ch src,
size_t  size 
)
inline
37 : src_(src), begin_(src), end_(src + size), size_(size) {}
const Ch * end_
End of stream.
Definition: memorystream.h:55
const Ch * src_
Current read position.
Definition: memorystream.h:53
const Ch * begin_
Original head of the string.
Definition: memorystream.h:54
size_t size_
Size of the stream.
Definition: memorystream.h:56

Member Function Documentation

void MemoryStream::Flush ( )
inline
45 { RAPIDJSON_ASSERT(false); }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
Ch MemoryStream::Peek ( ) const
inline
39 { return (src_ == end_) ? '\0' : *src_; }
const Ch * end_
End of stream.
Definition: memorystream.h:55
const Ch * src_
Current read position.
Definition: memorystream.h:53
const Ch* MemoryStream::Peek4 ( ) const
inline
49  {
50  return Tell() + 4 <= size_ ? src_ : 0;
51  }
const Ch * src_
Current read position.
Definition: memorystream.h:53
size_t size_
Size of the stream.
Definition: memorystream.h:56
size_t Tell() const
Definition: memorystream.h:41

+ Here is the call graph for this function:

void MemoryStream::Put ( Ch  )
inline
44 { RAPIDJSON_ASSERT(false); }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
Ch* MemoryStream::PutBegin ( )
inline
43 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
size_t MemoryStream::PutEnd ( Ch )
inline
46 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
Ch MemoryStream::Take ( )
inline
40 { return (src_ == end_) ? '\0' : *src_++; }
const Ch * end_
End of stream.
Definition: memorystream.h:55
const Ch * src_
Current read position.
Definition: memorystream.h:53
size_t MemoryStream::Tell ( ) const
inline
41 { return static_cast<size_t>(src_ - begin_); }
const Ch * src_
Current read position.
Definition: memorystream.h:53
const Ch * begin_
Original head of the string.
Definition: memorystream.h:54

+ Here is the caller graph for this function:

Member Data Documentation

const Ch* MemoryStream::begin_

Original head of the string.

const Ch* MemoryStream::end_

End of stream.

size_t MemoryStream::size_

Size of the stream.

const Ch* MemoryStream::src_

Current read position.


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