Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
netbuffer.h File Reference
#include <string.h>
#include "cmd/weapon_xml.h"
#include "gfx/vec.h"
#include "gfx/matrix.h"
#include "gfx/quaternion.h"
#include "networking/lowlevel/vsnet_clientstate.h"
#include "cmd/unit_armorshield.h"
#include "gfxlib_struct.h"

Go to the source code of this file.

Classes

class  NetBuffer
 

Functions

std::string getSimpleString (std::string &input)
 
char getSimpleChar (std::string &input)
 
int getSimpleInt (std::string &input)
 
void addSimpleString (std::string &input, const std::string adder)
 
void addSimpleChar (std::string &input, const char adder)
 
void addSimpleInt (std::string &input, const int adder)
 

Function Documentation

void addSimpleChar ( std::string &  input,
const char  adder 
)

Definition at line 45 of file netbuffer.cpp.

Referenced by AcctLogout(), NetClient::loginAcctLoop(), NetServer::saveAccount(), NetServer::sendJump(), and NetServer::start().

46 {
47  char add[2] = {adder, '\0'};
48  input += std::string( add, 1 );
49 }
void addSimpleInt ( std::string &  input,
const int  adder 
)

Definition at line 51 of file netbuffer.cpp.

References XMLSupport::tostring().

Referenced by addSimpleString().

52 {
53  input += XMLSupport::tostring( adder )+" ";
54 }
void addSimpleString ( std::string &  input,
const std::string  adder 
)

Definition at line 39 of file netbuffer.cpp.

References addSimpleInt().

Referenced by AcctLogout(), AddWriteSave(), NetClient::loginAcctLoop(), NetServer::saveAccount(), NetServer::sendJump(), and NetServer::start().

40 {
41  addSimpleInt( input, adder.length() );
42  input += adder;
43 }
char getSimpleChar ( std::string &  input)

Definition at line 20 of file netbuffer.cpp.

21 {
22  char retval = input[0];
23  input = input.substr( 1 );
24  return retval;
25 }
int getSimpleInt ( std::string &  input)

Definition at line 27 of file netbuffer.cpp.

References XMLSupport::parse_int().

Referenced by getSimpleString().

28 {
29  std::string::size_type where = input.find( " " );
30  if (where != string::npos) {
31  std::string num = input.substr( 0, where );
32  int len = XMLSupport::parse_int( num );
33  input = input.substr( where+1 );
34  return len;
35  }
36  return 0;
37 }
std::string getSimpleString ( std::string &  input)

Definition at line 9 of file netbuffer.cpp.

References getSimpleInt().

10 {
11  int len = getSimpleInt( input );
12  if ( len >= 0 && (unsigned int) len <= input.length() ) {
13  std::string retval = input.substr( 0, len );
14  input = input.substr( len );
15  return retval;
16  }
17  return "";
18 }