Example #1
0
    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);
    }
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
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;
}
Example #5
0
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;
}
Example #6
0
void Class::setObj(std::string name, Object *value) {
    if (staticObjectFields.find(name) == staticObjectFields.end())
        throw FieldNotFound();

    staticObjectFields[name] = value;
}
Example #7
0
Object *Class::getObj(std::string name) {
    if (staticObjectFields.find(name) == staticObjectFields.end())
        throw FieldNotFound();

    return staticObjectFields[name];
}
Example #8
0
void Class::setInt(std::string name, int value) {
    if (staticIntFields.find(name) == staticIntFields.end())
        throw FieldNotFound();

    staticIntFields[name] = value;
}
Example #9
0
int Class::getInt(std::string name) {
    if (staticIntFields.find(name) == staticIntFields.end())
        throw FieldNotFound();

    return staticIntFields[name];
}
Example #10
0
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();
}