SourceMod SDK  1.7
IDataPack.h
Go to the documentation of this file.
1 
32 #ifndef _INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_
33 #define _INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_
34 
35 #include <sp_vm_api.h>
36 
43 namespace SourceMod
44 {
49  {
50  public:
54  virtual void Reset() const =0;
55 
61  virtual size_t GetPosition() const =0;
62 
69  virtual bool SetPosition(size_t pos) const =0;
70 
76  virtual cell_t ReadCell() const =0;
77 
83  virtual float ReadFloat() const =0;
84 
92  virtual bool IsReadable(size_t bytes) const =0;
93 
100  virtual const char *ReadString(size_t *len) const =0;
101 
107  virtual void *GetMemory() const =0;
108 
115  virtual void *ReadMemory(size_t *size) const =0;
116 
122  virtual cell_t ReadFunction() const =0;
123  };
124 
128  class IDataPack : public IDataReader
129  {
130  public:
134  virtual void ResetSize() =0;
135 
141  virtual void PackCell(cell_t cell) =0;
142 
148  virtual void PackFloat(float val) =0;
149 
156  virtual void PackString(const char *string) =0;
157 
169  virtual size_t CreateMemory(size_t size, void **addr) =0;
170 
176  virtual void PackFunction(cell_t function) =0;
177  };
178 }
179 
180 #endif //_INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_
virtual void * ReadMemory(size_t *size) const =0
Reads the current position as a generic data type.
virtual void ResetSize()=0
Resets the used size of the stream back to zero.
virtual float ReadFloat() const =0
Reads one float from the data stream.
virtual cell_t ReadCell() const =0
Reads one cell from the data stream.
virtual void PackString(const char *string)=0
Packs one string into the data stream. The length is recorded as well for buffer overrun protection...
Specifies a data pack that can only be read.
Definition: IDataPack.h:48
virtual size_t CreateMemory(size_t size, void **addr)=0
Creates a generic block of memory in the stream.
virtual const char * ReadString(size_t *len) const =0
Reads a string from the data stream.
virtual void * GetMemory() const =0
Reads the current position as a generic address.
virtual void PackFunction(cell_t function)=0
Packs one function pointer into the data stream.
Specifies a data pack that can only be written.
Definition: IDataPack.h:128
Definition: IAdminSystem.h:63
virtual size_t GetPosition() const =0
Retrieves the current stream position.
virtual void Reset() const =0
Resets the position in the data stream to the beginning.
virtual bool SetPosition(size_t pos) const =0
Sets the current stream position.
virtual void PackCell(cell_t cell)=0
Packs one cell into the data stream.
virtual bool IsReadable(size_t bytes) const =0
Returns whether or not a specified number of bytes from the current stream position to the end can be...
virtual void PackFloat(float val)=0
Packs one float into the data stream.
virtual cell_t ReadFunction() const =0
Reads a function pointer from the data stream.