Type Alias CapeArrayValueVec

Source
pub type CapeArrayValueVec = CapeArrayObjectVec<CapeValueImpl, ICapeValue>;
Expand description

Vector based CapeArrayValueOut implementation

ICapeArrayValue is passed as data container between CAPE-OPEN functions. It is up to the caller to provide the interface, and its implementation. This class provides a default impementation using a Vec<CapeValueImpl>.

To manipulate the values, one could use the CapeArrayValueOut wrapper; only a limited number of functions are implemented here.

§Examples

use cobia::*;

fn set_content(a: &mut CapeArrayStringOut) {
    a.put_array(&["idealGasEnthalpy", "idealGasEntropy"]).unwrap();
}
 
let mut arr = cobia::CapeArrayStringVec::new();
set_content(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);

Aliased Type§

pub struct CapeArrayValueVec {
    vec: Vec<CapeValueImpl>,
    interface_vec: Vec<ICapeValue>,
    interface_ptr_vec: Vec<*mut ICapeValue>,
}

Fields§

§vec: Vec<CapeValueImpl>§interface_vec: Vec<ICapeValue>§interface_ptr_vec: Vec<*mut ICapeValue>

Implementations§

Source§

impl CapeArrayValueVec

Source

const CAPE_ARRAY_VALUE_VTABLE: ICapeArrayValue_VTable

interface v-table

Source

pub fn from_slice(array: &[CapeValueContent]) -> CapeArrayValueVec

Initialize from CapeValueContent slice

Creates a new CapeArrayValueVec from or slice of CapeValueContent; note that the values will be cloned.

§Arguments
  • array - A slice of values to converted to a CapeArrayValueVec
§Examples
use cobia;
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
assert_eq!(arr.as_value_vec(), vec![cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
Source

pub fn as_value_vec(&self) -> Vec<CapeValueContent>

Return a value vector

Returns a vector of values from the CapeArrayValueVec.

§Examples
use cobia;
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
let valvec = arr.as_value_vec();
assert_eq!(valvec, vec![cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
Source

pub fn resize(&mut self, size: usize)

Resize

Change the size of the vector.

§Arguments
  • size - The new size of the vector
§Example
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
arr.resize(3);
assert_eq!(arr.size(), 3);
Source

pub fn set<T: CapeArrayValueProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>

Set the content of the value array from any object that implements CapeArrayValueProviderIn.

§Arguments
  • array - An object that implements CapeArrayValueProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayValueVec::new();
let mut arr1 = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
arr.set(&arr1);
assert_eq!(arr.as_value_vec(), vec![cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
Source

extern "C" fn get( me: *mut c_void, data: *mut *mut *mut ICapeValue, size: *mut CapeSize, )

interface member

Source

extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut *mut ICapeValue, ) -> CapeResult

interface member

Trait Implementations§

Source§

impl CapeArrayValueProviderIn for CapeArrayValueVec

Source§

fn as_cape_array_value_in(&self) -> ICapeArrayValue

Convert to ICapeArrayValue

Returns a reference to the ICapeArrayValue interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let arr = cobia::CapeArrayValueVec::from_slice(&vec![cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
let i_cape_value=arr.as_cape_array_value_in();
let mut i_cape_value_ptr=(&i_cape_value as *const C::ICapeArrayValue).cast_mut(); //normally a pointer to the interface is received
let sa = cobia::CapeArrayValueIn::new(&mut i_cape_value_ptr); //CapeArrayValueIn from *mut C::ICapeArrayValue
assert_eq!(sa.as_value_vec().unwrap(), vec![cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
Source§

impl CapeArrayValueProviderOut for CapeArrayValueVec

Source§

fn as_cape_array_value_out(&mut self) -> ICapeArrayValue

Convert to ICapeArrayValue

Returns a mutable reference to the ICapeArrayValue interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
let i_cape_array_value=arr.as_cape_array_value_out();
let mut i_cape_array_value_ptr=(&i_cape_array_value as *const C::ICapeArrayValue).cast_mut(); //normally a pointer to the interface is received
let va = cobia::CapeArrayValueOut::new(&mut i_cape_array_value_ptr); //CapeArrayValueOut from *mut C::ICapeArrayValue
assert_eq!(va.as_value_vec().unwrap(), vec![cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
Source§

impl<T: CapeArrayValueProviderIn> PartialEq<T> for CapeArrayValueVec

Source§

fn eq(&self, other: &T) -> bool

Partial equality

Checks if the content of the CapeArrayValueVec is equal to the content of another object that implements CapeArrayValueProviderIn.

§Arguments
  • other - An object that implements CapeArrayValueProviderIn
§Examples
use cobia::*;
let arr1 = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
let arr2 = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
let arr3 = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Boolean(false),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
assert!(arr1 == arr2);
assert!(arr1 != arr3);
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.