pub struct CapeStringInFromProvider {
interface: ICapeString,
interface_ptr: *mut ICapeString,
}Expand description
CapeStringInFromProvider
When calling a CAPE-OPEN method that takes a CapeString as input,
the caller provides an object that implements CapeStringProviderIn,
for example CapeStringImpl.
The CapeStringInFromProvider 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 input, it received a &CapeStringIn 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 CapeStringIn 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
CapeStringProviderIn trait, allocate the pointer, point to it, and
construct the CapeStringIn object from a reference to that pointer.
The CapeStringInFromProvider class does all this.
§Example
use cobia::*;
let string = CapeStringImpl::from_string("Hello");
fn StringFromCapeStringIn(string:&CapeStringIn) -> String {
string.as_string()
}
let value=StringFromCapeStringIn(&CapeStringInFromProvider::from(&string).as_cape_string_in()); //this is how string is passed as &CapeStringIn argument
assert_eq!(value,"Hello".to_string());Fields§
§interface: ICapeString§interface_ptr: *mut ICapeString