pub struct CapeStringOut<'a> {
interface: &'a mut *mut ICapeString,
}Expand description
CapeStringOut wraps an ICapeString interface pointer.
Given an ICapeString interface pointer, this allows setting and getting the string.
This interface is not typically used directly as pre-generated wrappers provide input strings as str and return values as Result<&str,cobia::COBIAError>. However for output values and CapeArrayStringOut elements, this interface is used.
NULL pointers are not allowed.
§Examples
use cobia::*;
fn set_content(s: &mut CapeStringOut) {
s.set_string("idealGasEnthalpy").unwrap();
}
let mut s1=cobia::CapeStringImpl::new();
set_content(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());
assert_eq!(s1.as_string(),"idealGasEnthalpy");Fields§
§interface: &'a mut *mut ICapeStringImplementations§
Source§impl<'a> CapeStringOut<'a>
impl<'a> CapeStringOut<'a>
Sourcepub fn new(interface: &'a mut *mut ICapeString) -> CapeStringOut<'a>
pub fn new(interface: &'a mut *mut ICapeString) -> CapeStringOut<'a>
Create a new CapeStringOut from an ICapeString interface pointer.
§Arguments
interface- A pointer to an ICapeString interface
§Examples
use cobia::*;
use cobia::prelude::*;
let mut s1=cobia::CapeStringImpl::from("idealGasEnthalpy");
let i_cape_string=s1.as_cape_string_out();
let mut i_cape_string_ptr=(&i_cape_string as *const C::ICapeString).cast_mut(); //normally a pointer to the interface is received
let s = cobia::CapeStringOut::new(&mut i_cape_string_ptr); //CapeStringOut from *mut C::ICapeString
assert_eq!(s.as_string(),"idealGasEnthalpy");Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
Return the content of the string as a string.
§Examples
use cobia::*;
fn check_content(s: &mut CapeStringOut) {
assert_eq!(s.as_string(),"idealGasEnthalpy"); //return as string
}
let mut s1=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
check_content(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());Sourcepub fn set<T: CapeStringConstProvider>(&self, s: &T) -> Result<(), COBIAError>
pub fn set<T: CapeStringConstProvider>(&self, s: &T) -> Result<(), COBIAError>
Set the content of the string any CAPE-OPEN string
§Arguments
s- An object implementing CapeStringConstProvider
§Examples
use cobia::*;
fn set_content(s: &mut CapeStringOut) {
let s0=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
s.set(&s0).unwrap();
}
let mut s1=cobia::CapeStringImpl::new();
set_content(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());
assert_eq!(s1.as_string(),"idealGasEnthalpy");Sourcepub fn set_string<T: AsRef<str>>(&self, s: T) -> Result<(), COBIAError>
pub fn set_string<T: AsRef<str>>(&self, s: T) -> Result<(), COBIAError>
Set the content of the string from a string slice.
§Arguments
s- A string slice
§Examples
use cobia::*;
fn set_content(s: &mut CapeStringOut) {
s.set_string("idealGasEnthalpy").unwrap();
}
let mut s1=cobia::CapeStringImpl::new();
set_content(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());
assert_eq!(s1.as_string(),"idealGasEnthalpy");Sourcepub fn eq_ignore_case<T: CapeStringConstProvider>(&self, other: &T) -> bool
pub fn eq_ignore_case<T: CapeStringConstProvider>(&self, other: &T) -> bool
Case insentitive comparison
§Arguments
other- The other string to compare to
§Examples
use cobia::*;
fn check_string(s: &mut CapeStringOut) {
let s2=cobia::CapeStringImpl::from_string("IDEALGASENTHALPY");
assert_eq!(s.eq_ignore_case(&s2),true);
}
let mut s1=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
check_string(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());Sourcepub fn eq<T: CapeStringConstProvider>(&self, other: &T) -> bool
pub fn eq<T: CapeStringConstProvider>(&self, other: &T) -> bool
Case sentitive comparison
§Arguments
other- The other string to compare to
§Examples
use cobia::*;
fn test_string(s: &CapeStringOut) {
let s2=cobia::CapeStringImpl::from_string("IDEALGASENTHALPY");
assert_eq!(s.eq(&s2),false);
let s3=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
assert_eq!(s.eq(&s3),true);
}
let mut s1=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
test_string(&CapeStringOutFromProvider::from(&mut s1).as_cape_string_out())Trait Implementations§
Source§impl<'a> CapeStringConstProvider for CapeStringOut<'a>
impl<'a> CapeStringConstProvider for CapeStringOut<'a>
Source§fn as_capechar_const_with_length(&self) -> (*const CapeCharacter, CapeSize)
fn as_capechar_const_with_length(&self) -> (*const CapeCharacter, CapeSize)
Return as CapeCharacter const pointer with length
The caller must ensure that the lifetime of the CapeStringImpl is longer than the pointer returned.
§Examples
use cobia::*;
fn check_size(s: &mut CapeStringOut) {
let (ptr,len)=s.as_capechar_const_with_length();
assert_eq!(len,16);
}
let mut s1=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
check_size(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());Source§fn as_capechar_const(&self) -> *const CapeCharacter
fn as_capechar_const(&self) -> *const CapeCharacter
Return as CapeCharacter const pointer with length
The caller must ensure that the lifetime of the CapeStringImpl is longer than the pointer returned.
§Examples
use cobia::*;
fn check_ptr(s: &mut CapeStringOut) {
let ptr=s.as_capechar_const(); ///... while ptr is used
assert_eq!(unsafe{*ptr},'i' as u16);
}
let mut s1=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
check_ptr(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());Source§impl<'a> CapeStringProviderOut for CapeStringOut<'a>
impl<'a> CapeStringProviderOut for CapeStringOut<'a>
Source§fn as_cape_string_out(&mut self) -> ICapeString
fn as_cape_string_out(&mut self) -> ICapeString
Source§impl<'a> Debug for CapeStringOut<'a>
impl<'a> Debug for CapeStringOut<'a>
Source§impl<'a> Display for CapeStringOut<'a>
impl<'a> Display for CapeStringOut<'a>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the CapeStringOut error using the given formatter.
§Examples
use cobia::*;
fn check_format(s: &mut CapeStringOut) {
let ptr=s.as_capechar_const(); ///... while ptr is used
assert_eq!(format!("{}",s),"idealGasEnthalpy");
}
let mut s1=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
check_format(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());Source§impl<'a, T: CapeStringConstProvider> PartialEq<T> for CapeStringOut<'a>
impl<'a, T: CapeStringConstProvider> PartialEq<T> for CapeStringOut<'a>
Source§fn eq(&self, other: &T) -> bool
fn eq(&self, other: &T) -> bool
Compare the CapeStringOut with a string slice or any object that implements CapeStringConstProvider.
§Examples
use cobia::*;
fn test_string(s: &mut CapeStringOut) {
let s2=cobia::CapeStringImpl::from_string("IDEALGASENTHALPY");
assert_ne!(s,&s2);
let s3=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
assert_eq!(s,&s3);
}
let mut s1=cobia::CapeStringImpl::from_string("idealGasEnthalpy");
test_string(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out())