示例#1
0
文件: glv_model.cpp 项目: eranws/GLV
void Data::print() const{
	printf("%p + %d, (%d", mData, offset(), size(0));
	for(int i=1;i<highestDim(*this);++i){
		printf(",%d", size(i));
	}
	printf("):%+d, %s %s\n", stride(), typeToString(type()).c_str(), toToken().c_str());
}
	void processChar( char item, MyStack<Token> &stack, string &operations, bool &OK )
	{
		// Note:
		// I could check top of stack before adding tokens
		// and catch many errors "now" instead of later.
		// I'd rather be lazy and let collapse() catch the errors.

		Token token = toToken(item);
		switch (token)
		{
		case TOKEN_VALUE:
			if		( stack.isEmpty() ) { stack << token; return; }
			switch ( stack.top() )
			{
			case TOKEN_LEFT_GROUP:		stack << token; break;
			case TOKEN_ADDITION:		stack << token; break; // don't collapse yet
			case TOKEN_MULTIPLICATION:	collapse( stack << token, operations, OK ); break;
			default:					OK = false; break;
			}
			break;

		case TOKEN_ADDITION:
			collapse( stack, operations, OK);
			stack << TOKEN_ADDITION;
			break;

		case TOKEN_MULTIPLICATION:
		case TOKEN_LEFT_GROUP:
			stack << token;
			break;

		case TOKEN_RIGHT_GROUP:
			// clear any pending addidion
			collapse( stack, operations, OK );
			if ( !OK ) return;

			// convert ( value ) to value
			if ( !stack.isEmpty() && TOKEN_VALUE == stack.pop()
					&& !stack.isEmpty() && TOKEN_LEFT_GROUP == stack.pop() )
				stack << TOKEN_VALUE;
			else
				OK = false;
			break;

		case TOKEN_UNKNOWN:
			OK = false;
			break;
		}
	}
示例#3
0
文件: db_key.cpp 项目: jbfavre/xca
void db_key::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
{
	QMenu *menu = new QMenu(mainwin);
	currentIdx = index;

	pki_key *key = static_cast<pki_key*>(currentIdx.internalPointer());

	menu->addAction(tr("New Key"), this, SLOT(newItem()));
	menu->addAction(tr("Import"), this, SLOT(load()));
	if (index != QModelIndex()) {
		menu->addAction(tr("Rename"), this, SLOT(edit()));
		menu->addAction(tr("Show Details"), this, SLOT(showItem()));
		menu->addAction(tr("Delete"), this, SLOT(delete_ask()));
		menu->addAction(tr("Export"), this, SLOT(store()));
		if (key->isPrivKey() && !key->isToken()) {
			switch (key->getOwnPass()) {
			case pki_key::ptCommon:
				menu->addAction(tr("Change password"), this,
						SLOT(setOwnPass()));
				break;
			case pki_key::ptPrivate:
				menu->addAction(tr("Reset password"), this,
						SLOT(resetOwnPass()));
				break;
			}
		}
		if (key->isToken() && pkcs11::loaded()) {
			menu->addAction(tr("Change PIN"), this,
				SLOT(changePin()));
			menu->addAction(tr("Init PIN with SO PIN (PUK)"), this,
				SLOT(initPin()));
			menu->addAction(tr("Change SO PIN (PUK)"), this,
				SLOT(changeSoPin()));
		}
		if (!key->isToken() && pkcs11::loaded()) {
			menu->addAction(tr("Store on Security token"),
				this, SLOT(toToken()));
		}
	}
	contextMenu(e, menu);
	currentIdx = QModelIndex();
	return;
}
示例#4
0
文件: glv_model.cpp 项目: eranws/GLV
int toToken(std::string& dst, const char * src){ return toToken(dst, std::string(src)); }