inline void load(iarchive& iarc) {
   /*
    * The old datetime representation is simply 56 bits for the timestamp
    * and 8 bits for the timezone at 1/2 hour increments, and no microsecond.
    * for a total of 64 bits.
    *
    * To ensure backward compatibility, we have to some tricks.
    *  - We shift the timezone value to EXCLUDE the timezone range the old
    *  format allowed.  (this will be [-24, 24] since at 1/2 hour offsets,
    *  24 is the maximum value possible).
    *
    *  This allows us to simply by inspection of the 
    *  timezone value, determine if it was an old format or a new format 
    *  timezone.
    *
    * - So to deserialize, we first deserialize 8 bytes, check the timezone
    *   value, to determine if it is old format or new format. If it is new
    *   format, deserialize a further 4 bytes. 
    *
    *   If it is old format, scale up the timezone value by 2 (to get it to
    *   15 minute increments, and clear the microsecond value.
    */
   iarc.read(reinterpret_cast<char*>(this), 8);
   if (m_tz_15min_offset > - _LEGACY_TIMEZONE_SHIFT && 
       m_tz_15min_offset < _LEGACY_TIMEZONE_SHIFT
       ) {
     // old format
     set_time_zone_offset(m_tz_15min_offset * 2);
     m_microsecond = 0;
   } else {
     // new format
     iarc.read(reinterpret_cast<char*>(&m_microsecond), sizeof(m_microsecond));
   }
 } 
Пример #2
0
	/**
	 * Deserialize the LIST(Vendor_IE) data type.
	 *
	 * @param ar The archive from where deserialize the data type.
	 */
	void serialize(iarchive& ar)
	{
		base::clear();

		while (ar.position() < ar.length()) {
			base::resize(base::size() + 1);
			vendor_ie& ie = base::back();

			if (!ie.serialize(ar)) {
				base::resize(base::size() - 1);
				return;
			}
		}
	}
Пример #3
0
	/**
	 * Deserialize the Vendor_IE data type.
	 *
	 * @param ar The archive from where deserialize the data type.
	 */
	bool serialize(iarchive& ar)
	{
		uint32 type;
		uint   pos = ar.position();
		uint   len;

		ar & type;
		if (!is_vendor_ie(type)) {
			ar.position(pos);
			return false;
		}

		ar & len;
		_data.size(len);
		std::copy(ar.current(), ar.current() + len, _data.get());
		ar.advance(len);

		return true;
	}
Пример #4
0
	/**
	 * Deserialize the IR_BIN_DATA data type.
	 *
	 * @param ar The archive from where deserialize the data type.
	 */
	void serialize(iarchive& ar)
	{
		_cnt = ar.list_length();

		_ar.clear();
		for (uint i = 0; i < _cnt; ++i) {
			uint pos;
			uint end;

			pos = ar.position();
			ar.position(pos + 4);
			end = ar.list_length();
			end += ar.position();
			_ar.append(ar.begin() + pos, ar.begin() + end);
			ar.position(end);
		}
	}
Пример #5
0
void unity_sgraph::load(iarchive& iarc) {
  log_func_entry();
  std::lock_guard<mutex> lock(dag_access_mutex);
  char buf[256] = "";
  size_t magic_header_size = strlen(GRAPH_MAGIC_HEADER);
  iarc.read(buf, magic_header_size);
  if (strcmp(buf, GRAPH_MAGIC_HEADER)) {
    log_and_throw(std::string("Invalid graph file."));
  }
  size_t num_partitions = 0;
  iarc >> num_partitions;
  sgraph* g = new sgraph(num_partitions);
  iarc >> *g;
  m_graph.reset(unity_sgraph::get_dag()->add_value(g));
}