Example #1
0
QString Index::getCodeDefinition(unsigned tipo_def)
{
	setElementsAttribute(tipo_def);
	attributes[ParsersAttributes::UNIQUE]=(index_attribs[UNIQUE] ? "1" : "");
	attributes[ParsersAttributes::CONCURRENT]=(index_attribs[CONCURRENT] ? "1" : "");
	attributes[ParsersAttributes::FAST_UPDATE]=(index_attribs[FAST_UPDATE] ? "1" : "");
	attributes[ParsersAttributes::INDEX_TYPE]=(~indexing_type);
	attributes[ParsersAttributes::CONDITION]=conditional_expr;

	if(this->parent_table)
		attributes[ParsersAttributes::TABLE]=this->parent_table->getName(true);

	attributes[ParsersAttributes::FACTOR]=QString("%1").arg(fill_factor);

	/* Case the index doesn't referece some column added by relationship it will be declared
		inside the parent table construction by the use of 'decl-in-table' schema attribute */
	if(!isReferRelationshipAddedColumn())
		attributes[ParsersAttributes::DECL_IN_TABLE]="1";

	return(BaseObject::__getCodeDefinition(tipo_def));
}
Example #2
0
QString Type::getCodeDefinition(unsigned def_type, bool reduced_form)
{
	QString code_def=getCachedCode(def_type, reduced_form);
	if(!code_def.isEmpty()) return(code_def);

	if(config==ENUMERATION_TYPE)
	{
		attributes[ParsersAttributes::ENUM_TYPE]=ParsersAttributes::_TRUE_;
		setEnumerationsAttribute(def_type);
	}
	else if(config==COMPOSITE_TYPE)
	{
		attributes[ParsersAttributes::COMPOSITE_TYPE]=ParsersAttributes::_TRUE_;
		setElementsAttribute(def_type);
	}
	else if(config==RANGE_TYPE)
	{
		attributes[ParsersAttributes::RANGE_TYPE]=ParsersAttributes::_TRUE_;

		if(def_type==SchemaParser::SQL_DEFINITION)
			attributes[ParsersAttributes::SUBTYPE]=(*subtype);
		else
			attributes[ParsersAttributes::SUBTYPE]=subtype.getCodeDefinition(SchemaParser::XML_DEFINITION);

		if(subtype_opclass)
		{
			if(def_type==SchemaParser::SQL_DEFINITION)
				attributes[ParsersAttributes::OP_CLASS]=subtype_opclass->getName(true);
			else
				attributes[ParsersAttributes::OP_CLASS]=subtype_opclass->getCodeDefinition(def_type, true);
		}
	}
	else
	{
		attributes[ParsersAttributes::BASE_TYPE]=ParsersAttributes::_TRUE_;

		if(internal_len==0 && def_type==SchemaParser::SQL_DEFINITION)
			attributes[ParsersAttributes::INTERNAL_LENGTH]=QString("VARIABLE");
		else
			attributes[ParsersAttributes::INTERNAL_LENGTH]=QString("%1").arg(internal_len);

		attributes[ParsersAttributes::BY_VALUE]=(by_value ? ParsersAttributes::_TRUE_ : QString());
		attributes[ParsersAttributes::ALIGNMENT]=(*alignment);
		attributes[ParsersAttributes::STORAGE]=(~storage);
		attributes[ParsersAttributes::DEFAULT_VALUE]=default_value;

		if(element!=QString("\"any\""))
			attributes[ParsersAttributes::ELEMENT]=(*element);

		if(delimiter!='\0')
			attributes[ParsersAttributes::DELIMITER]=delimiter;

		attributes[ParsersAttributes::CATEGORY]=~(category);

		attributes[ParsersAttributes::PREFERRED]=(preferred ? ParsersAttributes::_TRUE_ : QString());
		attributes[ParsersAttributes::COLLATABLE]=(collatable ? ParsersAttributes::_TRUE_ : QString());

		if(like_type!=QString("\"any\""))
		{
			if(def_type==SchemaParser::SQL_DEFINITION)
				attributes[ParsersAttributes::LIKE_TYPE]=(*like_type);
			else
				attributes[ParsersAttributes::LIKE_TYPE]=like_type.getCodeDefinition(SchemaParser::XML_DEFINITION);
		}
	}

	if(config==BASE_TYPE || config==RANGE_TYPE)
	{
		unsigned i;
		QString func_attrib[]={ParsersAttributes::INPUT_FUNC,
							   ParsersAttributes::OUTPUT_FUNC,
							   ParsersAttributes::RECV_FUNC,
							   ParsersAttributes::SEND_FUNC,
							   ParsersAttributes::TPMOD_IN_FUNC,
							   ParsersAttributes::TPMOD_OUT_FUNC,
							   ParsersAttributes::ANALYZE_FUNC,
							   ParsersAttributes::CANONICAL_FUNC,
							   ParsersAttributes::SUBTYPE_DIFF_FUNC};

		for(i=0; i < sizeof(functions)/sizeof(Function *); i++)
		{
			if(functions[i])
			{
				if(def_type==SchemaParser::SQL_DEFINITION)
					attributes[func_attrib[i]]=functions[i]->getName();
				else
				{
					functions[i]->setAttribute(ParsersAttributes::REF_TYPE, func_attrib[i]);
					attributes[func_attrib[i]]=functions[i]->getCodeDefinition(def_type, true);
				}
			}
		}
	}

	return(BaseObject::getCodeDefinition(def_type, reduced_form));
}