コード例 #1
0
ファイル: pgsqltypes.cpp プロジェクト: Ox0000/pgmodeler
QString PgSQLType::operator * (void)
{
	QString fmt_type, type, aux;
	unsigned idx;

	type=~(*this);

	//Generation the definition for the spatial types (PostGiS)
	if(type==QString("geometry") || type==QString("geography"))
		fmt_type=type + (*spatial_type);
	else if(length > 1 && hasVariableLength())
	{
		//Configuring the precision
		if((type==QString("numeric") || type==QString("decimal")) && precision>=0 &&
				precision<=static_cast<int>(length))
			aux=QString("%1(%2,%3)").arg(BaseType::type_list[type_idx]).arg(length).arg(precision);
		//Configuring the length for the type
		else
			aux=QString("%1(%2)").arg(BaseType::type_list[type_idx]).arg(length);

		fmt_type=aux;
	}
	else if(type!=QString("numeric") && type!=QString("decimal") && acceptsPrecision())
	{
		if(type!=QString("interval"))
		{
			aux=BaseType::type_list[type_idx];

			if(precision >= 0)
				aux+=QString("(%1)").arg(precision);

			if(with_timezone)
				aux+=QString(" with time zone");
		}
		else
		{
			aux=BaseType::type_list[type_idx];

			if(interval_type!=BaseType::null)
				aux+=QString(" %1 ").arg(~interval_type);

			if(precision >= 0)
				aux+=QString("(%1)").arg(precision);
		}

		fmt_type=aux;
	}
	else
		fmt_type=type;


	if(type!=QString("void") && dimension > 0)
	{
		for(idx=0; idx < dimension; idx++)
			fmt_type+=QString("[]");
	}

	return(fmt_type);
}
コード例 #2
0
ファイル: CPPBase.cpp プロジェクト: BackupTheBerlios/qedo-svn
char*
CPPBase::map_return_type
( IR__::IDLType_ptr type )
throw ( CannotMapType )
{
	string ret_string;
	CORBA::TCKind typecodekind;
	typecodekind=type->type()->kind();
	IR__::Contained_ptr contained = IR__::Contained::_narrow(type);

	//
	// skip typedefs
	//
	IR__::IDLType_var a_type = IR__::IDLType::_duplicate(type);
	while(typecodekind == CORBA::tk_alias)
	{
		IR__::AliasDef_var alias = IR__::AliasDef::_narrow(a_type);
		a_type = alias->original_type_def();
		typecodekind = a_type->type()->kind();
	}

	switch (typecodekind)
	{
	case CORBA::tk_alias : {
		assert(0);
		break; }
	case CORBA::tk_void:
		ret_string = "void";
		break;
	case CORBA::tk_short:
		ret_string = "CORBA::Short";
		break;
	case CORBA::tk_long:
		ret_string = "CORBA::Long";
		break;
	case CORBA::tk_longlong:
		ret_string = "CORBA::LongLong";
		break;
	case CORBA::tk_ushort:
		ret_string = "CORBA::UShort";
		break;
	case CORBA::tk_ulong:
		ret_string = "CORBA::ULong";
		break;
	case CORBA::tk_ulonglong:
		ret_string = "CORBA::ULongLong";
		break;
	case CORBA::tk_float:
		ret_string = "CORBA::Float";
		break;
	case CORBA::tk_double:
		ret_string = "CORBA::Double";
		break;
	case CORBA::tk_longdouble:
		ret_string = "CORBA::LongDouble";
		break;
	case CORBA::tk_boolean:
		ret_string = "CORBA::Boolean";
		break;
	case CORBA::tk_char:
		ret_string = "CORBA::Char";
		break;
	case CORBA::tk_wchar:
		ret_string = "CORBA::WChar";
		break;
	case CORBA::tk_any:
		ret_string = "CORBA::Any*";
		break;
	case CORBA::tk_objref:
		// First test whether we are a Contained, if not we are simply CORBA::Object_ptr
		if(CORBA::is_nil (contained))
		{
			ret_string = "CORBA::Object_ptr";
		}
		else
		{
			ret_string = getAbsoluteName (contained);
			ret_string.append ("_ptr");
		}
		break;
	case CORBA::tk_native:
		ret_string = getAbsoluteName (contained);
		break;
	case CORBA::tk_string:
		ret_string = "char*";
		break;
	case CORBA::tk_wstring:
		ret_string = "CORBA::WChar*";
		break;
	case CORBA::tk_value:
		ret_string = getAbsoluteName (contained);
		ret_string = ret_string + "*";
		break;
	case CORBA::tk_struct:
	case CORBA::tk_union:
		ret_string = getAbsoluteName(contained);
		if(hasVariableLength(type))
		{
			ret_string = ret_string + "*";
		}
		break;
	case CORBA::tk_enum:
		ret_string = getAbsoluteName (contained);
		break;
	case CORBA::tk_sequence:
		ret_string = getAbsoluteName(contained);
		ret_string = ret_string + "*";
		break;
	case CORBA::tk_TypeCode :
		ret_string = "CORBA::TypeCode_ptr";
		break;
	default:
		throw CannotMapType();
	}
	return CORBA::string_dup ( ret_string.c_str() );
}
コード例 #3
0
ファイル: CPPBase.cpp プロジェクト: BackupTheBerlios/qedo-svn
bool
CPPBase::hasVariableLength(IR__::IDLType_ptr type)
{
	CORBA::TCKind typecodekind = type->type()->kind();
	CORBA::ULong i;
	IR__::StructDef_var s;
	IR__::StructMemberSeq_var s_members;
	IR__::UnionDef_var u;
	IR__::UnionMemberSeq_var u_members;
	IR__::SequenceDef_var seq;

	//
	// skip typedefs
	//
	IR__::IDLType_var orig_type = IR__::IDLType::_duplicate(type);
	while(typecodekind == CORBA::tk_alias)
	{
		IR__::AliasDef_var alias = IR__::AliasDef::_narrow(orig_type);
		orig_type = alias->original_type_def();
		typecodekind = orig_type->type()->kind();
	}

	switch (typecodekind)
	{
	case CORBA::tk_short:
	case CORBA::tk_long:
	case CORBA::tk_longlong:
	case CORBA::tk_ushort:
	case CORBA::tk_ulong:
	case CORBA::tk_ulonglong:
	case CORBA::tk_float:
	case CORBA::tk_double:
	case CORBA::tk_longdouble:
	case CORBA::tk_boolean:
	case CORBA::tk_char:
	case CORBA::tk_wchar:
	case CORBA::tk_enum:
	case CORBA::tk_octet:
		return false;
	case CORBA::tk_any:
	case CORBA::tk_objref:
	case CORBA::tk_native:
	case CORBA::tk_string:
	case CORBA::tk_wstring:
	case CORBA::tk_value:
		return true;
	case CORBA::tk_struct:
		s = IR__::StructDef::_narrow(orig_type);
		s_members = s->members();
		for(i = 0; i < s_members->length(); i++)
		{
			if(hasVariableLength(s_members[i].type_def))
			{
				return true;
			}
		}
		return false;
	case CORBA::tk_union:
		u = IR__::UnionDef::_narrow(orig_type);
		u_members = u->members();
		for(i = 0; i < u_members->length(); i++)
		{
			if(hasVariableLength(u_members[i].type_def))
			{
				return true;
			}
		}
		return false;
	case CORBA::tk_sequence:
		seq = IR__::SequenceDef::_narrow(orig_type);
		if( (seq->bound() == 0) || hasVariableLength(seq->element_type_def()) )
		{
			return true;
		}
		return false;
	default:
	   std::cerr << "Unknown TCKind (" << (int)typecodekind << ")" << std::endl;
		assert(0);
	}
	return true;
}