|
SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
|
A platform-neutral list of values, used to exchange data between client and server. More...
#include <SFSArray.h>
Public Member Functions | |
| bool | isNull (size_t index) const |
| Tells if the value at the given position is a null value. | |
| bool | removeElement (size_t index) |
| Removes the value at the given position. | |
| size_t | size () const |
| std::unique_ptr< ByteBuffer > | toBinary () const |
| std::string | getDump () const |
| std::string | getDump (bool noFormat) const |
| std::string | getHexDump () const |
| std::optional< bool > | getBool (size_t index) const |
| std::optional< uint8_t > | getByte (size_t index) const |
| std::optional< int16_t > | getShort (size_t index) const |
| std::optional< int32_t > | getInt (size_t index) const |
| std::optional< int64_t > | getLong (size_t index) const |
| std::optional< float > | getFloat (size_t index) const |
| std::optional< double > | getDouble (size_t index) const |
| std::optional< std::string > | getShortString (size_t index) const |
| Reads a UTF-8 string of at most 255 bytes. | |
| std::optional< std::string > | getString (size_t index) const |
| Reads a UTF-8 string of at most 32767 bytes. | |
| std::optional< std::string > | getText (size_t index) const |
| Reads a UTF-8 string of at most 2 GB. | |
| std::optional< SFSVector2 > | getVector2 (size_t index) const |
| std::optional< SFSVector3 > | getVector3 (size_t index) const |
| std::optional< std::vector< bool > > | getBoolArray (size_t index) const |
| std::optional< std::vector< uint8_t > > | getByteArray (size_t index) const |
| const std::vector< uint8_t > * | getByteArrayPtr (size_t index) const |
| Reads an array of bytes without copying it. | |
| std::optional< std::vector< int16_t > > | getShortArray (size_t index) const |
| std::optional< std::vector< int32_t > > | getIntArray (size_t index) const |
| std::optional< std::vector< int64_t > > | getLongArray (size_t index) const |
| std::optional< std::vector< float > > | getFloatArray (size_t index) const |
| std::optional< std::vector< double > > | getDoubleArray (size_t index) const |
| std::optional< std::vector< std::string > > | getStringArray (size_t index) const |
| Reads an array of UTF-8 strings, each one of at most 32767 bytes. | |
| std::optional< std::vector< std::string > > | getShortStringArray (size_t index) const |
| Reads an array of UTF-8 strings, each one of at most 255 bytes. | |
| std::optional< std::vector< SFSVector2 > > | getVector2Array (size_t index) const |
| std::optional< std::vector< SFSVector3 > > | getVector3Array (size_t index) const |
| std::shared_ptr< SFSObject > | getSFSObject (size_t index) const |
| std::shared_ptr< SFSArray > | getSFSArray (size_t index) const |
| void | addNull () |
| Appends a null value. | |
| void | addBool (bool value) |
| Appends a boolean. | |
| void | addByte (uint8_t value) |
| Appends a byte (8 bit). | |
| void | addShort (int16_t value) |
| Appends a short (signed 16 bit). | |
| void | addInt (int32_t value) |
| Appends an integer (signed 32 bit). | |
| void | addLong (int64_t value) |
| Appends a long (signed 64 bit). | |
| void | addFloat (float value) |
| Appends a float (signed 32 bit). | |
| void | addDouble (double value) |
| Appends a double (signed 64 bit). | |
| void | addString (std::string value) |
| Appends a UTF-8 string, with a limit of 32767 bytes. | |
| void | addShortString (std::string value) |
| Appends a UTF-8 string, with a limit of 255 bytes. | |
| void | addText (std::string value) |
| Appends a UTF-8 string, with a limit of 2 GB. | |
| void | addVector2 (SFSVector2 value) |
| Appends a 2D vector. | |
| void | addVector3 (SFSVector3 value) |
| Appends a 3D vector. | |
| void | addBoolArray (std::vector< bool > value) |
| Appends an array of booleans. | |
| void | addByteArray (std::vector< uint8_t > value) |
| Appends an array of bytes. | |
| void | addByteArray (const uint8_t *data, size_t length) |
| Appends an array of bytes read from raw memory. | |
| void | addShortArray (std::vector< int16_t > value) |
| Appends an array of shorts. | |
| void | addIntArray (std::vector< int32_t > value) |
| Appends an array of integers. | |
| void | addLongArray (std::vector< int64_t > value) |
| Appends an array of longs. | |
| void | addFloatArray (std::vector< float > value) |
| Appends an array of floats. | |
| void | addDoubleArray (std::vector< double > value) |
| Appends an array of doubles. | |
| void | addShortStringArray (std::vector< std::string > value) |
| Appends an array of UTF-8 strings, each one limited to 255 bytes. | |
| void | addStringArray (std::vector< std::string > value) |
| Appends an array of UTF-8 strings, each one limited to 32767 bytes. | |
| void | addVector2Array (std::vector< SFSVector2 > value) |
| Appends an array of 2D vectors. | |
| void | addVector3Array (std::vector< SFSVector3 > value) |
| Appends an array of 3D vectors. | |
| void | addSFSObject (std::shared_ptr< SFSObject > value) |
| Appends a nested SFSObject. | |
| void | addSFSArray (std::shared_ptr< SFSArray > value) |
| Appends a nested SFSArray. | |
A platform-neutral list of values, used to exchange data between client and server.
It is the list counterpart of SFSObject, and it carries the same data types with the same size limits. Read the description of SFSObject for the full table of types and for the notes on strings, nesting and thread safety.
Every getter takes the position of the value in the list, counted from zero.
| bool sfs3::entities::SFSArray::isNull | ( | size_t | index | ) | const |
Tells if the value at the given position is a null value.
| index | the position of the value |
| bool sfs3::entities::SFSArray::removeElement | ( | size_t | index | ) |
Removes the value at the given position.
| index | the position of the value to remove |
|
inline |
| std::unique_ptr< ByteBuffer > sfs3::entities::SFSArray::toBinary | ( | ) | const |
| std::string sfs3::entities::SFSArray::getDump | ( | ) | const |
| std::string sfs3::entities::SFSArray::getDump | ( | bool | noFormat | ) | const |
| noFormat | if true the dump is not pretty-printed |
| std::string sfs3::entities::SFSArray::getHexDump | ( | ) | const |
| std::optional< bool > sfs3::entities::SFSArray::getBool | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< uint8_t > sfs3::entities::SFSArray::getByte | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< int16_t > sfs3::entities::SFSArray::getShort | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< int32_t > sfs3::entities::SFSArray::getInt | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< int64_t > sfs3::entities::SFSArray::getLong | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< float > sfs3::entities::SFSArray::getFloat | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< double > sfs3::entities::SFSArray::getDouble | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::string > sfs3::entities::SFSArray::getShortString | ( | size_t | index | ) | const |
Reads a UTF-8 string of at most 255 bytes.
| index | the position of the value |
| std::optional< std::string > sfs3::entities::SFSArray::getString | ( | size_t | index | ) | const |
Reads a UTF-8 string of at most 32767 bytes.
| index | the position of the value |
| std::optional< std::string > sfs3::entities::SFSArray::getText | ( | size_t | index | ) | const |
Reads a UTF-8 string of at most 2 GB.
| index | the position of the value |
| std::optional< SFSVector2 > sfs3::entities::SFSArray::getVector2 | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< SFSVector3 > sfs3::entities::SFSArray::getVector3 | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< bool > > sfs3::entities::SFSArray::getBoolArray | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< uint8_t > > sfs3::entities::SFSArray::getByteArray | ( | size_t | index | ) | const |
| index | the position of the value |
| const std::vector< uint8_t > * sfs3::entities::SFSArray::getByteArrayPtr | ( | size_t | index | ) | const |
Reads an array of bytes without copying it.
Use it in place of SFSArray::getByteArray for a large array. The pointer stays valid as long as this array holds the value and is not changed.
| index | the position of the value |
nullptr if there is no such value | std::optional< std::vector< int16_t > > sfs3::entities::SFSArray::getShortArray | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< int32_t > > sfs3::entities::SFSArray::getIntArray | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< int64_t > > sfs3::entities::SFSArray::getLongArray | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< float > > sfs3::entities::SFSArray::getFloatArray | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< double > > sfs3::entities::SFSArray::getDoubleArray | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< std::string > > sfs3::entities::SFSArray::getStringArray | ( | size_t | index | ) | const |
Reads an array of UTF-8 strings, each one of at most 32767 bytes.
| index | the position of the value |
| std::optional< std::vector< std::string > > sfs3::entities::SFSArray::getShortStringArray | ( | size_t | index | ) | const |
Reads an array of UTF-8 strings, each one of at most 255 bytes.
| index | the position of the value |
| std::optional< std::vector< SFSVector2 > > sfs3::entities::SFSArray::getVector2Array | ( | size_t | index | ) | const |
| index | the position of the value |
| std::optional< std::vector< SFSVector3 > > sfs3::entities::SFSArray::getVector3Array | ( | size_t | index | ) | const |
| index | the position of the value |
| std::shared_ptr< SFSObject > sfs3::entities::SFSArray::getSFSObject | ( | size_t | index | ) | const |
| std::shared_ptr< SFSArray > sfs3::entities::SFSArray::getSFSArray | ( | size_t | index | ) | const |
| index | the position of the value |
nullptr if there is no such value | void sfs3::entities::SFSArray::addNull | ( | ) |
Appends a null value.
We recommend that you simply do not send a value that is null. This method adds one byte that marks the null value, so it makes the message bigger for nothing.
| void sfs3::entities::SFSArray::addBool | ( | bool | value | ) |
Appends a boolean.
| value | the value |
| void sfs3::entities::SFSArray::addByte | ( | uint8_t | value | ) |
Appends a byte (8 bit).
| value | the value |
| void sfs3::entities::SFSArray::addShort | ( | int16_t | value | ) |
Appends a short (signed 16 bit).
| value | the value |
| void sfs3::entities::SFSArray::addInt | ( | int32_t | value | ) |
Appends an integer (signed 32 bit).
| value | the value |
| void sfs3::entities::SFSArray::addLong | ( | int64_t | value | ) |
Appends a long (signed 64 bit).
| value | the value |
| void sfs3::entities::SFSArray::addFloat | ( | float | value | ) |
Appends a float (signed 32 bit).
| value | the value |
| void sfs3::entities::SFSArray::addDouble | ( | double | value | ) |
Appends a double (signed 64 bit).
| value | the value |
| void sfs3::entities::SFSArray::addString | ( | std::string | value | ) |
Appends a UTF-8 string, with a limit of 32767 bytes.
| value | the value |
| void sfs3::entities::SFSArray::addShortString | ( | std::string | value | ) |
Appends a UTF-8 string, with a limit of 255 bytes.
| value | the value |
| void sfs3::entities::SFSArray::addText | ( | std::string | value | ) |
Appends a UTF-8 string, with a limit of 2 GB.
| value | the value |
| void sfs3::entities::SFSArray::addVector2 | ( | SFSVector2 | value | ) |
Appends a 2D vector.
| value | the value |
| void sfs3::entities::SFSArray::addVector3 | ( | SFSVector3 | value | ) |
Appends a 3D vector.
| value | the value |
| void sfs3::entities::SFSArray::addBoolArray | ( | std::vector< bool > | value | ) |
Appends an array of booleans.
| value | the value |
| void sfs3::entities::SFSArray::addByteArray | ( | std::vector< uint8_t > | value | ) |
Appends an array of bytes.
| value | the value |
| void sfs3::entities::SFSArray::addByteArray | ( | const uint8_t * | data, |
| size_t | length ) |
Appends an array of bytes read from raw memory.
The bytes are copied, so the caller keeps the ownership of the memory it passes.
| data | the first byte to copy |
| length | how many bytes to copy |
| void sfs3::entities::SFSArray::addShortArray | ( | std::vector< int16_t > | value | ) |
Appends an array of shorts.
| value | the value |
| void sfs3::entities::SFSArray::addIntArray | ( | std::vector< int32_t > | value | ) |
Appends an array of integers.
| value | the value |
| void sfs3::entities::SFSArray::addLongArray | ( | std::vector< int64_t > | value | ) |
Appends an array of longs.
| value | the value |
| void sfs3::entities::SFSArray::addFloatArray | ( | std::vector< float > | value | ) |
Appends an array of floats.
| value | the value |
| void sfs3::entities::SFSArray::addDoubleArray | ( | std::vector< double > | value | ) |
Appends an array of doubles.
| value | the value |
| void sfs3::entities::SFSArray::addShortStringArray | ( | std::vector< std::string > | value | ) |
Appends an array of UTF-8 strings, each one limited to 255 bytes.
The array itself is limited to 32767 strings.
| value | the value |
| void sfs3::entities::SFSArray::addStringArray | ( | std::vector< std::string > | value | ) |
Appends an array of UTF-8 strings, each one limited to 32767 bytes.
The array itself is limited to 32767 strings.
| value | the value |
| void sfs3::entities::SFSArray::addVector2Array | ( | std::vector< SFSVector2 > | value | ) |
Appends an array of 2D vectors.
| value | the value |
| void sfs3::entities::SFSArray::addVector3Array | ( | std::vector< SFSVector3 > | value | ) |
Appends an array of 3D vectors.
| value | the value |
| void sfs3::entities::SFSArray::addSFSObject | ( | std::shared_ptr< SFSObject > | value | ) |
| void sfs3::entities::SFSArray::addSFSArray | ( | std::shared_ptr< SFSArray > | value | ) |
Appends a nested SFSArray.
| value | the value |