Esempio n. 1
0
size_t MessageEncoder::getEncodedSize(const Properties& p, const qpid::types::Variant::Map& ap, const std::string& d)
{
    size_t total(getEncodedSize(p));
    //application-properties:
    total += 3/*descriptor*/ + getEncodedSize(ap, true);
    //body:
    if (d.size()) total += 3/*descriptor*/ + 1/*code*/ + encodedSize(d);

    return total;
}
Esempio n. 2
0
size_t MessageEncoder::getEncodedSizeForValue(const qpid::types::Variant& value)
{
    size_t total = 0;
    switch (value.getType()) {
      case qpid::types::VAR_MAP:
        total += getEncodedSize(value.asMap(), true);
        break;
      case qpid::types::VAR_LIST:
        total += getEncodedSize(value.asList(), true);
        break;

      case qpid::types::VAR_VOID:
      case qpid::types::VAR_BOOL:
        total += 1;
        break;

      case qpid::types::VAR_UINT8:
      case qpid::types::VAR_INT8:
        total += 2;
        break;

      case qpid::types::VAR_UINT16:
      case qpid::types::VAR_INT16:
        total += 3;
        break;

      case qpid::types::VAR_UINT32:
      case qpid::types::VAR_INT32:
      case qpid::types::VAR_FLOAT:
        total += 5;
        break;

      case qpid::types::VAR_UINT64:
      case qpid::types::VAR_INT64:
      case qpid::types::VAR_DOUBLE:
        total += 9;
        break;

      case qpid::types::VAR_UUID:
        total += 17;
        break;

      case qpid::types::VAR_STRING:
        total += 1/*code*/ + encodedSize(value.getString());
        break;
    }
    return total;
}
Esempio n. 3
0
size_t MessageEncoder::getEncodedSize(const Properties& p, const qpid::types::Variant::Map& ap, const std::string& d)
{
    //NOTE: this does not take optional optimisation into account,
    //i.e. it is a 'worst case' estimate for required buffer space
    size_t total(0);

    //properties:
    total += 3/*descriptor*/ + 1/*code*/ + 4/*size*/ + 4/*count*/ + 13/*codes for each field*/;
    if (p.hasMessageId()) total += encodedSize(p.getMessageId());
    if (p.hasUserId()) total += encodedSize(p.getUserId());
    if (p.hasTo()) total += encodedSize(p.getTo());
    if (p.hasSubject()) total += encodedSize(p.getSubject());
    if (p.hasReplyTo()) total += encodedSize(p.getReplyTo());
    if (p.hasCorrelationId()) total += encodedSize(p.getCorrelationId());
    if (p.hasContentType()) total += encodedSize(p.getContentType());
    if (p.hasContentEncoding()) total += encodedSize(p.getContentEncoding());
    if (p.hasAbsoluteExpiryTime()) total += 8;
    if (p.hasCreationTime()) total += 8;
    if (p.hasGroupId()) total += encodedSize(p.getGroupId());
    if (p.hasGroupSequence()) total += 4;
    if (p.hasReplyToGroupId()) total += encodedSize(p.getReplyToGroupId());


    //application-properties:
    total += 3/*descriptor*/ + getEncodedSize(ap, true);
    //body:
    if (d.size()) total += 3/*descriptor*/ + 1/*code*/ + encodedSize(d);

    return total;
}
Esempio n. 4
0
void NdefMessage::print()
{
    Serial.print(F("\nNDEF Message "));Serial.print(_recordCount);Serial.print(F(" record"));
    _recordCount == 1 ? Serial.print(", ") : Serial.print("s, ");
    Serial.print(getEncodedSize());Serial.println(F(" bytes"));

    int i;
    for (i = 0; i < _recordCount; i++)
    {
         _records[i].print();
    }
}
Esempio n. 5
0
size_t MessageEncoder::getEncodedSize(const Header& h, const Properties& p, const qpid::types::Variant::Map& ap, const std::string& d)
{
    //NOTE: this does not take optional optimisation into account,
    //i.e. it is a 'worst case' estimate for required buffer space
    size_t total(0);

    //header:
    total += 3/*descriptor*/ + 1/*code*/ + 1/*size*/ + 1/*count*/ + 5/*codes for each field*/;
    if (h.getPriority() != 4) total += 1;
    if (h.getDeliveryCount()) total += 4;
    if (h.hasTtl()) total += 4;
    return total + getEncodedSize(p, ap, d);
}
Esempio n. 6
0
void NdefRecord::print()
{
    Serial.println(F("  NDEF Record"));    
    Serial.print(F("    TNF 0x"));Serial.print(_tnf, HEX);Serial.print(" ");
    switch (_tnf) {
    case TNF_EMPTY:
        Serial.println(F("Empty"));
        break; 
    case TNF_WELL_KNOWN:
        Serial.println(F("Well Known"));
        break;     
    case TNF_MIME_MEDIA:
        Serial.println(F("Mime Media"));
        break;     
    case TNF_ABSOLUTE_URI:
        Serial.println(F("Absolute URI"));
        break;     
    case TNF_EXTERNAL_TYPE:
        Serial.println(F("External"));
        break;     
    case TNF_UNKNOWN:
        Serial.println(F("Unknown"));
        break;     
    case TNF_UNCHANGED:
        Serial.println(F("Unchanged"));
        break;     
    case TNF_RESERVED:
        Serial.println(F("Reserved"));
        break;
    default:
        Serial.println();     
    }
    Serial.print(F("    Type Length 0x"));Serial.print(_typeLength, HEX);Serial.print(" ");Serial.println(_typeLength);
    Serial.print(F("    Payload Length 0x"));Serial.print(_payloadLength, HEX);;Serial.print(" ");Serial.println(_payloadLength);    
    if (_idLength)
    {
        Serial.print(F("    Id Length 0x"));Serial.println(_idLength, HEX);  
    }
    Serial.print(F("    Type "));PrintHexChar(_type, _typeLength);  
    // TODO chunk large payloads so this is readable
    Serial.print(F("    Payload "));PrintHexChar(_payload, _payloadLength);
    if (_idLength)
    {
        Serial.print(F("    Id "));PrintHexChar(_id, _idLength);  
    }
    Serial.print(F("    Record is "));Serial.print(getEncodedSize());Serial.println(" bytes");

}
Esempio n. 7
0
void MapSizeCalculator::handleKey(const CharSequence& key)
{
    ++count;
    size += getEncodedSize(key);
}
Esempio n. 8
0
void MapSizeCalculator::handleString(const CharSequence& key, const CharSequence& value, const CharSequence& /*encoding*/)
{
    handleKey(key);
    size += getEncodedSize(value);
}
Esempio n. 9
0
size_t MessageEncoder::getEncodedSize(const Header& h, const Properties& p, const ApplicationProperties& ap, const std::string& d)
{
    return getEncodedSize(h) + getEncodedSize(p) + getEncodedSize(ap) + getEncodedSizeForContent(d);
}
Esempio n. 10
0
size_t MessageEncoder::getEncodedSize(const Header& h, const Properties& p, const qpid::types::Variant::Map& ap, const std::string& d)
{
    return getEncodedSize(h) + getEncodedSize(p, ap, d);
}