pub struct CapeValueImpl {
value: CapeValueContent,
str_val: CapeStringImpl,
}Expand description
Default CapeValue implementation
ICapeValue 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.
This class can be used as input and output argument.
§Examples
use cobia::*;
fn set_value(v: &mut CapeValueOut) {
v.set_string("my value").unwrap();
}
let mut val = cobia::CapeValueImpl::new();
set_value(&mut CapeValueOutFromProvider::from(&mut val).as_cape_value_out());
assert_eq!(val.value(), CapeValueContent::String("my value".into()));Fields§
§value: CapeValueContent§str_val: CapeStringImplImplementations§
Source§impl CapeValueImpl
impl CapeValueImpl
Sourceconst VTABLE: ICapeValue_VTable
const VTABLE: ICapeValue_VTable
Interface v-table
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty, CapeValueImpl
Creates a new empty CapeValueImpl
§Examples
use cobia::*;
fn set_value(v: &mut CapeValueOut) {
v.set_string("my value").unwrap();
}
let mut val = cobia::CapeValueImpl::new();
set_value(&mut CapeValueOutFromProvider::from(&mut val).as_cape_value_out());
assert_eq!(val.value(), CapeValueContent::String("my value".into()));Sourcepub fn from_str(value: &str) -> Self
pub fn from_str(value: &str) -> Self
Create a new CapeValueImpl from string
Creates a new CapeValueImpl from the given string
§Arguments
value- The initial value
§Examples
use cobia::*;
fn check_value(v: &CapeValueIn) {
assert_eq!(v.get_string().unwrap(), "C2H6".to_string());
}
let val = cobia::CapeValueImpl::from_str("C2H6");
check_value(&CapeValueInFromProvider::from(&val).as_cape_value_in());Sourcepub fn from_string(value: String) -> Self
pub fn from_string(value: String) -> Self
Create a new CapeValueImpl from string
Creates a new CapeValueImpl from the given string
§Arguments
value- The initial value
§Examples
use cobia::*;
fn check_value(v: &CapeValueIn) {
assert_eq!(v.get_string().unwrap(), "C2H6".to_string());
}
let val = cobia::CapeValueImpl::from_string("C2H6".to_string());
check_value(&CapeValueInFromProvider::from(&val).as_cape_value_in());Sourcepub fn from_content(value: CapeValueContent) -> Self
pub fn from_content(value: CapeValueContent) -> Self
Create a new CapeValueImpl from content
Creates a new CapeValueImpl from the given CapeValueContent
§Arguments
value- The initial value
§Examples
use cobia::*;
fn check_value(v: &CapeValueIn) {
assert_eq!(v.get_string().unwrap(), "n-butane".to_string());
}
let val = cobia::CapeValueImpl::from_content(cobia::CapeValueContent::String("n-butane".into()));
check_value(&CapeValueInFromProvider::from(&val).as_cape_value_in());Sourcepub fn from_integer(value: CapeInteger) -> Self
pub fn from_integer(value: CapeInteger) -> Self
Create a new CapeValueImpl from integer
Creates a new CapeValueImpl from the given integer
§Arguments
value- The initial value
§Examples
use cobia::*;
fn check_value(v: &CapeValueIn) {
assert_eq!(v.get_integer().unwrap(),5);
}
let val = cobia::CapeValueImpl::from_integer(5);
check_value(&CapeValueInFromProvider::from(&val).as_cape_value_in());Sourcepub fn from_boolean(value: bool) -> Self
pub fn from_boolean(value: bool) -> Self
Create a new CapeValueImpl from boolean
Creates a new CapeValueImpl from the given boolean
§Arguments
value- The initial value
§Examples
use cobia::*;
fn check_value(v: &CapeValueIn) {
assert_eq!(v.get_boolean().unwrap(),false);
}
let val = cobia::CapeValueImpl::from_boolean(false);
check_value(&CapeValueInFromProvider::from(&val).as_cape_value_in());Sourcepub fn from_real(value: CapeReal) -> Self
pub fn from_real(value: CapeReal) -> Self
Create a new CapeValueImpl from real
Creates a new CapeValueImpl from the given real
§Arguments
value- The initial value
§Examples
use cobia::*;
fn check_value(v: &CapeValueIn) {
assert_eq!(v.get_real().unwrap(),3.0);
}
let val = cobia::CapeValueImpl::from_real(3.0);
check_value(&CapeValueInFromProvider::from(&val).as_cape_value_in());Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Set to empty
Change the type to empty
§Examples
use cobia::*;
let mut val = cobia::CapeValueImpl::from_real(3.0);
val.reset();
assert_eq!(val.value(), CapeValueContent::Empty);Sourcepub fn set_string(&mut self, value: String)
pub fn set_string(&mut self, value: String)
Sourcepub fn set_integer(&mut self, value: CapeInteger)
pub fn set_integer(&mut self, value: CapeInteger)
Sourcepub fn set_boolean(&mut self, value: bool)
pub fn set_boolean(&mut self, value: bool)
Set to boolean
Change the type to the given boolean
§Arguments
value- The new value
§Examples
use cobia::*;
let mut val = cobia::CapeValueImpl::new();
val.set_boolean(true);
assert_eq!(val.value(), CapeValueContent::Boolean(true));
val.set_boolean(false);
assert_eq!(val.value(), CapeValueContent::Boolean(false));Sourcepub fn set<T: CapeValueProviderIn>(&mut self, val: &T) -> Result<(), COBIAError>
pub fn set<T: CapeValueProviderIn>(&mut self, val: &T) -> Result<(), COBIAError>
Set the content of the value from any object that implements CapeValueProviderIn.
§Arguments
val- An object that implements CapeValueProviderIn
§Example
use cobia;
let mut val = cobia::CapeValueImpl::new();
let val1 = cobia::CapeValueImpl::from_str("test");
val.set(&val1);
assert_eq!(val.value(), cobia::CapeValueContent::String("test".into()));
fn set_value(val: &mut cobia::CapeValueImpl,v: &cobia::CapeValueIn) {
val.set(v);
}
let val2 = cobia::CapeValueImpl::from_str("test2");
set_value(&mut val,&cobia::CapeValueInFromProvider::from(&val2).as_cape_value_in());
assert_eq!(val.value(), cobia::CapeValueContent::String("test2".into()));Sourcepub fn value_ref(&self) -> &CapeValueContent
pub fn value_ref(&self) -> &CapeValueContent
Get a reference to the value
Returns a reference to the value
§Examples
use cobia;
let val = cobia::CapeValueImpl::from_str("test");
assert_eq!(val.value_ref(),&cobia::CapeValueContent::String("test".into()));Sourcepub fn value_ref_mut(&mut self) -> &mut CapeValueContent
pub fn value_ref_mut(&mut self) -> &mut CapeValueContent
Get a mutable reference to the value
Returns a mutable reference to the value
§Examples
use cobia;
use cobia::prelude::*;
let mut val = cobia::CapeValueImpl::from_integer(2);
*val.value_ref_mut()=cobia::CapeValueContent::Boolean(false);
assert_eq!(val.value_ref(),&cobia::CapeValueContent::Boolean(false));Sourcepub fn value(&self) -> CapeValueContent
pub fn value(&self) -> CapeValueContent
Get a clone of the value
Returns a clone of the value
§Examples
use cobia;
use cobia::prelude::*;
let val = cobia::CapeValueImpl::from_integer(2);
assert_eq!(val.value(),cobia::CapeValueContent::Integer(2));Sourceextern "C" fn get_value_type(me: *mut c_void) -> CapeValueType
extern "C" fn get_value_type(me: *mut c_void) -> CapeValueType
Interface member function
Sourceextern "C" fn get_string_value(
me: *mut c_void,
data: *mut *const CapeCharacter,
size: *mut CapeSize,
) -> CapeResult
extern "C" fn get_string_value( me: *mut c_void, data: *mut *const CapeCharacter, size: *mut CapeSize, ) -> CapeResult
Interface member function
Sourceextern "C" fn get_integer_value(
me: *mut c_void,
value: *mut CapeInteger,
) -> CapeResult
extern "C" fn get_integer_value( me: *mut c_void, value: *mut CapeInteger, ) -> CapeResult
Interface member function
Sourceextern "C" fn get_boolean_value(
me: *mut c_void,
value: *mut CapeBoolean,
) -> CapeResult
extern "C" fn get_boolean_value( me: *mut c_void, value: *mut CapeBoolean, ) -> CapeResult
Interface member function
Sourceextern "C" fn get_real_value(
me: *mut c_void,
value: *mut CapeReal,
) -> CapeResult
extern "C" fn get_real_value( me: *mut c_void, value: *mut CapeReal, ) -> CapeResult
Interface member function
Sourceextern "C" fn set_string_value(
me: *mut c_void,
data: *const CapeCharacter,
size: CapeSize,
) -> CapeResult
extern "C" fn set_string_value( me: *mut c_void, data: *const CapeCharacter, size: CapeSize, ) -> CapeResult
Interface member function
Sourceextern "C" fn set_integer_value(
me: *mut c_void,
value: CapeInteger,
) -> CapeResult
extern "C" fn set_integer_value( me: *mut c_void, value: CapeInteger, ) -> CapeResult
Interface member function
Sourceextern "C" fn set_boolean_value(
me: *mut c_void,
value: CapeBoolean,
) -> CapeResult
extern "C" fn set_boolean_value( me: *mut c_void, value: CapeBoolean, ) -> CapeResult
Interface member function
Sourceextern "C" fn set_real_value(
me: *mut c_void,
value: CapeReal,
) -> CapeResult
extern "C" fn set_real_value( me: *mut c_void, value: CapeReal, ) -> CapeResult
Interface member function
Sourceextern "C" fn clear(me: *mut c_void) -> CapeResult
extern "C" fn clear(me: *mut c_void) -> CapeResult
Interface member function
Trait Implementations§
Source§impl CapeValueProviderIn for CapeValueImpl
impl CapeValueProviderIn for CapeValueImpl
Source§fn as_cape_value_in(&self) -> ICapeValue
fn as_cape_value_in(&self) -> ICapeValue
Convert to ICapeValue
Returns a reference to the ICapeValue interface.
§Examples
use cobia::*;
use cobia::prelude::*;
let val = cobia::CapeValueImpl::from_integer(2);
let i_cape_value=val.as_cape_value_in();
let mut i_cape_value_ptr=(&i_cape_value as *const C::ICapeValue).cast_mut(); //normally a pointer to the interface is received
let v = cobia::CapeValueIn::new(&mut i_cape_value_ptr); //CapeValueIn from *mut C::ICapeValue
assert_eq!(v.get_integer().unwrap(), 2);Source§impl CapeValueProviderOut for CapeValueImpl
impl CapeValueProviderOut for CapeValueImpl
Source§fn as_cape_value_out(&mut self) -> ICapeValue
fn as_cape_value_out(&mut self) -> ICapeValue
Convert to ICapeValue
Returns a mutable reference to the ICapeValue interface.
§Examples
use cobia::*;
use cobia::prelude::*;
let mut val = cobia::CapeValueImpl::new();
let i_cape_value=val.as_cape_value_out();
let mut i_cape_value_ptr=(&i_cape_value as *const C::ICapeValue).cast_mut(); //normally a pointer to the interface is received
let mut v = cobia::CapeValueOut::new(&mut i_cape_value_ptr); //CapeValueOut from *mut C::ICapeValue
v.set_real(2.5).unwrap();
assert_eq!(val.value(), cobia::cape_value_impl::CapeValueContent::Real(2.5));Source§impl Clone for CapeValueImpl
impl Clone for CapeValueImpl
Source§fn clone(&self) -> CapeValueImpl
fn clone(&self) -> CapeValueImpl
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for CapeValueImpl
impl Default for CapeValueImpl
Source§impl<T: CapeValueProviderIn> PartialEq<T> for CapeValueImpl
impl<T: CapeValueProviderIn> PartialEq<T> for CapeValueImpl
Source§fn eq(&self, other: &T) -> bool
fn eq(&self, other: &T) -> bool
Partial equality
Checks if the content of the CapeValueVec is equal to the content of another object that implements CapeValueProviderIn.
§Arguments
other- An object that implements CapeValueProviderIn
§Examples
use cobia::*;
let val1 = cobia::CapeValueImpl::from_integer(2);
let val2 = cobia::CapeValueImpl::from_integer(2);
let val3 = cobia::CapeValueImpl::from_boolean(true);
assert!(val1 == val2);
assert!(val1 != val3);