support removal of properties from a message header

This commit is contained in:
Emiel Bruijntjes 2023-04-12 08:25:00 +02:00
parent 40456bbffb
commit 9413c9d7aa
5 changed files with 54 additions and 3 deletions

View File

@ -8,7 +8,7 @@
* Compile with: "g++ -std=c++11 libev.cpp -lamqpcpp -lev -lpthread"
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2015 - 2018 Copernica BV
* @copyright 2015 - 2023 Copernica BV
*/
/**

View File

@ -273,6 +273,24 @@ public:
void setTypeName (const char *value) { _typeName.assign(value); _bools2.set(5,true); }
void setMessageID (const char *value) { _messageID.assign(value); _bools2.set(7,true); }
/**
* Methods to remove properties from the header
*/
void removeExpiration () { _expiration .clear(); _bools1.set(0,false); }
void removeReplyTo () { _replyTo .clear(); _bools1.set(1,false); }
void removeCorrelationID () { _correlationID .clear(); _bools1.set(2,false); }
void removePriority () { _priority .clear(); _bools1.set(3,false); }
void removeDeliveryMode () { _deliveryMode .clear(); _bools1.set(4,false); }
void removeHeaders () { _headers .clear(); _bools1.set(5,false); }
void removeContentEncoding () { _contentEncoding.clear(); _bools1.set(6,false); }
void removeContentType () { _contentType .clear(); _bools1.set(7,false); }
void removeClusterID () { _clusterID .clear(); _bools2.set(2,false); }
void removeAppID () { _appID .clear(); _bools2.set(3,false); }
void removeUserID () { _userID .clear(); _bools2.set(4,false); }
void removeTypeName () { _typeName .clear(); _bools2.set(5,false); }
void removeTimestamp () { _timestamp .clear(); _bools2.set(6,false); }
void removeMessageID () { _messageID .clear(); _bools2.set(7,false); }
/**
* Retrieve the fields
* @return string

View File

@ -1,7 +1,7 @@
/**
* Numeric field types for AMQP
*
* @copyright 2014 - 2020 Copernica BV
* @copyright 2014 - 2023 Copernica BV
*/
/**
@ -113,6 +113,16 @@ public:
return *this;
};
/**
* Clear the field
* @return NumericField
*/
NumericField& clear()
{
_value = 0;
return *this;
}
/**
* Get the value
* @return mixed

View File

@ -195,6 +195,19 @@ public:
return *this;
}
/**
* Make the field empty
* @return StringField
*/
StringField &clear()
{
// clear internal dta
_data.clear();
// allow chaining
return *this;
}
/**
* Get the size this field will take when
* encoded in the AMQP wire-frame format

View File

@ -1,7 +1,7 @@
/**
* AMQP field table
*
* @copyright 2014 - 2020 Copernica BV
* @copyright 2014 - 2023 Copernica BV
*/
/**
@ -141,6 +141,16 @@ public:
Table &set(const std::string &name, const char *value) { return set(name, LongString(std::string(value))); }
Table &set(const std::string &name, std::nullptr_t) { return set(name, VoidField()); }
/**
* Clear the entire table
* @return Table
*/
Table &clear()
{
_fields.clear();
return *this;
}
/**
* Is a certain field set in the table
* @param name