Esempio n. 1
0
::CDB::doubleSeq * DAOImpl::get_double_seq (
	const char * propertyName
	
	)
{
	Field fld;
    if( !get_field(propertyName, fld) )
    {
	throw CDBFieldDoesNotExistExImpl (
		__FILE__, __LINE__,
		"DAOImpl::get_long").getCDBFieldDoesNotExistEx();
   }
  // I don't know why but it returns always an array of string
  if(fld.GetType() != Field::tyStringArray)
  {
	throw WrongCDBDataTypeExImpl (
		__FILE__, __LINE__,
		"DAOImpl::get_long").getWrongCDBDataTypeEx();
   }
 // create return value
 CDB::doubleSeq_var retSeq;
 try
     {
     retSeq = new CDB::doubleSeq();
     }
 catch(...)
     {
     throw CORBA::NO_MEMORY ();
     }//try-catch

 StringArray * ary = fld.GetStringArray();
  retSeq->length( ary->size() );
 CORBA::ULong n=0;
  for(StringArray::const_iterator aiter = ary->begin(); aiter != ary->end(); ++aiter) 
   {
      //retSeq[n++] = *aiter; //CORBA::long_dup( *aiter); //->c_str() );
      double dbl;
      int parsed=sscanf(aiter->c_str(),"%lf",&dbl);
      if (parsed==1) {
         retSeq[n++]=dbl;
      } else {
         // The string doesn't contain a long: throw an exception
		throw WrongCDBDataTypeExImpl (
			__FILE__, __LINE__,
			"DAOImpl::get_long").getWrongCDBDataTypeEx();
         
      }
 }
  
   return retSeq._retn();
}
Esempio n. 2
0
CDB::doubleSeq * DAOProxy::get_double_seq (const char * propertyName)
{
    //ACS_TRACE("cdb::DAOProxy::get_double_seq");

    // check remote mode
    if (m_dao.ptr() != CDB::DAO::_nil()) 
	return m_dao->get_double_seq(propertyName);

    string value;
    try{
    get_field(propertyName, value);
    }catch(cdbErrType::CDBFieldDoesNotExistExImpl ex){
	throw ex.getCDBFieldDoesNotExistEx();
    }

    VectorString array;
    split(value.c_str(), array);

    CDB::doubleSeq_var seq = new CDB::doubleSeq();
    seq->length(array.size());

    CORBA::ULong i = 0;
    for (VectorString::const_iterator iter = array.begin();
	 iter != array.end(); iter++)
	{
	std::istringstream is(iter->c_str());
	CORBA::Double val;
	(istream&) is >> val;
	if (!is)
	    throw cdbErrType::WrongCDBDataTypeExImpl(
		__FILE__, __LINE__,
		"cdb::DAOProxy::get_long" ).getWrongCDBDataTypeEx();
	seq[i++] = val;
	}

    return seq._retn();
}