コード例 #1
0
ファイル: PersonEditorPane.cpp プロジェクト: fb/startkladde
void PersonEditorPane::fieldsToObject (Person &person)
{
	// Require "change medical data" permission if the medical data changed
	Person originalPerson=getOriginalObject ();
	if (getEffectiveMedicalValidity ()!=originalPerson.medicalValidity)
	{
		if (paneData && !paneData->changeMedicalDataPermission->permit (this))
		{
			throw AbortedException ();
		}
	}

	person.lastName             =ui.lastNameInput       ->text ().simplified ();
	person.firstName            =ui.firstNameInput      ->text ().simplified ();
	person.club                 =ui.clubInput           ->currentText ().simplified ();
	person.comments             =ui.commentsInput       ->text ().simplified ();
	person.checkMedical         =ui.checkMedicalInput   ->currentItemData ().toBool ();
	person.medicalValidity      =getEffectiveMedicalValidity ();
	person.clubId               =ui.clubIdInput         ->text ();

	// Error checks

	if (isNone (person.lastName))
		errorCheck (tr ("Last name not specified."),
			ui.lastNameInput);

	if (isNone (person.firstName))
		errorCheck (tr ("First name not specified."),
			ui.firstNameInput);
}
コード例 #2
0
PassRefPtr<Range> VisibleSelection::toNormalizedRange() const
{
    if (isNone())
        return 0;

    // Make sure we have an updated layout since this function is called
    // in the course of running edit commands which modify the DOM.
    // Failing to call this can result in equivalentXXXPosition calls returning
    // incorrect results.
    m_start.anchorNode()->document().updateLayout();

    // Check again, because updating layout can clear the selection.
    if (isNone())
        return 0;

    Position s, e;
    if (isCaret()) {
        // If the selection is a caret, move the range start upstream. This helps us match
        // the conventions of text editors tested, which make style determinations based
        // on the character before the caret, if any. 
        s = m_start.upstream().parentAnchoredEquivalent();
        e = s;
    } else {
        // If the selection is a range, select the minimum range that encompasses the selection.
        // Again, this is to match the conventions of text editors tested, which make style 
        // determinations based on the first character of the selection. 
        // For instance, this operation helps to make sure that the "X" selected below is the 
        // only thing selected. The range should not be allowed to "leak" out to the end of the 
        // previous text node, or to the beginning of the next text node, each of which has a 
        // different style.
        // 
        // On a treasure map, <b>X</b> marks the spot.
        //                       ^ selected
        //
        ASSERT(isRange());
        s = m_start.downstream();
        e = m_end.upstream();
        if (comparePositions(s, e) > 0) {
            // Make sure the start is before the end.
            // The end can wind up before the start if collapsed whitespace is the only thing selected.
            Position tmp = s;
            s = e;
            e = tmp;
        }
        s = s.parentAnchoredEquivalent();
        e = e.parentAnchoredEquivalent();
    }

    if (!s.containerNode() || !e.containerNode())
        return 0;

    // VisibleSelections are supposed to always be valid.  This constructor will ASSERT
    // if a valid range could not be created, which is fine for this callsite.
    return Range::create(s.anchorNode()->document(), s, e);
}
コード例 #3
0
PassRefPtr<Range> VisibleSelection::firstRange() const
{
    if (isNone())
        return 0;
    Position start = rangeCompliantEquivalent(m_start);
    Position end = rangeCompliantEquivalent(m_end);
    return Range::create(start.node()->document(), start, end);
}
コード例 #4
0
ファイル: VRPyPathtool.cpp プロジェクト: infobeisel/polyvr
PyObject* VRPyPathtool::extrude(VRPyPathtool* self, PyObject* args) {
    if (self->obj == 0) { PyErr_SetString(err, "VRPyPathtool::extrude - Object is invalid"); return NULL; }
    VRPyDevice* dev; VRPyPath* p;
    if (! PyArg_ParseTuple(args, "OO", &dev, &p)) return NULL;
    OSG::VRDevice* d = 0;
    if (!isNone((PyObject*)dev)) d = dev->obj;
    return VRPyGeometry::fromPtr( self->obj->extrude( d, p->obj) );
}
コード例 #5
0
PassRefPtr<Range> VisibleSelection::firstRange() const
{
    if (isNone())
        return 0;
    Position start = m_start.parentAnchoredEquivalent();
    Position end = m_end.parentAnchoredEquivalent();
    return Range::create(start.anchorNode()->document(), start, end);
}
コード例 #6
0
bool VisibleSelection::expandUsingGranularity(TextGranularity granularity)
{
    if (isNone())
        return false;

    validate(granularity);
    return true;
}
コード例 #7
0
ファイル: option.hpp プロジェクト: CipherLiu/mesos
  operator Result<T> () const
  {
    if (isNone()) {
      return Result<T>::none();
    }

    return Result<T>::some(get());
  }
コード例 #8
0
PassRefPtrWillBeRawPtr<Range> VisibleSelection::firstRange() const
{
    if (isNone())
        return nullptr;
    Position start = m_start.parentAnchoredEquivalent();
    Position end = m_end.parentAnchoredEquivalent();
    return Range::create(*start.document(), start, end);
}
コード例 #9
0
ファイル: FunctionParser.cpp プロジェクト: scrossuk/locic
		AST::Node<AST::Function>
		FunctionParser::parseNonTemplatedMethod(const Debug::SourcePosition& start) {
			if (reader_.peek().kind() == Token::TILDA) {
				reader_.consume();
				const auto nameString = reader_.makeCString("__destroy");
				auto name = builder_.makeName(Name::Relative() + nameString, start);
				auto scope = ScopeParser(reader_).parseScope();
				return builder_.makeDestructor(std::move(name), std::move(scope), start);
			}
			
			const bool isStatic = reader_.consumeIfPresent(Token::STATIC);
			auto returnType = parseMethodReturnType();
			auto name = parseMethodName();
			
			if (reader_.peek().kind() == Token::SETEQUAL) {
				reader_.consume();
				reader_.expect(Token::DEFAULT);
				auto requireSpecifier = AttributeParser(reader_).parseOptionalRequireSpecifier();
				reader_.expect(Token::SEMICOLON);
				return builder_.makeDefaultMethod(isStatic, std::move(name), std::move(requireSpecifier), start);
			}
			
			reader_.expect(Token::LROUNDBRACKET);
			auto varList = VarParser(reader_).parseVarList(/*allowInherit=*/false);
			reader_.expect(Token::RROUNDBRACKET);
			
			auto constSpecifier = AttributeParser(reader_).parseOptionalConstSpecifier();
			auto noexceptSpecifier = AttributeParser(reader_).parseOptionalNoexceptSpecifier();
			
			const auto overrideStart = reader_.position();
			const bool isOverride = reader_.consumeIfPresent(Token::OVERRIDE);
			if (isOverride) {
				reader_.issueDiag(OverrideNotImplementedDiag(),
				                  overrideStart);
			}
			
			auto requireSpecifier = AttributeParser(reader_).parseOptionalRequireSpecifier();
			
			if (isStatic && !constSpecifier->isNone()) {
				reader_.issueDiagWithLoc(StaticMethodCannotBeConstDiag(),
				                         constSpecifier.location());
			}
			
			if (reader_.peek().kind() == Token::SEMICOLON) {
				reader_.consume();
				return builder_.makeFunctionDecl(/*isVarArg=*/false, isStatic,
				                                 std::move(returnType), std::move(name), std::move(varList),
				                                 std::move(constSpecifier), std::move(noexceptSpecifier),
				                                 std::move(requireSpecifier), start);
			}
			
			auto scope = ScopeParser(reader_).parseScope();
			
			return builder_.makeFunctionDef(/*isVarArg=*/false, isStatic,
			                                std::move(returnType), std::move(name), std::move(varList),
			                                std::move(constSpecifier), std::move(noexceptSpecifier),
			                                std::move(requireSpecifier), std::move(scope), start);
		}
コード例 #10
0
ファイル: Selection.cpp プロジェクト: Crawping/davinci
PassRefPtr<Range> Selection::toRange() const
{
    if (isNone())
        return 0;

    // Make sure we have an updated layout since this function is called
    // in the course of running edit commands which modify the DOM.
    // Failing to call this can result in equivalentXXXPosition calls returning
    // incorrect results.
    m_start.node()->document()->updateLayout();

    Position s, e;
    if (isCaret()) {
        // If the selection is a caret, move the range start upstream. This helps us match
        // the conventions of text editors tested, which make style determinations based
        // on the character before the caret, if any. 
        s = rangeCompliantEquivalent(m_start.upstream());
        e = s;
    } else {
        // If the selection is a range, select the minimum range that encompasses the selection.
        // Again, this is to match the conventions of text editors tested, which make style 
        // determinations based on the first character of the selection. 
        // For instance, this operation helps to make sure that the "X" selected below is the 
        // only thing selected. The range should not be allowed to "leak" out to the end of the 
        // previous text node, or to the beginning of the next text node, each of which has a 
        // different style.
        // 
        // On a treasure map, <b>X</b> marks the spot.
        //                       ^ selected
        //
        ASSERT(isRange());
        s = m_start.downstream();
        e = m_end.upstream();
        if (Range::compareBoundaryPoints(s.node(), s.offset(), e.node(), e.offset()) > 0) {
            // Make sure the start is before the end.
            // The end can wind up before the start if collapsed whitespace is the only thing selected.
            Position tmp = s;
            s = e;
            e = tmp;
        }
        s = rangeCompliantEquivalent(s);
        e = rangeCompliantEquivalent(e);
    }

    ExceptionCode ec = 0;
    RefPtr<Range> result(new Range(s.node()->document()));
    result->setStart(s.node(), s.offset(), ec);
    if (ec) {
        LOG_ERROR("Exception setting Range start from Selection: %d", ec);
        return 0;
    }
    result->setEnd(e.node(), e.offset(), ec);
    if (ec) {
        LOG_ERROR("Exception setting Range end from Selection: %d", ec);
        return 0;
    }
    return result.release();
}
コード例 #11
0
ファイル: VRPyLogistics.cpp プロジェクト: Pfeil/polyvr
PyObject* FPyLogistics::addContainer(FPyLogistics* self, PyObject* args) {
    if (self->obj == 0) { PyErr_SetString(err, "FPyLogistics::addContainer - Object is invalid"); return NULL; }
    VRPyTransform* t = 0;
    if (! PyArg_ParseTuple(args, "O", &t)) return NULL;
    OSG::VRTransformPtr tr = 0;
    if ( !isNone((PyObject*)t) ) tr = t->objPtr;
    FContainer* c = self->obj->addContainer(tr);
    return FPyContainer::fromPtr(c);
}
コード例 #12
0
ファイル: Selection.cpp プロジェクト: Crawping/davinci
bool Selection::expandUsingGranularity(TextGranularity granularity)
{
    if (isNone())
        return false;

    m_granularity = granularity;
    validate();
    return true;
}
コード例 #13
0
ファイル: VRPyPathtool.cpp プロジェクト: infobeisel/polyvr
PyObject* VRPyPathtool::newPath(VRPyPathtool* self, PyObject* args) {
    if (self->obj == 0) { PyErr_SetString(err, "VRPyPathtool::newPath - Object is invalid"); return NULL; }
    VRPyDevice* dev; VRPyObject* obj; int res = 10;
    if (pySize(args) == 2) { if (! PyArg_ParseTuple(args, "OO", &dev, &obj)) return NULL; }
    else if (! PyArg_ParseTuple(args, "OOi", &dev, &obj, &res)) return NULL;
    OSG::VRDevice* d = 0;
    if (!isNone((PyObject*)dev)) d = dev->obj;
    OSG::path* p = self->obj->newPath( d, obj->obj, res );
    return VRPyPath::fromPtr(p);
}
コード例 #14
0
ファイル: VRPyObject.cpp プロジェクト: infobeisel/polyvr
PyObject* VRPyObject::addChild(VRPyObject* self, PyObject* args, PyObject *kwds) {
    VRPyObject* child = NULL;
    if (! PyArg_ParseTuple(args, "O", &child)) return NULL;
    if ( isNone((PyObject*)child) ) Py_RETURN_TRUE;

    if (self->obj == 0) { PyErr_SetString(err, "VRPyObject::addChild, Parent is invalid"); return NULL; }
    if (child->obj == 0) { PyErr_SetString(err, "VRPyObject::addChild, Child is invalid"); return NULL; }

    self->obj->addChild(child->obj);
    Py_RETURN_TRUE;
}
コード例 #15
0
ファイル: scface.cpp プロジェクト: Fahad-Alsaidi/scribus
/** two ScFaces are equal if they either are both NULLFACEs or they
agree on family, style, variant and fontpath
*/
bool ScFace::operator==(const ScFace& other) const
{
	return m_replacedName == other.m_replacedName && 
		( (isNone() && other.isNone() )
			 || (m_m == other.m_m)
			 || (m_m->family == other.m_m->family
				 && m_m->style == other.m_m->style
				 && m_m->variant == other.m_m->variant
				 && m_m->fontFile == other.m_m->fontFile
				 && m_m-> faceIndex == other.m_m->faceIndex) );
}
コード例 #16
0
ファイル: QDjangoWhere.cpp プロジェクト: rayben/Niepce
/** Combines the current QDjangoWhere with the \a other QDjangoWhere using
 *  a logical OR.
 *
 * \param other
 */
QDjangoWhere QDjangoWhere::operator||(const QDjangoWhere &other) const
{
    if (isAll() || other.isNone())
        return *this;
    else if (isNone() || other.isAll())
        return other;

    QDjangoWhere result;
    result.m_combine = OrCombine;
    result.m_children << *this << other;
    return result;
}
コード例 #17
0
ファイル: result.hpp プロジェクト: janisz/mesos
 const T& get() const
 {
   if (!isSome()) {
     std::string errorMessage = "Result::get() but state == ";
     if (isError()) {
       errorMessage += "ERROR: " + data.error();
     } else if (isNone()) {
       errorMessage += "NONE";
     }
     ABORT(errorMessage);
   }
   return data.get().get();
 }
コード例 #18
0
ファイル: NameSearch.cpp プロジェクト: scrossuk/locic
		SearchResult performSearch(Context& context, const Name& name, const size_t searchStartPosition) {
			assert(!name.empty());
			
			const auto& scopeStack = context.scopeStack();
			
			const size_t startPosition = name.isAbsolute() ? scopeStack.size() - 1 : searchStartPosition;
			for (size_t i = startPosition; i < scopeStack.size(); i++) {
				const auto pos = scopeStack.size() - i - 1;
				const auto result = performInnerSearch(scopeStack[pos], name);
				if (!result.isNone()) return result;
			}
			
			return SearchResult::None();
		}
コード例 #19
0
bool VisibleSelection::expandUsingGranularity(TextGranularity granularity)
{
    if (isNone())
        return false;

    // FIXME: Do we need to check all of them?
    Position oldBase = m_base;
    Position oldExtent = m_extent;
    Position oldStart = m_start;
    Position oldEnd = m_end;
    validate(granularity);
    if (m_base != oldBase || m_extent != oldExtent || m_start != oldStart || m_end != oldEnd)
        didChange();
    return true;
}
コード例 #20
0
ファイル: QDjangoWhere.cpp プロジェクト: hummermania/qdjango
/** Combines the current QDjangoWhere with the \a other QDjangoWhere using
 *  a logical OR.
 *
 * \param other
 */
QDjangoWhere QDjangoWhere::operator||(const QDjangoWhere &other) const
{
    if (isAll() || other.isNone())
        return *this;
    else if (isNone() || other.isAll())
        return other;

    if (d->combine == QDjangoWherePrivate::OrCombine) {
        QDjangoWhere result = *this;
        result.d->children << other;
        return result;
    }

    QDjangoWhere result;
    result.d->combine = QDjangoWherePrivate::OrCombine;
    result.d->children << *this << other;
    return result;
}
コード例 #21
0
ファイル: PlaneLog.cpp プロジェクト: startkladde/startkladde
/**
 * Create an entry for a non-empty, sorted list of flights which we know can
 * be merged. All flights must be of the same plane and on the same date.
 */
