Ejemplo n.º 1
0
bool BFCPMsgFloorQuery::ParseAttributes(JSONParser &parser)
{
	do {
		// Get key name.
		if (! parser.ParseJSONString()) {
			::Error("BFCPMsgFloorQuery::ParseAttributes() | failed to parse JSON key\n");
			goto error;
		}

		enum BFCPAttribute::Name attribute = BFCPAttribute::mapJsonStr2Name[parser.GetValue()];

		if (! parser.ParseDoubleDot()) {
			::Error("BFCPMsgFloorQuery::ParseAttributes() | failed to parse ':'\n");
			goto error;
		}

		switch(attribute) {
			case BFCPAttribute::FloorId:
				if (! parser.ParseJSONArrayStart()) {
					::Error("BFCPMsgFloorQuery::ParseAttributes() | failed to parse 'floorId' array start\n");
					goto error;
				}
				if (parser.ParseJSONArrayEnd())
					break;

				do {
					if (! parser.ParseJSONNumber()) {
						::Error("BFCPMsgFloorQuery::ParseAttributes() | failed to parse 'floorId' value in the array\n");
						goto error;
					}

					int floorId = (int)parser.GetNumberValue();
					::Debug("BFCPMsgFloorQuery::ParseAttributes() | attribute 'floorId' found\n");
					AddFloorId(floorId);
				} while (parser.ParseComma());

				if (! parser.ParseJSONArrayEnd()) {
					::Error("BFCPMsgFloorQuery::ParseAttributes() | failed to parse 'floorId' array end\n");
					goto error;
				}
				break;

			default:
				::Debug("BFCPMsgFloorQuery::ParseAttributes() | skiping unknown key\n");
				parser.SkipJSONValue();
				break;
		}
	} while (parser.ParseComma());

	::Debug("BFCPMsgFloorQuery::ParseAttributes() | exiting attributes object\n");
	return true;

error:
	return false;
}
Ejemplo n.º 2
0
bool BFCPMsgFloorRelease::ParseAttributes(JSONParser &parser)
{
	do {
		// Get key name.
		if (! parser.ParseJSONString()) {
			::Error("BFCPMsgFloorRelease::ParseAttributes() | failed to parse JSON key\n");
			goto error;
		}

		enum BFCPAttribute::Name attribute = BFCPAttribute::mapJsonStr2Name[parser.GetValue()];
		//::Log("BFCPMsgFloorRelease::ParseAttributes() | BFCPAttribute::Name attribute: %d\n", attribute);

		if (! parser.ParseDoubleDot()) {
			::Error("BFCPMsgFloorRelease::ParseAttributes() | failed to parse ':'\n");
			goto error;
		}

		switch(attribute) {
			case BFCPAttribute::FloorRequestId:
				if (! parser.ParseJSONNumber()) {
					::Error("BFCPMsgFloorRequest::ParseAttributes() | failed to parse 'floorRequestId'\n");
					goto error;
				}

				::Debug("BFCPMsgFloorRequest::ParseAttributes() | attribute 'floorRequestId' found\n");
				SetFloorRequestId((int)parser.GetNumberValue());
				break;

			default:
				::Debug("BFCPMsgFloorRelease::ParseAttributes() | skiping unknown key\n");
				parser.SkipJSONValue();
				break;
		}
	} while (parser.ParseComma());

	::Debug("BFCPMsgFloorRelease::ParseAttributes() | exiting attributes object\n");
	return true;

error:
	return false;
}