本文整理汇总了C++中tcpip::Storage::position方法的典型用法代码示例。如果您正苦于以下问题:C++ Storage::position方法的具体用法?C++ Storage::position怎么用?C++ Storage::position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcpip::Storage
的用法示例。
在下文中一共展示了Storage::position方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadGetResponse
void Query::ReadGetResponse(tcpip::Storage & content) {
int position = 0;
int length2 = 0;
int extLength = 0;
int length = 0;
int commandId = 0;
int varId = 0;
string objectId = "";
int variableType = 0;
try {
position = content.position();
length2 = content.size();
extLength = content.readUnsignedByte();
if (extLength == 0) {
length = content.readInt();
}
commandId = content.readUnsignedByte();
varId = content.readUnsignedByte();
objectId = content.readString();
variableType = content.readUnsignedByte();
int listLen = 0;
int count = 0;
switch (variableType) {
case TYPE_STRING:
stringValue = content.readString();
break;
case TYPE_INTEGER:
intValue = content.readInt();
break;
case TYPE_DOUBLE:
doubleValue = content.readDouble();
break;
case TYPE_STRINGLIST:
listLen = content.readInt();
stringListValue.clear();
for (int i=0; i<listLen; i++) {
stringListValue.push_back(content.readString());
}
break;
case POSITION_2D:
positionValue.x = content.readDouble();
positionValue.y = content.readDouble();
break;
case TYPE_BOUNDINGBOX:
count = content.size()/sizeof(double);
for (int i = 0; i < count-1; i++) {
vectorValue.push_back(content.readDouble());
}
break;
default:
break;
}
}
catch (exception & ex) {
cout << "can't read response for object " << objectId << ex.what() << endl;
cout<<position<<" "<<length2 << " "<<extLength<<" "<<length<<" "<<commandId<<" "<<varId<<" "<<objectId<<" "<<variableType<< "\n";
}
}
示例2: ReadSetResponse
void Query::ReadSetResponse(tcpip::Storage & content) {
// cout << endl << "Response to vehicle query: " << endl;
int pos = content.position();
cout << "pos: " << pos << endl;
int length = content.size();
cout << "length: " << length << endl;
// int length2 = content.readUnsignedByte();
// cout << "length: " << length2 << endl;
// int commandId = content.readUnsignedByte();
// cout << "command id : " << hex << commandId << endl;
// int varId = content.readUnsignedByte();
// cout << "variable id: " << hex << varId << endl;
// string vehicleId = content.readString();
// cout << "vehicle id: " << vehicleId << endl;
// int variableType = content.readUnsignedByte();
// cout << "type: " << variableType << endl;
// string variableStr;
// int variableInt;
// cout << "cmdid " << commandId;
// double variableDouble;
// switch (variableType) {
// case TYPE_STRING:
// variableStr = content.readString();
// break;
// case TYPE_INTEGER:
// variableInt = content.readInt();
// break;
// case TYPE_DOUBLE:
// variableDouble = content.readDouble();
// break;
// }
// // remember the result
// switch (varId) {
// case VAR_CURRENT_TRAVELTIME:
// travelTime = variableDouble;
// break;
// case VAR_EDGE_TRAVELTIME:
// travelTime = variableDouble;
// break;
// }
}
示例3: ReadRawResponse
void Query::ReadRawResponse(tcpip::Storage & content) {
cout << "Response content:" << endl;
for (int i = content.position(); i < content.size(); ++i) {
cout << "byte" << i << ": " << content.readUnsignedByte() << endl;
}
}