20#define LIBCARLA_THROW_INVALID_VALUE(message) throw_exception(InvalidAttributeValue(GetId() + ": " + message));
25#define LIBCARLA_THROW_BAD_VALUE_CAST(type) \
26 if (GetType()!= rpc::ActorAttributeType:: type) { \
27 throw_exception(BadAttributeCast(GetId() + ": bad attribute cast: cannot convert to " #type)); \
62 if (value ==
"true") {
66 else if (value ==
"false") {
83 return std::atoi(
GetValue().c_str());
93 double x = std::atof(
GetValue().c_str());
96 if ((x > std::numeric_limits<float>::max()) ||
97 (x < std::numeric_limits<float>::lowest())) {
101 return static_cast<float>(x);
105 std::string ActorAttributeValueAccess::As<std::string>()
const {
120 std::vector<std::string> channels;
127 if (channels.size()!= 3u) {
135 auto to_int = [
this](
const std::string &str) {
136 int i = std::atoi(str.c_str());
137 if (i > std::numeric_limits<uint8_t>::max()) {
140 return static_cast<uint8_t
>(i);
144 return {to_int(channels[0u]), to_int(channels[1u]), to_int(channels[2u])};
168#undef LIBCARLA_THROW_BAD_VALUE_CAST
169#undef LIBCARLA_THROW_INVALID_VALUE
#define LIBCARLA_THROW_BAD_VALUE_CAST(type)
#define LIBCARLA_THROW_INVALID_VALUE(message)
static void Split(Container &destination, const Range1T &str, const Range2T &separators)
static auto ToLowerCopy(const SequenceT &str)
static void ToLower(WritableRangeT &str)
virtual const std::string & GetValue() const =0
virtual rpc::ActorAttributeType GetType() const =0
void Set(std::string value)
设置这个属性值
rpc::ActorAttribute _attribute
virtual rpc::ActorAttributeType GetType() const override
auto ActorAttributeValueAccess::As< rpc::ActorAttributeType::String >() const
auto ActorAttributeValueAccess::As< rpc::ActorAttributeType::Bool >() const
auto ActorAttributeValueAccess::As< rpc::ActorAttributeType::RGBColor >() const
auto ActorAttributeValueAccess::As< rpc::ActorAttributeType::Float >() const
auto ActorAttributeValueAccess::As< rpc::ActorAttributeType::Int >() const
static void log_error(Args &&... args)