7 #include "cmdDefines.h"
9 #include <serializeCommands.h>
15 using namespace Serialization;
21 CREATE_FIELD(std::string, String);
32 virtual void serializeFun(
char *buf,
int &bytes)=0;
39 virtual void deSerializeFun(
const char *buf,
int &offset)=0;
44 virtual void dump()=0;
49 virtual std::string getKeyValueString()=0;
55 virtual void printType() = 0;
63 setString(stringType);
81 CREATE_FIELD( T, Value);
82 CREATE_FIELD( UNSIGNED_INTEGER, Count );
108 std::cout<<
"\n typename "<<
typeid(_Value).name()<<std::endl;
118 serialize(_Value, buf, bytes);
128 printf(
"calling deSerialize in main \n");
129 deSerialize(_Value, buf, offset);
140 const MapULong &mapULong,
144 UNSIGNED_LONG tmpLong = 0;
145 for(MapULongIter i= mapULong.begin(); i!= mapULong.end(); i++)
147 Serialization::serialize(i->first,buf,bytes);
148 Serialization::serialize(i->second,buf,bytes);
162 UNSIGNED_LONG tmp1,tmp2= 0;
163 for(
int i=0; i<getCount();i++)
167 Serialization::deSerialize(key,buf,offset);
168 Serialization::deSerialize(value,buf,offset);
182 char *buf,
int &bytes)
184 Serialization::serialize(value,buf,bytes);
196 Serialization::deSerialize(val,buf,offset);
205 std::cout<<getKeyValueStringImpl(getValue());
212 return getKeyValueStringImpl(getValue());
222 std::ostringstream out;
223 out << std::endl << getString() <<
"--->"<< val;
228 std::ostringstream out;
229 out << std::endl << getString() <<
"--->"<< val.dump();
239 std::ostringstream out;
240 out << std::endl << getString() <<
"--->"<< (short)val;
250 std::ostringstream out;
251 out << std::endl << getString() <<
"--->"<< (short)val;
261 std::ostringstream out;
262 out <<
"========" << std::endl << getString() <<
"========";
263 for(MapULongIter iter = _Value.begin(); iter != _Value.end(); iter ++)
265 out << std::endl << iter->first <<
"--->"<< iter->second;
273 typedef std::vector<BaseType *> BaseTypeVector;
284 CREATE_FIELD_DERIVED( UNSIGNED_LONG, StrategyVersion);
289 CREATE_FIELD_DERIVED( UNSIGNED_CHARACTER, TransactionType);
294 CREATE_FIELD_DERIVED( UNSIGNED_INTEGER, ClientId);
299 CREATE_FIELD_DERIVED( UNSIGNED_INTEGER, StrategyId);
304 CREATE_FIELD_DERIVED( UNSIGNED_LONG, AdminTokenId);
309 CREATE_FIELD_DERIVED( UNSIGNED_LONG, SequenceNumber);
314 BaseTypeVector _Members;
331 SET_DERIVED_TYPE( StrategyVersion, 0);
332 SET_DERIVED_TYPE( TransactionType, 0);
333 SET_DERIVED_TYPE( ClientId, 0);
334 SET_DERIVED_TYPE( StrategyId, 0);
335 SET_DERIVED_TYPE( AdminTokenId, 0);
336 SET_DERIVED_TYPE( SequenceNumber, 0);
347 int serialize(
char *buf,
bool isResponse, UNSIGNED_CHARACTER cat, UNSIGNED_CHARACTER comCat)
351 bytes =
sizeof(UNSIGNED_SHORT);
354 Serialization::serialize(cat,buf,bytes);
358 Serialization::serialize(comCat,buf,bytes);
361 for(
int i=0; i<(int)_Members.size(); i++)
364 _Members[i]->serializeFun(buf,bytes);
371 Serialization::serialize((UNSIGNED_SHORT)(bytes-
sizeof(UNSIGNED_SHORT)),buf,dummyBytes);
387 UNSIGNED_CHARACTER cat,
388 UNSIGNED_CHARACTER comCat,
393 bytes =
sizeof(UNSIGNED_SHORT);
396 Serialization::serialize(cat,buf,bytes);
400 Serialization::serialize(comCat,buf,bytes);
403 Serialization::serialize(apiIndex,buf,bytes);
404 for(
int i=0; i<(int)_Members.size(); i++)
407 _Members[i]->serializeFun(buf,bytes);
414 Serialization::serialize((UNSIGNED_SHORT)(bytes-
sizeof(UNSIGNED_SHORT)),buf,dummyBytes);
428 for(
int i=0; i<(int)_Members.size(); i++)
431 _Members[i]->deSerializeFun(buf,offset);
441 _Members.push_back(type);
449 std::cout << std::endl<<
"SG_DUMP. Total Params:" <<_Members.size()<<std::endl;
450 std::cout << std::endl<<
"===============================" <<std::endl;
452 for(
int i=0; i<(int)_Members.size(); i++)
459 std::string getString()
461 std::ostringstream out;
462 out << std::endl<<
"SG_DUMP. Total Params:" <<_Members.size()<<std::endl;
463 out << std::endl<<
"===============================" <<std::endl;
465 for(
int i=0; i<(int)_Members.size(); i++)
467 out<<_Members[i]->getKeyValueString();
472 void writeToFile(FILE *fp)
474 char strategyCommandBuffer[MAX_BUF_SIZE];
475 int strategyBytes = serialize((
char *)strategyCommandBuffer,
false,0,0);
476 fwrite((
void*)strategyCommandBuffer,strategyBytes, 1, fp);
479 int getSerializeSize()
481 char strategyCommandBuffer[MAX_BUF_SIZE];
482 int strategyBytes = serialize(strategyCommandBuffer,
false,0,0);
483 return strategyBytes;
485 void deSerializeMemorySize(
const char *buff)
488 UNSIGNED_CHARACTER tmp2;
490 Serialization::deSerialize(tmp1, buff, offset);
491 Serialization::deSerialize(tmp2,buff,offset);
492 deSerialize(buff + offset);
501 #endif // BASECOMMANDS_H
void addType(BaseType *type)
addType
Definition: baseCommands.h:439
std::string getKeyValueStringImpl(const MapULong &val)
getKeyValueStringImpl
Definition: baseCommands.h:259
void deSerialize(MapULong &val, const char *buf, int &offset)
deSerialize
Definition: baseCommands.h:160
int serialize(char *buf, bool isResponse, UNSIGNED_CHARACTER cat, UNSIGNED_CHARACTER comCat)
serialize
Definition: baseCommands.h:347
void printType()
printType
Definition: baseCommands.h:106
void deSerialize(const char *buf)
deSerialize
Definition: baseCommands.h:423
std::string getKeyValueString()
getKeyValueString
Definition: baseCommands.h:210
void deSerializeFun(const char *buf, int &offset)
deSerializeFun
Definition: baseCommands.h:126
int serializeApi(char *buf, bool isResponse, UNSIGNED_CHARACTER cat, UNSIGNED_CHARACTER comCat, int apiIndex)
serializeApi
Definition: baseCommands.h:385
Definition: sharedCommands.h:23
std::string getKeyValueStringImpl(const M &val)
getKeyValueStringImpl
Definition: baseCommands.h:220
AbstractUserParams()
AbstractUserParams.
Definition: baseCommands.h:320
std::string getKeyValueStringImpl(const char &val)
getKeyValueStringImpl
Definition: baseCommands.h:237
virtual void initialize()
initialize
Definition: baseCommands.h:328
DerivedType()
DerivedType.
Definition: baseCommands.h:101
The AbstractUserParams class.
Definition: baseCommands.h:278
void serialize(const M &value, char *buf, int &bytes)
serialize
Definition: baseCommands.h:181
BaseType()
BaseType.
Definition: baseCommands.h:69
BaseType(const std::string &stringType)
BaseType.
Definition: baseCommands.h:61
void dump()
dump
Definition: baseCommands.h:447
void dump()
dump
Definition: baseCommands.h:203
std::string getKeyValueStringImpl(const UNSIGNED_CHARACTER &val)
getKeyValueStringImpl
Definition: baseCommands.h:248
The BaseType class.
Definition: baseCommands.h:19
The DerivedType class.
Definition: baseCommands.h:79
DerivedType(const std::string &type)
DerivedType.
Definition: baseCommands.h:91
void serializeFun(char *buf, int &bytes)
serializeFun
Definition: baseCommands.h:116
void deSerialize(M &val, const char *buf, int &offset)
deSerialize
Definition: baseCommands.h:194
void serialize(const MapULong &mapULong, char *buf, int &bytes)
serialize
Definition: baseCommands.h:139