| 215 | } |
| 216 | |
| 217 | bool setFloat(void * obj, std::string const & name, float value, bool raw, bool throwError) const |
| 218 | { |
| 219 | auto prop = Properties.find(name); |
| 220 | if (prop == Properties.end()) { |
| 221 | if (Parent != nullptr) { |
| 222 | return Parent->setFloat(toParent(obj), name, value, raw, throwError); |
| 223 | } else { |
| 224 | if (throwError) { |
| 225 | OsiError("Failed to set float '" << name << "': Property does not exist"); |
| 226 | } |
| 227 | return false; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | if (!raw && prop->second.SetFloat) { |
| 232 | return prop->second.SetFloat(obj, value); |
| 233 | } |
| 234 | |
| 235 | if (!raw && !(prop->second.Flags & kPropWrite)) { |
| 236 | OsiError("Failed to set float '" << name << "': Property not writeable"); |
| 237 | return false; |
| 238 | } |
| 239 | |
| 240 | auto ptr = reinterpret_cast<std::uintptr_t>(obj) + prop->second.Offset; |
| 241 | switch (prop->second.Type) { |
| 242 | case PropertyType::kFloat: *reinterpret_cast<float *>(ptr) = value; break; |
| 243 | default: |
| 244 | OsiError("Failed to set property '" << name << "': Property is not a float"); |
| 245 | return false; |
| 246 | } |
| 247 | |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | std::optional<char const *> getString(void * obj, std::string const & name, bool raw, bool throwError) const |
| 252 | { |
no outgoing calls
no test coverage detected