pub struct CapeArrayStringOut<'a> {
interface: &'a mut *mut ICapeArrayString,
data: *mut *mut ICapeString,
size: CapeSize,
}Expand description
CapeArrayStringOut wraps an ICapeArrayString interface pointer.
Given a reference to an ICapeArrayString interface pointer, this allows setting and getting the elements.
This interface is typically used as arguments to rust methods on traits that are generated from CAPE-OPEN interfaces that have ICapeArrayString output arguments.
NULL interface pointers are not allowed.
§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()]);Fields§
§interface: &'a mut *mut ICapeArrayString§data: *mut *mut ICapeString§size: CapeSizeImplementations§
Source§impl<'a> CapeArrayStringOut<'a>
impl<'a> CapeArrayStringOut<'a>
Sourcepub fn new(interface: &'a mut *mut ICapeArrayString) -> CapeArrayStringOut<'a>
pub fn new(interface: &'a mut *mut ICapeArrayString) -> CapeArrayStringOut<'a>
Create a new CapeStringOut from an ICapeArrayString interface pointer.
§Arguments
interface- A pointer to an ICapeArrayString interface
§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
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 sa = cobia::CapeArrayStringOut::new(&mut i_cape_array_string_ptr); //CapeArrayStringOut from *mut C::ICapeArrayString
assert_eq!(sa.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);Sourcepub fn as_string_vec(&self) -> Vec<String>
pub fn as_string_vec(&self) -> Vec<String>
Return the content of the string array as a string vector.
§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
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 sa = cobia::CapeArrayStringOut::new(&mut i_cape_array_string_ptr); //CapeArrayStringOut from *mut C::ICapeArrayString
assert_eq!(sa.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Return the size of the vector
§Examples
use cobia::*;
fn test_size(a: &mut CapeArrayStringOut) {
assert_eq!(a.size(), 2);
}
let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_size(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if the array is empty
§Examples
use cobia::*;
fn test_empty(a: &mut CapeArrayStringOut) {
assert!(a.is_empty());
}
let mut arr = cobia::CapeArrayStringVec::new();
test_empty(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());Sourcepub fn put_array<T: AsRef<str>>(
&mut self,
array: &[T],
) -> Result<(), COBIAError>
pub fn put_array<T: AsRef<str>>( &mut self, array: &[T], ) -> Result<(), COBIAError>
Set the content of the string array from a slice of string slices.
§Arguments
arr- A slice or array of vector of strings or string slices
§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()]);Sourcepub fn at(&self, index: usize) -> Result<CapeStringOut<'a>, COBIAError>
pub fn at(&self, index: usize) -> Result<CapeStringOut<'a>, COBIAError>
Get an element
§Arguments
index- The index of the element to get
Note that neither Index and IndexMut is provided for CapeArrayStringOut, because these interfaces yield a reference to the element, whereas the elements of CapeArrayStringOut are represented by an interface, which is conveniently wrapped into CapeStringOut.
Note that the life time of the CapeStringOut is tied to the life time of the CapeArrayStringOut.
§Examples
use cobia::*;
fn test_element(a: &mut CapeArrayStringOut) {
assert_eq!(a.at(1).unwrap().to_string(), "idealGasEntropy".to_string());
}
let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_element(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());Sourcepub fn resize(&mut self, size: usize) -> Result<(), COBIAError>
pub fn resize(&mut self, size: usize) -> Result<(), COBIAError>
Resize
§Arguments
size- The new size of the array
§Examples
use cobia::*;
fn set_content(a: &mut CapeArrayStringOut) {
a.resize(3).unwrap();
a.at(0).unwrap().set_string("idealGasEnthalpy").unwrap();
a.at(1).unwrap().set_string("idealGasEntropy").unwrap();
a.at(2).unwrap().set_string("density").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(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string(), "density".to_string()]); //the values have been stored on the object that implements ICapeArrayStringSourcepub fn set_string<T: AsRef<str>>(
&mut self,
index: usize,
value: T,
) -> Result<(), COBIAError>
pub fn set_string<T: AsRef<str>>( &mut self, index: usize, value: T, ) -> Result<(), COBIAError>
Set an element
§Arguments
index- The index of the element to setvalue- The value to set
§Examples
use cobia::*;
fn set_content(a: &mut CapeArrayStringOut) {
a.resize(3).unwrap();
a.at(0).unwrap().set_string("idealGasEnthalpy").unwrap();
a.at(1).unwrap().set_string("idealGasEntropy").unwrap();
a.at(2).unwrap().set_string("density").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(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string(), "density".to_string()]); //the values have been stored on the object that implements ICapeArrayStringSourcepub fn set<T: CapeArrayStringProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
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
§Examples
use cobia::*;
let mut arr = cobia::CapeArrayStringVec::new();
let mut arr1 = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out().set(&arr1);
assert_eq!(arr.as_string_vec(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]); //the values have been stored on the object that implements ICapeArrayStringSource§impl<'a> CapeArrayStringOut<'a>
impl<'a> CapeArrayStringOut<'a>
Sourcepub fn iter(&self) -> CapeArrayStringIterator<'_> ⓘ
pub fn iter(&self) -> CapeArrayStringIterator<'_> ⓘ
Return an iterator over the string array.
§Examples
use cobia::*;
fn test_iter(a: &mut CapeArrayStringOut) {
let mut iter = a.iter();
assert_eq!(iter.next().unwrap().to_string(), "idealGasEnthalpy".to_string());
assert_eq!(iter.next().unwrap().to_string(), "idealGasEntropy".to_string());
assert!(!iter.next().is_some());
}
let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_iter(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());Trait Implementations§
Source§impl<'a> CapeArrayStringProviderOut for CapeArrayStringOut<'a>
impl<'a> CapeArrayStringProviderOut for CapeArrayStringOut<'a>
Source§fn as_cape_array_string_out(&mut self) -> ICapeArrayString
fn as_cape_array_string_out(&mut self) -> ICapeArrayString
Source§impl<'a> Display for CapeArrayStringOut<'a>
impl<'a> Display for CapeArrayStringOut<'a>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Display the content of the string array as a string vector.
§Examples
use cobia::*;
fn test_format(a: &mut CapeArrayStringOut) {
assert_eq!(format!("{}", a), "[\"idealGasEnthalpy\", \"idealGasEntropy\"]");
}
let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_format(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());