当前位置: 首页>>代码示例>>C++>>正文


C++ Storage::size方法代码示例

本文整理汇总了C++中tcpip::Storage::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Storage::size方法的具体用法?C++ Storage::size怎么用?C++ Storage::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tcpip::Storage的用法示例。


在下文中一共展示了Storage::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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";
		}
}
开发者ID:vincent10,项目名称:ovnis,代码行数:58,代码来源:query.cpp

示例2:

void
TraCIServer::writeResponseWithLength(tcpip::Storage& outputStorage, tcpip::Storage& tempMsg) {
    if (tempMsg.size() < 254) {
        outputStorage.writeUnsignedByte(1 + (int)tempMsg.size()); // command length -> short
    } else {
        outputStorage.writeUnsignedByte(0); // command length -> extended
        outputStorage.writeInt(1 + 4 + (int)tempMsg.size());
    }
    outputStorage.writeStorage(tempMsg);
}
开发者ID:harora,项目名称:ITS,代码行数:10,代码来源:TraCIServer.cpp

示例3: 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;
//	}
}
开发者ID:vincent10,项目名称:ovnis,代码行数:41,代码来源:query.cpp

示例4: 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;
	}
}
开发者ID:vincent10,项目名称:ovnis,代码行数:6,代码来源:query.cpp


注:本文中的tcpip::Storage::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。