Пример #1
0
colvarvalue::colvarvalue(cvm::vector1d<cvm::real> const &v, Type vti)
{
  if ((vti != type_vector) && (v.size() != num_dimensions(vti))) {
    cvm::error("Error: trying to initialize a variable of type \""+type_desc(vti)+
               "\" using a vector of size "+cvm::to_str(v.size())+
               ".\n");
    value_type = type_notset;
  } else {
    value_type = vti;
    switch (vti) {
    case type_scalar:
      real_value = v[0];
      break;
    case type_3vector:
    case type_unit3vector:
    case type_unit3vectorderiv:
      rvector_value = cvm::rvector(v);
      break;
    case type_quaternion:
    case type_quaternionderiv:
      quaternion_value = cvm::quaternion(v);
      break;
    case type_vector:
      vector1d_value = v;
      break;
    case type_notset:
    default:
      break;
    }
  }
}
Пример #2
0
void DescribeColumn::describe(OciConnection &con, OciParam &param)
{
	// OciParam param = _desc.get_param();

	_name = param.get_attribute<tstring>(OCI_ATTR_NAME);

	_schema_name = param.get_attribute<tstring>(OCI_ATTR_SCHEMA_NAME);

	_type_name = param.get_attribute<tstring>(OCI_ATTR_TYPE_NAME);

	_data_type = param.get_attribute<ub2>(OCI_ATTR_DATA_TYPE);

	// OCI_ATTR_SCALE The scale of numeric columns. If the precision is nonzero and scale is -127,
	// then it is a FLOAT, else it is a NUMBER(precision, scale).
	// For the case when precision is 0, NUMBER(precision, scale) can be represented simply as NUMBER. sb1
	_scale = param.get_attribute<sb1>(OCI_ATTR_SCALE);

	// OCI_ATTR_REF_TDO Returns the in-memory REF of the TDO for the type, if the column type is an object type.
	// If space has not been reserved for the OCIRef, then it is allocated implicitly in the cache. The caller can then pin the TDO with OCIObjectPin().
	// OCIRef*

	// OCI_ATTR_CHARSET_ID The character set id, if the type attribute is of a string/character type ub2
	_charset_id = param.get_attribute<ub2>(OCI_ATTR_CHARSET_ID);

	// OCI_ATTR_CHARSET_FORM The character set form, if the type attribute is of a string/character type ub1
	_charset_form = param.get_attribute<ub1>(OCI_ATTR_CHARSET_FORM);
	_utf16 = (_charset_form == SQLCS_NCHAR);

	// OCI_ATTR_CHAR_USED Returns the type of length semantics of the column. 0 means byte-length semantics and 1 means character-length semantics.
	// See "Character Length Semantics Support in Describing". ub4 (well docs says ub4 but it is ub1 in reality)
	_char_used = param.get_attribute<ub1>(OCI_ATTR_CHAR_USED);

	// OCI_ATTR_CHAR_SIZE Returns the column character length which is the number of characters allowed in the column.
	// It is the counterpart of OCI_ATTR_DATA_SIZE which gets the byte length. See "Character Length Semantics Support in Describing". ub2
	_char_size = param.get_attribute<ub2>(OCI_ATTR_CHAR_SIZE);

	// NOTE: older OCI docs refer OCI_ATTR_DATA_SIZE as ub2.
	// In 11gR2 it is ub4, but only ub2 works
	// OCI_ATTR_DATA_SIZE The maximum size of the column. This length is returned in bytes and not characters for strings and raws.
	// It returns 22 for NUMBERs. ub4
	// see metalink note 332084.1
	_data_size = param.get_attribute<ub2>(OCI_ATTR_DATA_SIZE);

	// OCI_ATTR_FSPRECISION The fractional seconds precision of a datetime or interval. ub1
	_fprecision = param.get_attribute<ub1>(OCI_ATTR_FSPRECISION);

	// OCI_ATTR_LFPRECISION The leading field precision of an interval. ub1
	_lfprecision = param.get_attribute<ub1>(OCI_ATTR_LFPRECISION);

	// get NULL-ability flag
	// OCI_ATTR_IS_NULL Returns 0 if null values are not permitted for the column ub1
	_is_null = param.get_attribute<ub1>(OCI_ATTR_IS_NULL);

	if(_data_type == SQLT_NTY)
	{
		sword res;
		// OCI_ATTR_REF_TDO Returns the REF of the TDO for the type, if the arguemnt type is an object OCIRef *
		_ref_tdo = param.get_attribute<OCIRef*>(OCI_ATTR_REF_TDO);

		OciDescribe type_desc(con._env);

		res = OCIDescribeAny(con._svc_ctx, con._env._errh,
		                     _ref_tdo,			// objptr (IN) pointer to a REF to the TDO
		                     sizeof(_ref_tdo),	// objnm_len (IN)
		                     OCI_OTYPE_REF,		// objptr_typ (IN) points to the name of a schema object
		                     (ub1)OCI_DEFAULT,	// info_level (IN) for future extensions. Pass OCI_DEFAULT.
		                     OCI_PTYPE_TYPE,
		                     type_desc
		                    );
		oci_check_error(__TROTL_HERE__, con._env._errh, res);

		_type = new DescribeType(con, type_desc, _name);

		_reg_name = _type->_reg_name;

		// throws ORA-24328: illegal attribute value on number
		_typecode = _type->_typecode;
		_collection_typecode = _type->_collection_typecode;
		_collection_data_type = _type->_collection_data_type;
	}
}
Пример #3
0
void colvarvalue::undef_op() const
{
  cvm::error("Error: Undefined operation on a colvar of type \""+
             type_desc(this->type())+"\".\n");
}