MCPcopy Create free account
hub / github.com/Norbyte/ositools / setString

Method setString

OsiInterface/PropertyMap.h:283–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281 }
282
283 bool setString(void * obj, std::string const & name, char const * value, bool raw, bool throwError) const
284 {
285 auto prop = Properties.find(name);
286 if (prop == Properties.end()) {
287 if (Parent != nullptr) {
288 return Parent->setString(toParent(obj), name, value, raw, throwError);
289 } else {
290 if (throwError) {
291 OsiError("Failed to set string '" << name << "': Property does not exist");
292 }
293 return false;
294 }
295 }
296
297 if (!raw && prop->second.SetString) {
298 return prop->second.SetString(obj, value);
299 }
300
301 if (!raw && !(prop->second.Flags & kPropWrite)) {
302 OsiError("Failed to set string '" << name << "': Property not writeable");
303 return false;
304 }
305
306 auto ptr = reinterpret_cast<std::uintptr_t>(obj) + prop->second.Offset;
307 if (prop->second.Type == PropertyType::kFixedString) {
308 auto fs = ToFixedString(value);
309 if (!fs) {
310 OsiError("Failed to set string '" << name << "': Could not map to FixedString");
311 return false;
312 } else {
313 *reinterpret_cast<FixedString *>(ptr) = fs;
314 return true;
315 }
316 } else {
317 OsiError("Failed to set property '" << name << "': Property is not a string");
318 return false;
319 }
320 }
321
322 std::optional<ObjectHandle> getHandle(void * obj, std::string const & name, bool raw, bool throwError) const
323 {

Callers 2

OsirisPropertyMapSetRawFunction · 0.80
SetStringMethod · 0.80

Calls 2

ToFixedStringFunction · 0.85
SetStringMethod · 0.45

Tested by

no test coverage detected