Struct CapeStringOut

Source
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 ICapeString

Implementations§

Source§

impl<'a> CapeStringOut<'a>

Source

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");
Source

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());
Source

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");
Source

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");
Source

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());
Source

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())
Source

pub fn is_empty(&self) -> bool

Check empty

§Examples
use cobia::*;
 
fn check_empty(s: &mut CapeStringOut) {
    assert_eq!(s.is_empty(),true);
}
 
let mut s1=cobia::CapeStringImpl::new();
check_empty(&mut CapeStringOutFromProvider::from(&mut s1).as_cape_string_out());

Trait Implementations§

Source§

impl<'a> CapeStringConstProvider for CapeStringOut<'a>

Source§

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

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>

Source§

fn as_cape_string_out(&mut self) -> ICapeString

Convert to ICapeString
Source§

impl<'a> Debug for CapeStringOut<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Display for CapeStringOut<'a>

Source§

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>

Source§

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())
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.

Auto Trait Implementations§

§

impl<'a> Freeze for CapeStringOut<'a>

§

impl<'a> RefUnwindSafe for CapeStringOut<'a>

§

impl<'a> !Send for CapeStringOut<'a>

§

impl<'a> !Sync for CapeStringOut<'a>

§

impl<'a> Unpin for CapeStringOut<'a>

§

impl<'a> !UnwindSafe for CapeStringOut<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.