You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#ifndef WEBCC_SOAP_PARAMETER_H_
|
|
#define WEBCC_SOAP_PARAMETER_H_
|
|
|
|
#include <string>
|
|
|
|
#include "webcc/globals.h" // for COPY_ASSIGN_MOVE_DEFAULT
|
|
|
|
namespace webcc {
|
|
|
|
// Key-value SOAP parameter.
|
|
class SoapParameter {
|
|
public:
|
|
SoapParameter() : as_cdata_(false) {
|
|
}
|
|
|
|
SoapParameter(const SoapParameter&) = default;
|
|
SoapParameter& operator=(const SoapParameter&) = default;
|
|
|
|
SoapParameter(const std::string& key, const char* value)
|
|
: key_(key), value_(value),
|
|
as_cdata_(false) {
|
|
}
|
|
|
|
SoapParameter(const std::string& key, const std::string& value,
|
|
bool as_cdata = false)
|
|
: key_(key), value_(value), as_cdata_(as_cdata) {
|
|
}
|
|
|
|
SoapParameter(const std::string& key, std::string&& value,
|
|
bool as_cdata = false)
|
|
: key_(key), value_(std::move(value)), as_cdata_(as_cdata) {
|
|
}
|
|
|
|
SoapParameter(const std::string& key, int value)
|
|
: key_(key), value_(std::to_string(value)),
|
|
as_cdata_(false) {
|
|
}
|
|
|
|
SoapParameter(const std::string& key, double value)
|
|
: key_(key), value_(std::to_string(value)),
|
|
as_cdata_(false) {
|
|
}
|
|
|
|
SoapParameter(const std::string& key, bool value)
|
|
: key_(key), value_(value ? "true" : "false"),
|
|
as_cdata_(false) {
|
|
}
|
|
|
|
SoapParameter(SoapParameter&&) = default;
|
|
SoapParameter& operator=(SoapParameter&&) = default;
|
|
|
|
const std::string& key() const { return key_; }
|
|
const std::string& value() const { return value_; }
|
|
|
|
const char* c_key() const { return key_.c_str(); }
|
|
const char* c_value() const { return value_.c_str(); }
|
|
|
|
bool as_cdata() const { return as_cdata_; }
|
|
|
|
private:
|
|
std::string key_;
|
|
std::string value_;
|
|
bool as_cdata_;
|
|
};
|
|
|
|
} // namespace webcc
|
|
|
|
#endif // WEBCC_SOAP_PARAMETER_H_
|