Пример #1
0
ScripMasterDataRequest::ScripMasterDataRequest(const char * buf)
{
  int offset = 0;
  UNSIGNED_INTEGER tmpInt1 = 0, tmpInt2 = 0;
  UNSIGNED_CHARACTER tmpChar = 0;
  UNSIGNED_LONG tmpLong1 = 0, tmpLong2 = 0;
  UNSIGNED_SHORT tmpShort1 = 0, tmpShort2 = 0;
  
  DESERIALIZE_8(tmpChar, setScripMasterDataRequestType(tmpChar), buf, offset);
  DESERIALIZE_32(tmpInt1, tmpInt2, setClientId(tmpInt2), buf, offset);
  DESERIALIZE_64(tmpLong1, tmpLong2, setRecordNumber(tmpLong2), buf, offset);
  DESERIALIZE_64(tmpLong1, tmpLong2, setSecurityId(tmpLong2), buf, offset);
  DESERIALIZE_64(tmpLong1, tmpLong2, setSymbolId(tmpLong2), buf, offset);
  DESERIALIZE_16(tmpShort1, tmpShort2, setExchangeId(tmpShort2), buf, offset);

  setSymbol(strdup(buf + offset));
  offset += SYMBOL_SIZE;
  setSeries(strdup(buf + offset));
  offset += SERIES_SIZE;
  setMarketName(strdup(buf + offset));
  offset += MARKET_NAME_SIZE;
  DESERIALIZE_8(tmpChar, setOptionType(tmpChar), buf, offset);
  DESERIALIZE_8(tmpChar, setOptionMode(tmpChar), buf, offset);
  DESERIALIZE_8(tmpChar, setSecurityType(tmpChar), buf, offset);
  DESERIALIZE_64(tmpLong1, tmpLong2, setStrikePrice(tmpLong2), buf, offset);
  DESERIALIZE_32(tmpInt1, tmpInt2, setExpiryYearMon(tmpInt2), buf, offset);
  DESERIALIZE_32(tmpInt1, tmpInt2, setExpiryDate(tmpInt2), buf, offset);
  DESERIALIZE_32(tmpInt1, tmpInt2, setNumberOfRecords(tmpInt2), buf, offset);
  setSymbolAlias(strdup(buf + offset));
  offset += SYMBOL_ALIAS_SIZE;

}
Пример #2
0
	size_type DataPage::deleteSingleRecord(const DataPageCursor& cursor)
	{
		const uint16_t numberOfRecords = getNumberOfRecords();
		RAISE_INTERNAL_ERROR_IF_ARG(numberOfRecords == 0);
		RAISE_INTERNAL_ERROR_IF_ARG(! cursor.isValid());

		const size_type recordInlineSize = (cursor.isInlineValue())? 
			  cursor.recordOverheadSize() + static_cast<size_type>(cursor.inlineValue().size())	// inline value - overhead + value size
			: cursor.recordOverheadSize() + (2 * sizeof(uint32_t));								// big value - overhead + data size (4) + page pointer (4)

		if (cursor.index() < numberOfRecords - 1) {
			// Generic case: existing records and record pointers must be moved.
			const size_type endOfFreeArea = getEndOfFreeArea();

			const size_type movedBytes = getRecordOffsetAt(cursor.index()) - endOfFreeArea;
			const size_type newEndOfFreeArea = endOfFreeArea + recordInlineSize;

			// Move rest of the data to fill the hole.
			moveBytes(newEndOfFreeArea, endOfFreeArea, movedBytes);

			// Adjust record pointers.
			for (uint16_t i = cursor.index() + 1; i < numberOfRecords; ++i) {
				const size_type newOffset = getRecordOffsetAt(i) + recordInlineSize;
				setRecordOffsetAt(i - 1, newOffset);
			}

			setEndOfFreeArea(newEndOfFreeArea);
		}
		else {
			// Special case: adjust the end of free area when deleting the last item.
			const uint32_t newEndOfFreeArea = (numberOfRecords == 1)? size() : getRecordOffsetAt(cursor.index() - 1);
			setEndOfFreeArea(newEndOfFreeArea);
		}
		setNumberOfRecords(numberOfRecords - 1);

		return recordInlineSize;
	}
Пример #3
0
	void DataPage::addRecordOffset(size_type keyOffset)
	{
		const uint16_t numberOfRecords = getNumberOfRecords();
		setRecordOffsetAt(numberOfRecords, keyOffset);
		setNumberOfRecords(numberOfRecords + 1);
	}