pub struct CapeStringOutFromProvider {
interface: ICapeString,
interface_ptr: *mut ICapeString,
}Expand description
CapeStringOutFromProvider
When calling a CAPE-OPEN method that takes a CapeString as output,
the caller provides an object that implements CapeStringProviderOut,
for example CapeStringImpl.
The CapeStringOutFromProvider returns an C::ICapeString interface, which
has a small life span, enough to make sure that the pointer to this
interface is valid. This is done inside wrapper classes such as
capeopen_1_2::CapeIdentification,
When implementing a function that gets called, and takes a CapeString
as output, it received a &mut CapeStringOut typed argument, which is
constructed from the reference to an C::ICapeString interface pointer.
Typically a function call receives the C::ICapeString interface
from the caller, and from this, the CapeStringOut is constructed by
the cape_object_implementation macro.
In the rare case that one wants to call an internal CAPE-OPEN function
directly, one needs to provide the class that implements the
CapeStringProviderOut trait, allocate the pointer, point to it, and
construct the CapeStringOut object from a reference to that pointer.
The CapeStringOutFromProvider class does all this.
§Example
use cobia::*;
let mut string = CapeStringImpl::new();
fn SetCapeStringOut(string:&CapeStringOut) {
string.set_string("Hello");
}
SetCapeStringOut(&mut CapeStringOutFromProvider::from(&mut string).as_cape_string_out()); //this is how string is passed as &mut CapeStringOut argument
assert_eq!(string.as_string(),"Hello".to_string());Fields§
§interface: ICapeString§interface_ptr: *mut ICapeString