Type Alias CapeArrayStringVec

Source
pub type CapeArrayStringVec = CapeArrayObjectVec<CapeStringImpl, ICapeString>;
Expand description

Vector based CapeArrayStringOut implementation

ICapeArrayString 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<CapeStringImpl>.

§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 CapeArrayStringVec {
    vec: Vec<CapeStringImpl>,
    interface_vec: Vec<_ICapeString>,
    interface_ptr_vec: Vec<*mut _ICapeString>,
}

Fields§

§vec: Vec<CapeStringImpl>§interface_vec: Vec<_ICapeString>§interface_ptr_vec: Vec<*mut _ICapeString>

Implementations§

Source§

impl CapeArrayStringVec

Source

const CAPE_ARRAY_STRING_VTABLE: ICapeArrayString_VTable

interface v-table

Source

pub fn from_slice<T: AsRef<str>>(array: &[T]) -> CapeArrayStringVec

Initialize from string vector

Creates a new CapeArrayStringVec from a vector of array of strings.

§Arguments
  • array - A vector or array or slice of strings or string slices to be converted to a CapeArrayStringVec
§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
Source

pub fn as_string_vec(&self) -> Vec<String>

Return a string vector

Returns a vector of strings from the CapeArrayStringVec.

Note that this operation comes with an overhead of string conversion.

§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
let strvec = arr.as_string_vec();
assert_eq!(strvec, vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
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::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
arr.resize(3);
assert_eq!(arr.size(), 3);
Source

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

Set the content of the string array from any object that implements CapeArrayStringProviderIn.

§Arguments
  • array - An object that implements CapeArrayStringProviderIn
§Example
use cobia;

let mut arr = cobia::CapeArrayStringVec::new();
let arr1 = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
arr.set(&arr1);
assert_eq!(arr.as_string_vec(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]); //the values have been stored on the object that implements ICapeArrayString
Source

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

interface member

Source

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

interface member

Trait Implementations§

Source§

impl CapeArrayStringProviderIn for CapeArrayStringVec

Source§

fn as_cape_array_string_in(&self) -> ICapeArrayString

Convert to ICapeArrayString

Returns a reference to the ICapeArrayString interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy", "idealGasEntropy"]);
let i_cape_array_string=arr.as_cape_array_string_in();
let mut i_cape_array_string_ptr=(&i_cape_array_string as *const C::ICapeArrayString).cast_mut(); //normally a pointer to the interface is received
let sa = cobia::CapeArrayStringIn::new(&mut i_cape_array_string_ptr); //CapeArrayStringIn from *mut C::ICapeArrayString
assert_eq!(sa.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
Source§

impl CapeArrayStringProviderOut for CapeArrayStringVec

Source§

fn as_cape_array_string_out(&mut self) -> ICapeArrayString

Convert to ICapeArrayString

Returns a mutable reference to the ICapeArrayString interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayStringVec::from(&["idealGasEnthalpy", "idealGasEntropy"]);
let i_cape_array_string=arr.as_cape_array_string_out();
let mut i_cape_array_string_ptr=(&i_cape_array_string as *const C::ICapeArrayString).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayStringOut::new(&mut i_cape_array_string_ptr); //CapeArrayStringOut from *mut C::ICapeArrayString
assert_eq!(a.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
Source§

impl<T: AsRef<str>> From<&[T]> for CapeArrayStringVec

Source§

fn from(array: &[T]) -> CapeArrayStringVec

Creates a new CapeArrayStringVec from reference to a slice of strings.

§Arguments
  • array - A slice of strings or string slices to be converted to a CapeArrayStringVec
§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from(&["idealGasEnthalpy", "idealGasEntropy"]); 
assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
Source§

impl<T: AsRef<str>, const N: usize> From<&[T; N]> for CapeArrayStringVec

Source§

fn from(array: &[T; N]) -> CapeArrayStringVec

Creates a new CapeArrayStringVec from reference to a slice of strings.

§Arguments
  • array - A slice of strings or string slices to be converted to a CapeArrayStringVec
§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from(&["idealGasEnthalpy", "idealGasEntropy"]); 
assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
Source§

impl<T: CapeArrayStringProviderIn> PartialEq<T> for CapeArrayStringVec

Source§

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

Partial equality

Checks if the content of the CapeArrayStringVec is equal to the content of another object that implements CapeArrayStringProviderIn.

§Arguments
  • other - An object that implements CapeArrayStringProviderIn
§Examples
use cobia::*;
let arr1 = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
let arr2 = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
let arr3 = cobia::CapeArrayStringVec::from_slice(&["IdealGasEnthalpy", "IdealGasEntropy"]);
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.