13 #include "networkmod.h" 17 #define mRequestPacketHeaderSize 10 47 bool isError()
const {
return subID()==cErrorSubID(); }
48 const void* payload()
const;
54 int setIsNewRequest();
60 void setPayload(
void*,
od_int32 size);
61 void setStringPayload(
const char*);
67 static void setSystemSizeLimit(
od_int32);
99 static od_int32 getPayloadSize(
const void*);
101 void* payload(
bool takeover=
false);
120 , curpos_(startpos) {}
122 # define mNPFSizeFor(v) Network::PacketFiller::sizeFor(v) 123 # define mNPFSizeForArr(a,s) Network::PacketFiller::sizeFor(a,s) 125 static int sizeFor(
const T&);
127 static int sizeFor(
const T*,
int nrelems,
bool rawmode=
false);
128 static int sizeFor(
bool);
129 static int sizeFor(
const char*);
133 template <
class T>
const PacketFiller&
135 template <
class T>
const PacketFiller&
136 put(
const T*,
int nrelems,
bool rawmode=
false)
const;
137 const PacketFiller& put(
const char*)
const;
138 const PacketFiller& put(
bool)
const;
139 const PacketFiller& put(
const OD::String&)
const;
142 const PacketFiller& putBytes(
const void*,
int nrbytes)
const;
165 , curpos_(startpos) {}
167 template <
class T>
void get(T&)
const;
168 inline bool getBool()
const;
169 inline int getInt()
const;
170 inline float getFloat()
const;
171 inline double getDouble()
const;
174 template <
class T>
void getArr(T*,
int maxsz,
bool rawmode=
false)
const;
175 template <
class T>
void getSet(
TypeSet<T>&,
int maxsz=-1,
176 bool rawmode=
false)
const;
179 inline void move(
int nrb )
const { curpos_ += nrb; }
180 inline void moveTo(
int pos )
const { curpos_ = pos; }
181 template <
class T>
void peek(T&)
const;
182 inline int peekInt()
const;
183 void getBytes(
void*,
int nrbytes)
const;
200 return sizeFor( ((
int)var) );
206 return (rawmode ? 0 :
sizeof(
int)) + nrelems *
sizeof(T);
216 return sizeof(int) + str.
size();
221 int ret =
sizeof(int);
222 for (
int idx=0; idx<bss.
size(); idx++ )
223 ret += sizeFor( bss.
get(idx) );
230 const int toput = var ? 1 : 0;
238 return putBytes( &var,
sizeof(T) );
247 return putBytes( arr, nrelems *
sizeof(T) );
257 const int sz = str.
size();
259 return putBytes( str.
str(), sz );
264 const int sz = bss.
size();
266 for (
int idx=0; idx<sz; idx++ )
276 OD::memCopy( pkt_.payload_+curpos_, ptr, sz );
288 OD::memCopy( &var, pkt_.payload_+curpos_,
sizeof(T) );
294 getBytes( &var,
sizeof(T) );
304 {
pErrMsg(
"Invalid string size"); }
310 getBytes( cstr, sz );
315 {
int ret = 0; peek(ret);
return ret; }
317 {
int ret = 0;
get(ret);
return ret != 0; }
319 {
int ret = 0;
get(ret);
return ret; }
321 {
float ret = 0.f;
get(ret);
return ret; }
323 {
double ret = 0.;
get(ret);
return ret; }
339 getBytes( arr, sz*
sizeof(T) );
350 if ( maxsz >= 0 && sz > maxsz )
356 getBytes( ts.
arr(), sz*
sizeof(T) );
362 int setsz;
get( setsz );
364 if ( maxsz >= 0 && sz > maxsz )
370 for (
int idx=0; idx<sz; idx++ )
377 for (
int idx=sz; idx<setsz; idx++ )
385 OD::memCopy( ptr, pkt_.payload_+curpos_, nrbytes );
static od_int32 headerSize()
Definition: netreqpacket.h:98
#define mExpClass(module)
Definition: commondefs.h:157
Header header_
Definition: netreqpacket.h:79
BufferString getString() const
Definition: netreqpacket.h:324
static od_int16 cMoreSubID()
Definition: netreqpacket.h:83
RequestPacket & pkt_
Definition: netreqpacket.h:146
void move(int nrb) const
Definition: netreqpacket.h:179
static int sizeFor(const T &)
Definition: netreqpacket.h:194
void peek(T &) const
Definition: netreqpacket.h:286
PacketFiller(RequestPacket &p, int startpos=0)
Definition: netreqpacket.h:118
const char * str() const
Definition: odstring.h:46
Definition: jobcommunic.h:22
int curpos_
Definition: netreqpacket.h:147
OD::String that holds an existing text string.
Definition: fixedstring.h:27
void setIsLast()
Definition: netreqpacket.h:57
const PacketFiller & putBytes(const void *, int nrbytes) const
Definition: netreqpacket.h:271
BufferString & setEmpty()
BufferString & get(size_type idx)
Definition: bufstringset.h:49
int curpos_
Definition: netreqpacket.h:188
#define mRequestPacketHeaderSize
Definition: netreqpacket.h:17
Set of BufferString objects.
Definition: bufstringset.h:25
void getArr(T *, int maxsz, bool rawmode=false) const
Definition: netreqpacket.h:328
unsigned int size() const
Definition: netreqpacket.h:38
char * payload_
Definition: netreqpacket.h:80
virtual T * arr()
3rd party access
Definition: typeset.h:86
const void * getRawHeader() const
Definition: netreqpacket.h:105
bool setBufSize(unsigned int)
Set of (small) copyable elements.
Definition: commontypes.h:26
static od_int16 cBeginSubID()
Definition: netreqpacket.h:82
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:29
bool isError() const
Definition: netreqpacket.h:47
void setEmpty()
Definition: odset.h:44
bool isNewRequest() const
Definition: netreqpacket.h:45
void * getRawHeader()
Definition: netreqpacket.h:104
void getBytes(void *, int nrbytes) const
Definition: netreqpacket.h:381
int peekInt() const
Definition: netreqpacket.h:314
void setEmpty()
Definition: bufstringset.h:56
void setIsError()
Definition: netreqpacket.h:56
#define od_int16
Definition: plftypes.h:25
const PacketFiller & put(const T &) const
Definition: netreqpacket.h:236
int getInt() const
Definition: netreqpacket.h:318
float getFloat() const
Definition: netreqpacket.h:320
Definition: netreqpacket.h:115
#define od_int32
Definition: plftypes.h:29
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
const RequestPacket & pkt_
Definition: netreqpacket.h:187
void get(T &) const
Definition: netreqpacket.h:292
bool getBool() const
Definition: netreqpacket.h:316
void moveTo(int pos) const
Definition: netreqpacket.h:180
bool isRequestEnd() const
Definition: netreqpacket.h:46
virtual bool setSize(size_type, T val=T())
void getSet(TypeSet< T > &, int maxsz=-1, bool rawmode=false) const
Definition: netreqpacket.h:343
size_type size() const
Definition: bufstringset.h:37
static od_int16 cEndSubID()
Definition: netreqpacket.h:84
#define pErrMsg(msg)
Usual access point for programmer error messages.
Definition: errmsg.h:34
double getDouble() const
Definition: netreqpacket.h:322
static od_int16 cErrorSubID()
Definition: netreqpacket.h:85
char * getCStr()
Definition: bufstring.h:73
od_int32 totalSize() const
Definition: netreqpacket.h:51
PacketInterpreter(const RequestPacket &p, int startpos=0)
Definition: netreqpacket.h:162
Definition: netreqpacket.h:159