Skip to content

Instantly share code, notes, and snippets.

@pnegri
Created April 15, 2014 22:05
Show Gist options
  • Save pnegri/10781677 to your computer and use it in GitHub Desktop.
Save pnegri/10781677 to your computer and use it in GitHub Desktop.
//oo FString
std::ostream& operator<<( std::ostream & s, FString& c )
{
uint16 fstringLength = c.Len();
s.write( reinterpret_cast<const char*>(&fstringLength), sizeof(fstringLength) );
return s;
}
std::istream& operator>>( std::istream & s, FString& c )
{
//s.read( reinterpret_cast<char*>(&c), sizeof(c) );
uint16 fstringLength = 0;
s.read( reinterpret_cast<char *>(&fstringLength), sizeof(fstringLength) );
static char buffer[65535];
memset( buffer, 0, 65535);
if (s.good())
{
//s.read( reinterpret_cast<char *>(&buffer), sizeof(char)*(unsigned short)str_len );
//_value.assign(buffer, str_len);
}
return s;
}
Way to use:
omsg << packet_id;
// Works
omsg << packet_id << name;
// Getting invalid operands to binary expression basic_ostream<char, std::__1:char_traits<char> > and FString
//oo uint8
std::ostream& operator<<( std::ostream & s, uint8& c )
{
s.write( reinterpret_cast<const char*>(&c), sizeof(c) );
return s;
}
std::istream& operator>>( std::istream & s, uint8& c )
{
s.read( reinterpret_cast<char*>(&c), sizeof(c) );
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment