Exemplo n.º 1
0
void ArgState::finalize() throw() {
	stage = STAGE_FINISH;

	// Finalize operands
	for (auto& operand : operands) {
		operand.stage = STAGE_FINISH;

		for (int optionGroupId = OPTG_MIN_; optionGroupId <= OPTG_MAX_; ++optionGroupId) {
			const IOptionGroupCallback& gcb = *optionGroupCallbacks[optionGroupId];
			gcb(*this, &operand);
		}
	}

	// Close files/streams
	inputOperand.inputStream.close();
	inputOperand.outputStream.close();
	outputOperand.outputStream.close();
	outputOperand.outputStream.close();
	for (auto& operand : operands) {
		operand.inputStream.close();
		operand.outputStream.close();
	}

	// Finalize the state itself
	for (int optionGroupId = OPTG_MIN_; optionGroupId <= OPTG_MAX_; ++optionGroupId) {
		const IOptionGroupCallback& gcb = *optionGroupCallbacks[optionGroupId];
		gcb(*this);
	}

	operands.clear();
	variants.clear();
}
Exemplo n.º 2
0
bool ArgState::callOptionGroups() {
	bool keepgoing = true;

	for (int optionGroupId = OPTG_MIN_; optionGroupId <= OPTG_MAX_ && keepgoing; ++optionGroupId) {
		const IOptionGroupCallback& gcb = *optionGroupCallbacks[optionGroupId];
		ukoct_ASSERT(optionGroupCallbacks[optionGroupId] != NULL, "NULL Option group callback, recheck declarations.");
		keepgoing = gcb(*this);
	}

	return keepgoing;
}
Exemplo n.º 3
0
void gcTextList::draw(gcDrawingImpl &impl) const {
    static const size_t V_OFF_START = 10;
    static const size_t V_OFF_PAD = 5;

    impl.SetColor(Qt::white);

    size_t voffset = V_OFF_START;
    QFontMetrics met (impl.curFont());

    for (tagged_cb gcbPair : list)
    {
        glbStringCallback_p gcb (gcbPair.second);
        if (gcb.isNull() || gcb->msg() == "")
            continue;
        impl.Draw(QString::fromStdString(gcb->msg()), QPoint(0, voffset));
        voffset += met.height() + V_OFF_PAD;
    }
}
Exemplo n.º 4
0
bool ArgState::callOptionGroups(Operand& operand) {
	bool keepgoing = true;

	// Option 1: Call all optionGroups on all operands, regardless of its
	// original option and option group
#if 0
	for (int optionGroupId = OPTG_MIN_; optionGroupId <= OPTG_MAX_ && keepgoing; ++optionGroupId) {
		const IOptionGroupCallback& gcb = *optionGroupCallbacks[optionGroupId];

		switch (operand.stage) {
		case STAGE_INIT:
			operand.initTiming.stage(STAGE_INIT).stageName("init");
			operand.initTiming.start();
			break;
		case STAGE_RUN:
			operand.execTiming.stage(STAGE_EXEC).stageName("run");
			operand.execTiming.start();
			break;
		}

		keepgoing = gcb(*this, &operand);

		// Timing end
		switch(operand.stage) {
		case STAGE_INIT:
			operand.initTiming.end();
			operand.initTiming.round();
			break;
		case STAGE_RUN:
			operand.execTiming.end();
			operand.execTiming.round();
			break;
		}
	}
#endif
	// Option 2: Call only the option group declared on the option that the
	// operand belongs to.
	ukoct_ASSERT(operand.option != NULL, "Operand must have an option object.");
	const IOptionGroupCallback& gcb = *optionGroupCallbacks[operand.option->group];
	ukoct_ASSERT(gcb != NULL, "Invalid option declared for option, `gcb` cannot be NULL.");

	// Timing start
	switch (operand.stage) {
	case STAGE_INIT:
		operand.initTiming.stage(STAGE_INIT).stageName("init");
		operand.initTiming.start();
		break;
	case STAGE_RUN:
		operand.execTiming.stage(STAGE_EXEC).stageName("run");
		operand.execTiming.start();
		break;
	}

	// Run
	keepgoing = gcb(*this, &operand);

	// Timing end
	switch(operand.stage) {
	case STAGE_INIT:
		operand.initTiming.end();
		operand.initTiming.round();
		break;
	case STAGE_RUN:
		operand.execTiming.end();
		operand.execTiming.round();
		break;
	}

	return keepgoing;
}