Value ResultRow::getValueByName(const std::string& field_name) const { unsigned fc = result->getFieldCount(); unsigned n; for (n = 0; n < fc; ++n) if (field_name == PQfname(getPGresult(), n)) break; if (n == fc) throw FieldNotFound(field_name); return getValueByNumber(n); }
void Object::setInt(std::string name, int value) { if ((Class::currentContext != this) && (!Class::accessEnabled)) throw FieldNotAccessible(); if(objectClass->staticIntFields.find(name) != objectClass->staticIntFields.end()) { objectClass->staticIntFields[name] = value; return; } if (intFields.find(name) == intFields.end()) throw FieldNotFound(); intFields[name] = value; }
void Object::setObj(std::string name, Object *value) { if (Class::currentContext != this && !Class::accessEnabled) throw FieldNotAccessible(); if(objectClass->staticObjectFields.find(name) != objectClass->staticObjectFields.end()) { objectClass->staticObjectFields[name] = value; return; } if (objectFields.find(name) == objectFields.end()) throw FieldNotFound(); objectFields[name] = value; }
Object* Object::getObj(std::string name) { Field field = this->getClass()->getField(name); if (field.getType() != OBJECT) { throw TypeError(); } if (field.isStatic()) { return this->getClass()->getObj(name); } std::map<std::string, Object*>::iterator iter = mIntObjectValues.find(name); if (iter == mIntObjectValues.end()) { throw FieldNotFound(); } if (!shimon_access) { if (this->shouldThrowAccess()) { throw FieldNotAccessible(); } } return iter->second; }
void Object::setInt(std::string name, int value) { Field field = this->getClass()->getField(name); if (field.getType() != INT) { throw TypeError(); } if (field.isStatic()) { this->getClass()->setInt(name, value); return; } std::map<std::string, int>::iterator iter = mIntFieldValues.find(name); if (iter == mIntFieldValues.end()) { throw FieldNotFound(); } if (!shimon_access) { if (this->shouldThrowAccess()) { throw FieldNotAccessible(); } } mIntFieldValues[name] = value; }
void Class::setObj(std::string name, Object *value) { if (staticObjectFields.find(name) == staticObjectFields.end()) throw FieldNotFound(); staticObjectFields[name] = value; }
Object *Class::getObj(std::string name) { if (staticObjectFields.find(name) == staticObjectFields.end()) throw FieldNotFound(); return staticObjectFields[name]; }
void Class::setInt(std::string name, int value) { if (staticIntFields.find(name) == staticIntFields.end()) throw FieldNotFound(); staticIntFields[name] = value; }
int Class::getInt(std::string name) { if (staticIntFields.find(name) == staticIntFields.end()) throw FieldNotFound(); return staticIntFields[name]; }
const Field &Map::walkableNear(int16_t &x, int16_t &y) const { auto startx = x; auto starty = y; unsigned char d = 0; while (d < 6) { x = startx - d; while (x <= startx + d) { try { const Field &field = at(x, d + starty); if (field.moveToPossible()) { y = d + starty; return field; } } catch (FieldNotFound &) { } try { const Field &field = at(x, starty - d); if (field.moveToPossible()) { y = starty - d; return field; } } catch (FieldNotFound &) { } x++; } y = starty - d; while (y <= d + starty) { try { const Field &field = at(d + startx, y); if (field.moveToPossible()) { x = d + startx; return field; } } catch (FieldNotFound &) { } try { const Field &field = at(startx - d, y); if (field.moveToPossible()) { x = startx - d; return field; } } catch (FieldNotFound &) { } y++; } d++; } throw FieldNotFound(); }