diff --git a/external/3rd/library/platform/utils/Base/Archive.h b/external/3rd/library/platform/utils/Base/Archive.h index 0a0a162d..c461f4d7 100644 --- a/external/3rd/library/platform/utils/Base/Archive.h +++ b/external/3rd/library/platform/utils/Base/Archive.h @@ -569,7 +569,7 @@ const unsigned MAX_ARRAY_SIZE = 1024; template void AutoVariable::pack(ByteStream & target) const { - Base::put(target, value); + put(target, value); } template @@ -581,7 +581,8 @@ const unsigned MAX_ARRAY_SIZE = 1024; template void AutoVariable::unpack(ByteStream::ReadIterator & source) { - Base::get(source, value); + using Base::get; + get(source, value); } @@ -644,7 +645,7 @@ const unsigned MAX_ARRAY_SIZE = 1024; for(i = array.begin(); i != array.end(); ++i) { ValueType v = (*i); - Base::put(target, v); + put(target, v); } } @@ -658,9 +659,10 @@ const unsigned MAX_ARRAY_SIZE = 1024; if (arraySize > MAX_ARRAY_SIZE) arraySize = 0; + using Base::get; for(unsigned int i = 0; i < arraySize; ++i) { - Base::get(source, v); + get(source, v); array.push_back(v); } } diff --git a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h index 352ad06f..856dcd95 100644 --- a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h +++ b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h @@ -321,6 +321,171 @@ const unsigned MAX_ARRAY_SIZE = 1024; } +//////////////////////////////////////////////////////////////////////////////// + + + inline void get(ByteStream::ReadIterator & source, ByteStream & target) + { + target.put(source.getBuffer(), source.getSize()); + source.advance(source.getSize()); + } + + inline void get(ByteStream::ReadIterator & source, double & target) + { + source.get(&target, 8); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, float & target) + { + source.get(&target, 4); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint64 & target) + { + source.get(&target, 8); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, int64 & target) + { + source.get(&target, 8); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint32 & target) + { + source.get(&target, 4); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, int32 & target) + { + source.get(&target, 4); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint16 & target) + { + source.get(&target, 2); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, int16 & target) + { + source.get(&target, 2); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint8 & target) + { + source.get(&target, 1); + } + + inline void get(ByteStream::ReadIterator & source, int8 & target) + { + source.get(&target, 1); + } + + inline void get(ByteStream::ReadIterator & source, unsigned char * const target, const unsigned int targetSize) + { + source.get(target, targetSize); + } + + inline void get(ByteStream::ReadIterator & source, bool & target) + { + source.get(&target, 1); + } + + +//////////////////////////////////////////////////////////////////////////////// + + + inline void put(ByteStream & target, ByteStream::ReadIterator & source) + { + target.put(source.getBuffer(), source.getSize()); + source.advance(source.getSize()); + } + + inline void put(ByteStream & target, const double value) + { + double temp = byteSwap(value); + target.put(&temp, 8); + } + + inline void put(ByteStream & target, const float value) + { + float temp = byteSwap(value); + target.put(&temp, 4); + } + + inline void put(ByteStream & target, const uint64 value) + { + uint64 temp = byteSwap(value); + target.put(&temp, 8); + } + + inline void put(ByteStream & target, const int64 value) + { + int64 temp = byteSwap(value); + target.put(&temp, 8); + } + + inline void put(ByteStream & target, const uint32 value) + { + uint32 temp = byteSwap(value); + target.put(&temp, 4); + } + + inline void put(ByteStream & target, const int32 value) + { + int32 temp = byteSwap(value); + target.put(&temp, 4); + } + + inline void put(ByteStream & target, const uint16 value) + { + uint16 temp = byteSwap(value); + target.put(&temp, 2); + } + + inline void put(ByteStream & target, const int16 value) + { + int16 temp = byteSwap(value); + target.put(&temp, 2); + } + + inline void put(ByteStream & target, const uint8 value) + { + target.put(&value, 1); + } + + inline void put(ByteStream & target, const int8 value) + { + target.put(&value, 1); + } + + inline void put(ByteStream & target, const bool & source) + { + target.put(&source, 1); + } + + + inline void put(ByteStream & target, const unsigned char * const source, const unsigned int sourceSize) + { + target.put(source, sourceSize); + } + + inline void put(ByteStream & target, const ByteStream & source) + { + target.put(source.begin().getBuffer(), source.begin().getSize()); + } + + void get(ByteStream::ReadIterator & source, std::string & target); + void put(ByteStream & target, const std::string & source); + + //////////////////////////////////////////////////////////////////////////////// @@ -499,171 +664,6 @@ const unsigned MAX_ARRAY_SIZE = 1024; } -//////////////////////////////////////////////////////////////////////////////// - - - inline void get(ByteStream::ReadIterator & source, ByteStream & target) - { - target.put(source.getBuffer(), source.getSize()); - source.advance(source.getSize()); - } - - inline void get(ByteStream::ReadIterator & source, double & target) - { - source.get(&target, 8); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, float & target) - { - source.get(&target, 4); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint64 & target) - { - source.get(&target, 8); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, int64 & target) - { - source.get(&target, 8); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint32 & target) - { - source.get(&target, 4); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, int32 & target) - { - source.get(&target, 4); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint16 & target) - { - source.get(&target, 2); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, int16 & target) - { - source.get(&target, 2); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint8 & target) - { - source.get(&target, 1); - } - - inline void get(ByteStream::ReadIterator & source, int8 & target) - { - source.get(&target, 1); - } - - inline void get(ByteStream::ReadIterator & source, unsigned char * const target, const unsigned int targetSize) - { - source.get(target, targetSize); - } - - inline void get(ByteStream::ReadIterator & source, bool & target) - { - source.get(&target, 1); - } - - -//////////////////////////////////////////////////////////////////////////////// - - - inline void put(ByteStream & target, ByteStream::ReadIterator & source) - { - target.put(source.getBuffer(), source.getSize()); - source.advance(source.getSize()); - } - - inline void put(ByteStream & target, const double value) - { - double temp = byteSwap(value); - target.put(&temp, 8); - } - - inline void put(ByteStream & target, const float value) - { - float temp = byteSwap(value); - target.put(&temp, 4); - } - - inline void put(ByteStream & target, const uint64 value) - { - uint64 temp = byteSwap(value); - target.put(&temp, 8); - } - - inline void put(ByteStream & target, const int64 value) - { - int64 temp = byteSwap(value); - target.put(&temp, 8); - } - - inline void put(ByteStream & target, const uint32 value) - { - uint32 temp = byteSwap(value); - target.put(&temp, 4); - } - - inline void put(ByteStream & target, const int32 value) - { - int32 temp = byteSwap(value); - target.put(&temp, 4); - } - - inline void put(ByteStream & target, const uint16 value) - { - uint16 temp = byteSwap(value); - target.put(&temp, 2); - } - - inline void put(ByteStream & target, const int16 value) - { - int16 temp = byteSwap(value); - target.put(&temp, 2); - } - - inline void put(ByteStream & target, const uint8 value) - { - target.put(&value, 1); - } - - inline void put(ByteStream & target, const int8 value) - { - target.put(&value, 1); - } - - inline void put(ByteStream & target, const bool & source) - { - target.put(&source, 1); - } - - - inline void put(ByteStream & target, const unsigned char * const source, const unsigned int sourceSize) - { - target.put(source, sourceSize); - } - - inline void put(ByteStream & target, const ByteStream & source) - { - target.put(source.begin().getBuffer(), source.begin().getSize()); - } - - void get(ByteStream::ReadIterator & source, std::string & target); - void put(ByteStream & target, const std::string & source); - - //////////////////////////////////////////////////////////////////////////////// diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h index d616b8ba..8e13f2c0 100644 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h +++ b/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h @@ -331,6 +331,171 @@ const unsigned MAX_ARRAY_SIZE = 1024; } +//////////////////////////////////////////////////////////////////////////////// + + + inline void get(ByteStream::ReadIterator & source, ByteStream & target) + { + target.put(source.getBuffer(), source.getSize()); + source.advance(source.getSize()); + } + + inline void get(ByteStream::ReadIterator & source, double & target) + { + source.get(&target, 8); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, float & target) + { + source.get(&target, 4); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint64 & target) + { + source.get(&target, 8); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, int64 & target) + { + source.get(&target, 8); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint32 & target) + { + source.get(&target, 4); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, int32 & target) + { + source.get(&target, 4); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint16 & target) + { + source.get(&target, 2); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, int16 & target) + { + source.get(&target, 2); + target = byteSwap(target); + } + + inline void get(ByteStream::ReadIterator & source, uint8 & target) + { + source.get(&target, 1); + } + + inline void get(ByteStream::ReadIterator & source, int8 & target) + { + source.get(&target, 1); + } + + inline unsigned get(ByteStream::ReadIterator & source, unsigned char * const target, const unsigned int targetSize) + { + return source.get(target, targetSize); + } + + inline void get(ByteStream::ReadIterator & source, bool & target) + { + source.get(&target, 1); + } + + +//////////////////////////////////////////////////////////////////////////////// + + + inline void put(ByteStream & target, ByteStream::ReadIterator & source) + { + target.put(source.getBuffer(), source.getSize()); + source.advance(source.getSize()); + } + + inline void put(ByteStream & target, const double value) + { + double temp = byteSwap(value); + target.put(&temp, 8); + } + + inline void put(ByteStream & target, const float value) + { + float temp = byteSwap(value); + target.put(&temp, 4); + } + + inline void put(ByteStream & target, const uint64 value) + { + uint64 temp = byteSwap(value); + target.put(&temp, 8); + } + + inline void put(ByteStream & target, const int64 value) + { + int64 temp = byteSwap(value); + target.put(&temp, 8); + } + + inline void put(ByteStream & target, const uint32 value) + { + uint32 temp = byteSwap(value); + target.put(&temp, 4); + } + + inline void put(ByteStream & target, const int32 value) + { + int32 temp = byteSwap(value); + target.put(&temp, 4); + } + + inline void put(ByteStream & target, const uint16 value) + { + uint16 temp = byteSwap(value); + target.put(&temp, 2); + } + + inline void put(ByteStream & target, const int16 value) + { + int16 temp = byteSwap(value); + target.put(&temp, 2); + } + + inline void put(ByteStream & target, const uint8 value) + { + target.put(&value, 1); + } + + inline void put(ByteStream & target, const int8 value) + { + target.put(&value, 1); + } + + inline void put(ByteStream & target, const bool & source) + { + target.put(&source, 1); + } + + + inline void put(ByteStream & target, const unsigned char * const source, const unsigned int sourceSize) + { + target.put(source, sourceSize); + } + + inline void put(ByteStream & target, const ByteStream & source) + { + target.put(source.begin().getBuffer(), source.begin().getSize()); + } + + unsigned get(ByteStream::ReadIterator & source, std::string & target); + void put(ByteStream & target, const std::string & source); + + //////////////////////////////////////////////////////////////////////////////// @@ -412,7 +577,7 @@ const unsigned MAX_ARRAY_SIZE = 1024; template void AutoVariable::pack(ByteStream & target) const { - Base::put(target, value); + put(target, value); } template @@ -424,7 +589,7 @@ const unsigned MAX_ARRAY_SIZE = 1024; template void AutoVariable::unpack(ByteStream::ReadIterator & source) { - Base::get(source, value); + get(source, value); } @@ -480,8 +645,9 @@ const unsigned MAX_ARRAY_SIZE = 1024; template inline void AutoArray::pack(ByteStream & target) const { + using Base::put; unsigned int arraySize = array.size(); - Base::put(target, arraySize); + put(target, arraySize); typename std::vector::const_iterator i; for(i = array.begin(); i != array.end(); ++i) @@ -509,171 +675,6 @@ const unsigned MAX_ARRAY_SIZE = 1024; } -//////////////////////////////////////////////////////////////////////////////// - - - inline void get(ByteStream::ReadIterator & source, ByteStream & target) - { - target.put(source.getBuffer(), source.getSize()); - source.advance(source.getSize()); - } - - inline void get(ByteStream::ReadIterator & source, double & target) - { - source.get(&target, 8); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, float & target) - { - source.get(&target, 4); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint64 & target) - { - source.get(&target, 8); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, int64 & target) - { - source.get(&target, 8); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint32 & target) - { - source.get(&target, 4); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, int32 & target) - { - source.get(&target, 4); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint16 & target) - { - source.get(&target, 2); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, int16 & target) - { - source.get(&target, 2); - target = byteSwap(target); - } - - inline void get(ByteStream::ReadIterator & source, uint8 & target) - { - source.get(&target, 1); - } - - inline void get(ByteStream::ReadIterator & source, int8 & target) - { - source.get(&target, 1); - } - - inline unsigned get(ByteStream::ReadIterator & source, unsigned char * const target, const unsigned int targetSize) - { - return source.get(target, targetSize); - } - - inline void get(ByteStream::ReadIterator & source, bool & target) - { - source.get(&target, 1); - } - - -//////////////////////////////////////////////////////////////////////////////// - - - inline void put(ByteStream & target, ByteStream::ReadIterator & source) - { - target.put(source.getBuffer(), source.getSize()); - source.advance(source.getSize()); - } - - inline void put(ByteStream & target, const double value) - { - double temp = byteSwap(value); - target.put(&temp, 8); - } - - inline void put(ByteStream & target, const float value) - { - float temp = byteSwap(value); - target.put(&temp, 4); - } - - inline void put(ByteStream & target, const uint64 value) - { - uint64 temp = byteSwap(value); - target.put(&temp, 8); - } - - inline void put(ByteStream & target, const int64 value) - { - int64 temp = byteSwap(value); - target.put(&temp, 8); - } - - inline void put(ByteStream & target, const uint32 value) - { - uint32 temp = byteSwap(value); - target.put(&temp, 4); - } - - inline void put(ByteStream & target, const int32 value) - { - int32 temp = byteSwap(value); - target.put(&temp, 4); - } - - inline void put(ByteStream & target, const uint16 value) - { - uint16 temp = byteSwap(value); - target.put(&temp, 2); - } - - inline void put(ByteStream & target, const int16 value) - { - int16 temp = byteSwap(value); - target.put(&temp, 2); - } - - inline void put(ByteStream & target, const uint8 value) - { - target.put(&value, 1); - } - - inline void put(ByteStream & target, const int8 value) - { - target.put(&value, 1); - } - - inline void put(ByteStream & target, const bool & source) - { - target.put(&source, 1); - } - - - inline void put(ByteStream & target, const unsigned char * const source, const unsigned int sourceSize) - { - target.put(source, sourceSize); - } - - inline void put(ByteStream & target, const ByteStream & source) - { - target.put(source.begin().getBuffer(), source.begin().getSize()); - } - - unsigned get(ByteStream::ReadIterator & source, std::string & target); - void put(ByteStream & target, const std::string & source); - - //////////////////////////////////////////////////////////////////////////////// diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/UnicodeUtils.h b/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/UnicodeUtils.h index 25bd89e8..a9c0c322 100644 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/UnicodeUtils.h +++ b/external/3rd/library/soePlatform/ChatAPI/utils/Unicode/UnicodeUtils.h @@ -64,7 +64,31 @@ namespace Plat_Unicode String & appendStringField (String & dst, const String & src, size_t width, FieldAlignment fa = FA_LEFT, unicode_char_t pad = ' ', bool truncate = false); String & appendStringField (String & dst, const NarrowString & src, size_t width, FieldAlignment fa = FA_LEFT, unicode_char_t pad = ' ', bool truncate = false); +// ====================================================================== + //----------------------------------------------------------------- + /** + * Hacky code to correctly handle Cyrillic. + */ + + inline unicode_char_t trueUpper(unicode_char_t letter) + { + if ((cyrillic_lower_first <= letter) && (letter <= cyrillic_lower_last)) { + return letter + (cyrillic_upper_first - cyrillic_lower_first); + } else { + return static_cast(toupper(letter)); + } + } + + inline unicode_char_t trueLower(unicode_char_t letter) + { + if ((cyrillic_upper_first <= letter) && (letter <= cyrillic_upper_last)) { + return letter - (cyrillic_upper_first - cyrillic_lower_first); + } else { + return static_cast(tolower(letter)); + } + } + /** * Compare substrings of str2 and str1, each starting with pos and containing n characters */ @@ -335,30 +359,6 @@ namespace Plat_Unicode { return appendStringField (dst, narrowToWide (src), width, fa, pad, truncate); } -// ====================================================================== - - //----------------------------------------------------------------- - /** - * Hacky code to correctly handle Cyrillic. - */ - - inline unicode_char_t trueUpper(unicode_char_t letter) - { - if ((cyrillic_lower_first <= letter) && (letter <= cyrillic_lower_last)) { - return letter + (cyrillic_upper_first - cyrillic_lower_first); - } else { - return static_cast(toupper(letter)); - } - } - - inline unicode_char_t trueLower(unicode_char_t letter) - { - if ((cyrillic_upper_first <= letter) && (letter <= cyrillic_upper_last)) { - return letter - (cyrillic_upper_first - cyrillic_lower_first); - } else { - return static_cast(tolower(letter)); - } - } // ====================================================================== }; diff --git a/external/3rd/library/soePlatform/VChatAPI/projects/VChat/VChatAPI/VChatAPITypes.h b/external/3rd/library/soePlatform/VChatAPI/projects/VChat/VChatAPI/VChatAPITypes.h index a7b0cbb9..5fe2adb2 100644 --- a/external/3rd/library/soePlatform/VChatAPI/projects/VChat/VChatAPI/VChatAPITypes.h +++ b/external/3rd/library/soePlatform/VChatAPI/projects/VChat/VChatAPI/VChatAPITypes.h @@ -40,7 +40,7 @@ namespace VChatSystem typedef unsigned ResultCode; - typedef enum ResultCode_t + enum ResultCode_t { RESULT_SUCCESS = 0, RESULT_TIMEOUT, @@ -109,7 +109,7 @@ namespace VChatSystem RESULT_END }; - typedef enum CommandType_t + enum CommandType_t { COMMAND_MUTE = 0, COMMAND_UNMUTE, @@ -130,13 +130,13 @@ namespace VChatSystem COMMAND_END }; - typedef enum ConnectionType + enum ConnectionType { CONNECTION_TYPE_UNKNOWN = 0, CONNECTION_TYPE_VHCAT_SYSTEM }; - typedef enum ChannelType + enum ChannelType { CHAN_TYPE_UNKNOWN = 0, CHAN_TYPE_DIR, @@ -144,7 +144,7 @@ namespace VChatSystem CHAN_TYPE_PROXIMITY }; - typedef enum BanStatus + enum BanStatus { BAN = 0, UNBAN diff --git a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Api/apiMessages.h b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Api/apiMessages.h index abe24836..ef733afb 100644 --- a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Api/apiMessages.h +++ b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Api/apiMessages.h @@ -5,7 +5,7 @@ #ifndef API_NAMESPACE #pragma message ("apiMessages.h: API_NAMESPACE undefined") -//#else +//#else //#pragma message ("apiMessages.h: API_NAMESPACE:") //#pragma message API_NAMESPACE #endif @@ -13,6 +13,7 @@ #include #include #include "Base/serializeClasses.h" +//#include "Base/serialize.h" #include "apiMacros.h" #include "apiTypeNameValuePair.h" @@ -38,7 +39,7 @@ namespace API_NAMESPACE MESSAGE_GET_CONFIGURATION = 0x0ff5, MESSAGE_SHUTDOWN_NOTIFY = 0x0f00, - + // Server Messages MESSAGE_CONNECT_REPLY = 0x7ff3, MESSAGE_GET_STATUS_REPLY = 0x7ff4, @@ -147,6 +148,90 @@ namespace API_NAMESPACE } #endif +namespace soe +{ + inline unsigned Write(unsigned char * stream, unsigned size, const API_NAMESPACE::Message::Base & data, unsigned version = 0) + { + unsigned written = 0; + unsigned writtenSize = Write(stream, size, written, version); + + if (writtenSize <= 0) { return 0; } + written = data.Write(stream + writtenSize, size - writtenSize, version); + if (written <= 0) { return 0; } + writtenSize = Write(stream, size, written, version); + + return (writtenSize + written); + } + + inline unsigned Read(const unsigned char * stream, unsigned size, API_NAMESPACE::Message::Base & data, unsigned, unsigned version = 0) + { + unsigned messageSize = 0; + unsigned readSize = Read(stream, size, messageSize, version); + unsigned readIn = 0; + + size -= readSize; + stream += readSize; + if (messageSize > size) { return 0; } + readIn = data.Read(stream, messageSize, version); + if (readIn <= 0) { return 0; } + + return (readSize + messageSize); + } + + inline unsigned Write(unsigned char * stream, unsigned size, const API_NAMESPACE::Message::Base::DeepPointer & data, unsigned version = 0) + { + API_NAMESPACE::Message::Base *msg = (API_NAMESPACE::Message::Base *)data; + + if (msg) { + return Write(stream, size, *msg, version); + } else { + return 0; + } + } + + inline unsigned Read(const unsigned char * stream, unsigned size, API_NAMESPACE::Message::Base::DeepPointer & data, unsigned, unsigned version = 0) + { + unsigned msgSize = 0; + unsigned msgId = 0; + unsigned sizeSize = Read(stream, size, msgSize, version); + unsigned idSize = (sizeSize > 0) ? Read(stream + sizeSize, size - sizeSize, msgId, version) : 0; + + if (idSize <= 0) { + return 0; + } + + data.SetMessageType(msgId); + + API_NAMESPACE::Message::Base *msg = data; + + if (msg) { + return Read(stream, size, *msg, 0, version); + } else { + return 0; + } + } + +#ifdef PRINTABLE_MESSAGES + inline int Print(char * stream, unsigned size, const API_NAMESPACE::Message::Base & data, unsigned maxDepth=INT_MAX) + { + return data.Print(stream, size, maxDepth); + + } + + inline int Print(char * stream, unsigned size, const API_NAMESPACE::Message::Base::DeepPointer & data, unsigned maxDepth=INT_MAX) + { + API_NAMESPACE::Message::Base *msg = (API_NAMESPACE::Message::Base *)data; + + if (msg) { + return Print(stream, size, *msg, maxDepth); + } else { + return 0; + } + } +#endif + +} + #include "Base/serializeTemplates.h" @@ -297,7 +382,7 @@ namespace API_NAMESPACE DefineMessageBegin(Connect, Basic, MESSAGE_CONNECT) DefineMessageMember(Version, std::string) DefineMessageMember(Description, std::string) - + DefineMessageEnd @@ -362,93 +447,30 @@ namespace API_NAMESPACE DECLSPEC void Read(soe::NameValuePair &dest, const Message::NameValuePair &src); DECLSPEC void Write(const soe::NameValuePair &src, Message::NameValuePair &dest); + #ifdef API_NAMESPACE } #endif -namespace soe -{ - inline unsigned Write(unsigned char * stream, unsigned size, const API_NAMESPACE::Message::Base & data, unsigned version = 0) - { - unsigned written = 0; - unsigned writtenSize = Write(stream, size, written, version); +namespace soe { - if (writtenSize <= 0) { return 0; } - written = data.Write(stream + writtenSize, size - writtenSize, version); - if (written <= 0) { return 0; } - writtenSize = Write(stream, size, written, version); + inline unsigned Read(const unsigned char * stream, unsigned size, API_NAMESPACE::Message::NameValuePair & data, unsigned maxLen, unsigned version = 0) + { + NameValuePair dest; + unsigned returnval = Read(stream, size, dest, maxLen, version); + API_NAMESPACE::Write(dest, data); - return (writtenSize + written); - } + return returnval; + } - inline unsigned Read(const unsigned char * stream, unsigned size, API_NAMESPACE::Message::Base & data, unsigned, unsigned version = 0) - { - unsigned messageSize = 0; - unsigned readSize = Read(stream, size, messageSize, version); - unsigned readIn = 0; + inline unsigned Write(unsigned char * stream, unsigned size, const API_NAMESPACE::Message::NameValuePair & data, unsigned version = 0) + { + NameValuePair dest; + API_NAMESPACE::Read(dest, data); - size -= readSize; - stream += readSize; - if (messageSize > size) { return 0; } - readIn = data.Read(stream, messageSize, version); - if (readIn <= 0) { return 0; } - - return (readSize + messageSize); - } - - inline unsigned Write(unsigned char * stream, unsigned size, const API_NAMESPACE::Message::Base::DeepPointer & data, unsigned version = 0) - { - API_NAMESPACE::Message::Base *msg = (API_NAMESPACE::Message::Base *)data; - - if (msg) { - return Write(stream, size, *msg, version); - } else { - return 0; - } - } - - inline unsigned Read(const unsigned char * stream, unsigned size, API_NAMESPACE::Message::Base::DeepPointer & data, unsigned, unsigned version = 0) - { - unsigned msgSize = 0; - unsigned msgId = 0; - unsigned sizeSize = Read(stream, size, msgSize, version); - unsigned idSize = (sizeSize > 0) ? Read(stream + sizeSize, size - sizeSize, msgId, version) : 0; - - if (idSize <= 0) { - return 0; - } - - data.SetMessageType(msgId); - - API_NAMESPACE::Message::Base *msg = data; - - if (msg) { - return Read(stream, size, *msg, 0, version); - } else { - return 0; - } - } - -#ifdef PRINTABLE_MESSAGES - inline int Print(char * stream, unsigned size, const API_NAMESPACE::Message::Base & data, unsigned maxDepth=INT_MAX) - { - return data.Print(stream, size, maxDepth); - - } - - inline int Print(char * stream, unsigned size, const API_NAMESPACE::Message::Base::DeepPointer & data, unsigned maxDepth=INT_MAX) - { - API_NAMESPACE::Message::Base *msg = (API_NAMESPACE::Message::Base *)data; - - if (msg) { - return Print(stream, size, *msg, maxDepth); - } else { - return 0; - } - } -#endif + return Write(stream, size, dest, version); + } } - //#endif //_API_MESSAGES_H