diff --git a/include/amqpcpp/fieldproxy.h b/include/amqpcpp/fieldproxy.h index 91ab004..388a641 100644 --- a/include/amqpcpp/fieldproxy.h +++ b/include/amqpcpp/fieldproxy.h @@ -2,7 +2,7 @@ * Field proxy. Returned by the table. Can be casted to the * relevant native type (std::string or numeric) * - * @copyright 2014 Copernica BV + * @copyright 2014 - 2024 Copernica BV */ /** @@ -207,6 +207,22 @@ public: return *this; } + /** + * Assign a string value + * + * @param value + * @return FieldProxy + */ + FieldProxy &operator=(const std::string_view &value) + { + // in theory we should make a distinction between short and long string, + // but in practive only long strings are accepted + _source->set(_index, LongString(value)); + + // allow chaining + return *this; + } + /** * Assign a string value * diff --git a/include/amqpcpp/table.h b/include/amqpcpp/table.h index 7e669cd..df5eff8 100644 --- a/include/amqpcpp/table.h +++ b/include/amqpcpp/table.h @@ -138,6 +138,7 @@ public: Table &set(const std::string &name, uint64_t value) { return set(name, ULongLong(value)); } Table &set(const std::string &name, int64_t value) { return set(name, LongLong(value)); } Table &set(const std::string &name, const std::string &value) { return set(name, LongString(value)); } + Table &set(const std::string &name, const std::string_view &value) { return set(name, LongString(value)); } 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()); }