Skip to content

Commit

Permalink
support removal of properties from a message header
Browse files Browse the repository at this point in the history
  • Loading branch information
EmielBruijntjes committed Apr 12, 2023
1 parent 40456bb commit 9413c9d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/amqpcpp/libev.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Compile with: "g++ -std=c++11 libev.cpp -lamqpcpp -lev -lpthread"
*
* @author Emiel Bruijntjes <[email protected]>
* @copyright 2015 - 2018 Copernica BV
* @copyright 2015 - 2023 Copernica BV
*/

/**
Expand Down
18 changes: 18 additions & 0 deletions include/amqpcpp/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ class MetaData
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
Expand Down
12 changes: 11 additions & 1 deletion include/amqpcpp/numericfield.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Numeric field types for AMQP
*
* @copyright 2014 - 2020 Copernica BV
* @copyright 2014 - 2023 Copernica BV
*/

/**
Expand Down Expand Up @@ -112,6 +112,16 @@ class NumericField : public Field
_value = value;
return *this;
};

/**
* Clear the field
* @return NumericField
*/
NumericField& clear()
{
_value = 0;
return *this;
}

/**
* Get the value
Expand Down
13 changes: 13 additions & 0 deletions include/amqpcpp/stringfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ class StringField : public Field
// allow chaining
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
Expand Down
12 changes: 11 additions & 1 deletion include/amqpcpp/table.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* AMQP field table
*
* @copyright 2014 - 2020 Copernica BV
* @copyright 2014 - 2023 Copernica BV
*/

/**
Expand Down Expand Up @@ -141,6 +141,16 @@ class Table : public Field
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
Expand Down

0 comments on commit 9413c9d

Please sign in to comment.