예제 #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);
    }
예제 #2
0
파일: Object.cpp 프로젝트: maxyor6040/cpp
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;
}
예제 #3
0
파일: Object.cpp 프로젝트: maxyor6040/cpp
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;
}
예제 #4
0
파일: Object.cpp 프로젝트: sazulay3/OOP-HW5
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;
}
예제 #5
0
파일: Object.cpp 프로젝트: sazulay3/OOP-HW5
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;
}
예제 #6
0
파일: Class.cpp 프로젝트: maxyor6040/cpp
void Class::setObj(std::string name, Object *value) {
    if (staticObjectFields.find(name) == staticObjectFields.end())
        throw FieldNotFound();

    staticObjectFields[name] = value;
}
예제 #7
0
파일: Class.cpp 프로젝트: maxyor6040/cpp
Object *Class::getObj(std::string name) {
    if (staticObjectFields.find(name) == staticObjectFields.end())
        throw FieldNotFound();

    return staticObjectFields[name];
}
예제 #8
0
파일: Class.cpp 프로젝트: maxyor6040/cpp
void Class::setInt(std::string name, int value) {
    if (staticIntFields.find(name) == staticIntFields.end())
        throw FieldNotFound();

    staticIntFields[name] = value;
}
예제 #9
0
파일: Class.cpp 프로젝트: maxyor6040/cpp
int Class::getInt(std::string name) {
    if (staticIntFields.find(name) == staticIntFields.end())
        throw FieldNotFound();

    return staticIntFields[name];
}
예제 #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();
}