Example #1
0
bool
get_message_timestamp ( pn_message_t * msg, double * timestamp )
{
  pn_data_t * annotations = pn_message_annotations ( msg );
  pn_data_rewind ( annotations );
  pn_data_next   ( annotations );
  if ( PN_MAP == pn_data_type ( annotations ) )
  {
    int len = pn_data_get_map ( annotations );
    pn_data_enter ( annotations );
    for (int i = 0; i < len; i += 2 ) 
    {
      pn_data_next ( annotations );
      pn_type_t type = pn_data_type ( annotations );
      if ( PN_STRING == type ) 
      {
        pn_bytes_t string = pn_data_get_symbol ( annotations );
        if ( ! strncmp ( "timestamp", string.start, string.size ) )
        {
          pn_data_next ( annotations );
          type = pn_data_type ( annotations );
          if ( type == PN_DOUBLE )
          {
            * timestamp = pn_data_get_double ( annotations );
            return true;
          }
        }
      }
    }
  }

  return false;
}
Example #2
0
void DataReader::readMap(pn_data_t* data, const qpid::amqp::Descriptor* descriptor)
{
    size_t count = pn_data_get_map(data);
    reader.onStartMap(count, qpid::amqp::CharSequence(), descriptor);
    pn_data_enter(data);
    for (size_t i = 0; i < count && pn_data_next(data); ++i) {
        read(data);
    }
    pn_data_exit(data);
    reader.onEndMap(count, descriptor);
}