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

Method setInt

OsiInterface/PropertyMap.h:175–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173 }
174
175 bool setInt(void * obj, std::string const & name, int64_t value, bool raw, bool throwError) const
176 {
177 auto prop = Properties.find(name);
178 if (prop == Properties.end()) {
179 if (Parent != nullptr) {
180 return Parent->setInt(toParent(obj), name, value, raw, throwError);
181 } else {
182 if (throwError) {
183 OsiError("Failed to set int '" << name << "': Property does not exist");
184 }
185 return false;
186 }
187 }
188
189 if (!raw && prop->second.SetInt) {
190 return prop->second.SetInt(obj, value);
191 }
192
193 if (!raw && !(prop->second.Flags & kPropWrite)) {
194 OsiError("Failed to set int '" << name << "': Property not writeable");
195 return false;
196 }
197
198 auto ptr = reinterpret_cast<std::uintptr_t>(obj) + prop->second.Offset;
199 switch (prop->second.Type) {
200 case PropertyType::kBool: *reinterpret_cast<bool *>(ptr) = (bool)value; break;
201 case PropertyType::kUInt8: *reinterpret_cast<uint8_t *>(ptr) = (uint8_t)value; break;
202 case PropertyType::kInt16: *reinterpret_cast<int16_t *>(ptr) = (int16_t)value; break;
203 case PropertyType::kUInt16: *reinterpret_cast<uint16_t *>(ptr) = (uint16_t)value; break;
204 case PropertyType::kInt32: *reinterpret_cast<int32_t *>(ptr) = (int32_t)value; break;
205 case PropertyType::kUInt32: *reinterpret_cast<uint32_t *>(ptr) = (uint32_t)value; break;
206 case PropertyType::kInt64: *reinterpret_cast<int64_t *>(ptr) = (int64_t)value; break;
207 case PropertyType::kUInt64: *reinterpret_cast<uint64_t *>(ptr) = (uint64_t)value; break;
208 case PropertyType::kFloat: *reinterpret_cast<float *>(ptr) = (float)value; break;
209 default:
210 OsiError("Failed to set property '" << name << "': Property is not an int");
211 return false;
212 }
213
214 return true;
215 }
216
217 bool setFloat(void * obj, std::string const & name, float value, bool raw, bool throwError) const
218 {

Callers 3

OsirisPropertyMapSetRawFunction · 0.80
CharacterSetStatIntFunction · 0.80
SetIntMethod · 0.80

Calls 1

SetIntMethod · 0.45

Tested by

no test coverage detected