PlaneLog::Entry PlaneLog::Entry::create (const QList<Flight> &flights, Cache &cache)
{
	assert (!flights.isEmpty ());

	PlaneLog::Entry entry;

	Plane      *plane     =cache.getNewObject<Plane     > (flights.last ().getPlaneId ());
    Person     *pilot     =cache.getNewObject<Person    > (flights.last ().getPilotInCommandId ());

	// Values directly determined
	if (plane) entry.registration=plane->registration;
	if (plane) entry.type=plane->type;

	entry.date=flights.last ().effdatum ();
	if (pilot) entry.pilotName=pilot->formalName ();
	entry.departureLocation=flights.first ().getDepartureLocation ().trimmed ();
	entry.landingLocation=flights.last ().getLandingLocation ().trimmed ();
	entry.departureTime=flights.first ().getDepartureTime ();
	entry.landingTime=flights.last ().getLandingTime ();

	// Values determined from all flights
	entry.minPassengers=entry.maxPassengers=0;
	entry.numLandings=0;
	QStringList comments;
	entry.valid=true;

	int numTowFlights=0;

	foreach (const Flight &flight, flights)
	{
		int numPassengers=flight.numPassengers ();
		if (entry.minPassengers==0 || numPassengers<entry.minPassengers) entry.minPassengers=numPassengers;
		if (entry.maxPassengers==0 || numPassengers>entry.maxPassengers) entry.maxPassengers=numPassengers;

		entry.numLandings+=flight.getNumLandings ();

		if (flight.hasDuration ())
			entry.operationTime=entry.operationTime.addSecs (QTime ().secsTo (flight.flightDuration ())); // TODO: check flight mode

		if (!isNone (flight.getComments ())) comments << flight.getComments ().trimmed ();
		if (!flight.finished ()) entry.valid=false;

		if (flight.isTowflight ()) ++numTowFlights;
	}
コード例 #22
0
ファイル: FunctionParser.cpp プロジェクト: scrossuk/locic
		AST::Node<AST::Function> FunctionParser::parseBasicFunction(const Debug::SourcePosition& start) {
			const bool isStatic = reader_.consumeIfPresent(Token::STATIC);
			auto returnType = TypeParser(reader_).parseType();
			auto name = parseFunctionName();
			
			reader_.expect(Token::LROUNDBRACKET);
			
			bool isVarArg = false;
			
			auto varList = VarParser(reader_).parseVarList(/*allowInherit=*/false);
			
			if (reader_.peek().kind() == Token::COMMA) {
				reader_.consume();
				reader_.expect(Token::DOT);
				reader_.expect(Token::DOT);
				reader_.expect(Token::DOT);
				isVarArg = true;
			}
			
			reader_.expect(Token::RROUNDBRACKET);
			
			auto constSpecifier = AttributeParser(reader_).parseOptionalConstSpecifier();
			auto noexceptSpecifier = AttributeParser(reader_).parseOptionalNoexceptSpecifier();
			auto requireSpecifier = AttributeParser(reader_).parseOptionalRequireSpecifier();
			
			if (isStatic && !constSpecifier->isNone()) {
				reader_.issueDiagWithLoc(StaticMethodCannotBeConstDiag(),
				                         constSpecifier.location());
			}
			
			if (reader_.peek().kind() == Token::SEMICOLON) {
				reader_.consume();
				return builder_.makeFunctionDecl(isVarArg, isStatic,
				                                 std::move(returnType), std::move(name), std::move(varList),
				                                 std::move(constSpecifier), std::move(noexceptSpecifier),
				                                 std::move(requireSpecifier), start);
			}
			
			auto scope = ScopeParser(reader_).parseScope();
			return builder_.makeFunctionDef(isVarArg, isStatic, std::move(returnType),
			                                std::move(name), std::move(varList), std::move(constSpecifier),
			                                std::move(noexceptSpecifier), std::move(requireSpecifier),
			                                std::move(scope), start);
		}
コード例 #23
0
void VisibleSelection::formatForDebugger(char* buffer, unsigned length) const
{
    String result;
    String s;
    
    if (isNone()) {
        result = "<none>";
    } else {
        const int FormatBufferSize = 1024;
        char s[FormatBufferSize];
        result += "from ";
        start().formatForDebugger(s, FormatBufferSize);
        result += s;
        result += " to ";
        end().formatForDebugger(s, FormatBufferSize);
        result += s;
    }

    strncpy(buffer, result.utf8().data(), length - 1);
}
コード例 #24
0
void VisibleSelection::formatForDebugger(char* buffer, unsigned length) const
{
    StringBuilder result;
    String s;

    if (isNone()) {
        result.appendLiteral("<none>");
    } else {
        const int FormatBufferSize = 1024;
        char s[FormatBufferSize];
        result.appendLiteral("from ");
        start().formatForDebugger(s, FormatBufferSize);
        result.append(s);
        result.appendLiteral(" to ");
        end().formatForDebugger(s, FormatBufferSize);
        result.append(s);
    }

    strncpy(buffer, result.toString().utf8().data(), length - 1);
}
コード例 #25
0
ファイル: ofxPython.cpp プロジェクト: joshuajnoble/ofxPython
ofxPythonObject::operator bool() const
{
	return get() && get()->obj && !isNone(); //TODO: check if evaluates to false (0,(,),[])
}
コード例 #26
0
ファイル: File.cpp プロジェクト: Prabhnith/nix
void File::close() {
    if (!isNone()) {
        backend()->close();
        nullify();
    }
}
コード例 #27
0
ファイル: pybase.cpp プロジェクト: evetools/marshalcpp
const pynone* pybase::asNone() const {
	assert(isNone());
	return (reinterpret_cast<const pynone*>(this));
}
コード例 #28
0
ファイル: option.hpp プロジェクト: 447327642/mesos
 // This must return a copy to avoid returning a reference to a temporary.
 T getOrElse(const T& _t) const { return isNone() ? _t : t; }
コード例 #29
0
ファイル: ObjectEditorPane.cpp プロジェクト: fb/startkladde
// TODO use more
void ObjectEditorPaneBase::requiredField (const QString &value, QWidget *widget, const QString &problem)
{
	if (isNone (value))
		errorCheck (problem, widget);
}
コード例 #30
0
ファイル: option.hpp プロジェクト: 447327642/mesos
 bool operator==(const Option<T>& that) const
 {
   return (isNone() && that.isNone()) ||
     (isSome() && that.isSome() && t == that.t);
 }