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.
70 lines
1.5 KiB
C
70 lines
1.5 KiB
C
![]()
8 years ago
|
#ifndef CSOAP_COMMON_H_
|
||
|
#define CSOAP_COMMON_H_
|
||
|
|
||
|
// Common definitions.
|
||
|
|
||
|
#include <string>
|
||
|
#include "boost/lexical_cast.hpp"
|
||
|
|
||
|
namespace csoap {
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
// Wrapper for boost::lexcical_cast.
|
||
|
// Usage:
|
||
|
// LexicalCast<int>("123", 0);
|
||
|
// LexicalCast<std::string>(123, "");
|
||
|
template <typename To, typename From>
|
||
|
To LexicalCast(const From& input, const To& default_output) {
|
||
|
try {
|
||
|
return boost::lexical_cast<To>(input);
|
||
|
} catch (boost::bad_lexical_cast&) {
|
||
|
return default_output;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
// XML namespace name/url pair.
|
||
|
// E.g., { "soapenv", "http://schemas.xmlsoap.org/soap/envelope/" }
|
||
|
class Namespace {
|
||
|
public:
|
||
|
std::string name;
|
||
|
std::string url;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
// Parameter in the SOAP request envelope.
|
||
|
class Parameter {
|
||
|
public:
|
||
|
Parameter(const std::string& key, const std::string& value);
|
||
|
Parameter(const std::string& key, int value);
|
||
|
Parameter(const std::string& key, float value);
|
||
|
Parameter(const std::string& key, bool value);
|
||
|
|
||
|
const char* c_key() const {
|
||
|
return key_.c_str();
|
||
|
}
|
||
|
|
||
|
const std::string& key() const {
|
||
|
return key_;
|
||
|
}
|
||
|
|
||
|
const char* c_value() const {
|
||
|
return value_.c_str();
|
||
|
}
|
||
|
|
||
|
const std::string& value() const {
|
||
|
return value_;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
std::string key_;
|
||
|
std::string value_;
|
||
|
};
|
||
|
|
||
|
} // namespace csoap
|
||
|
|
||
|
#endif // CSOAP_COMMON_H_
|