pub struct CapeStringConstNoCase {
data: Vec<CapeCharacter>,
}Expand description
Class to store a platform dependent string encoding for use in case insensitive hash maps or for use of case insensitive comparisons.
For COBIA, strings go over the pipeline as null terminated. For Windows, COBIA requires UTF-16 encoding.
Because this translation is always required, there is no read-only string implementation that refers to a string slice. However, this string implementation is immutable and can therefore be used as static.
This implementation uses a Vec<u16> to store the string data.
A common use case in CAPE-OPEN is to to have a string constant
for comparison with CapeString-like objects. This class is a
specialization for this purpose: the string is stored in
lower case, and PartialEq does case insensitive comparison.
Another common use case in CAPE-OPEN is to make hash maps of
strings for case-insentive lookups. A specialized class is
available for this purpose: CapeStringHashKey.
PartialEq can be directly used to for a CapeStringConstNoCase on the left, and any object implementing CapeStringConstProvider on the right (but not vice versa)
§Examples
use cobia::*;
use cobia::prelude::*;
let s=cobia::CapeStringConstNoCase::from_string("idealGasEnthalpy");
let s2=cobia::CapeStringImpl::from_string("IDEALGASENTHALPY");
assert_eq!(s,s2);
fn test_eq(s:CapeStringConstNoCase, s3:&CapeStringIn) {
assert_eq!(&s,s3);
}
test_eq(s,&CapeStringInFromProvider::from(&s2).as_cape_string_in()); Fields§
§data: Vec<CapeCharacter>Implementations§
Source§impl CapeStringConstNoCase
impl CapeStringConstNoCase
Sourcepub fn from_string<T: AsRef<str>>(s: T) -> Self
pub fn from_string<T: AsRef<str>>(s: T) -> Self
Sourcepub fn from_cape_char_const(ptr: *const CapeCharacter, size: CapeSize) -> Self
pub fn from_cape_char_const(ptr: *const CapeCharacter, size: CapeSize) -> Self
Construct from CapeCharacter pointer
§Arguments
ptr- A const CapeCharacter pointersize- Length of the string pointed to
Source§impl CapeStringConstNoCase
impl CapeStringConstNoCase
const CAPE_STRING_VTABLE: ICapeString_VTable
extern "C" fn string_get( me: *mut c_void, data: *mut *const CapeCharacter, size: *mut CapeSize, )
extern "C" fn string_set( me: *mut c_void, data: *const CapeCharacter, size: CapeSize, ) -> CapeResult
Trait Implementations§
Source§impl CapeStringConstProvider for CapeStringConstNoCase
impl CapeStringConstProvider for CapeStringConstNoCase
Source§fn as_capechar_const(&self) -> *const CapeCharacter
fn as_capechar_const(&self) -> *const CapeCharacter
Return as CapeCharacter const pointer
The caller must ensure that the lifetime of the CapeStringImpl is longer than the pointer returned.
§Examples
use cobia;
use cobia::prelude::*;
let s=cobia::CapeStringConstNoCase::from_string("idealGasEnthalpy"); //must remain in scope....
let ptr=s.as_capechar_const(); ///... while ptr is used
assert_eq!(unsafe{*ptr},'i' as u16);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;
use cobia::prelude::*;
let s=cobia::CapeStringConstNoCase::from_string("idealGasEnthalpy"); //must remain in scope....
let (ptr,len)=s.as_capechar_const_with_length(); ///... while ptr is used
assert_eq!(len,16);Source§impl CapeStringProviderIn for CapeStringConstNoCase
impl CapeStringProviderIn for CapeStringConstNoCase
Source§fn as_cape_string_in(&self) -> ICapeString
fn as_cape_string_in(&self) -> ICapeString
Source§impl Clone for CapeStringConstNoCase
impl Clone for CapeStringConstNoCase
Source§impl Debug for CapeStringConstNoCase
impl Debug for CapeStringConstNoCase
Source§impl Display for CapeStringConstNoCase
impl Display for CapeStringConstNoCase
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the CapeStringConstNoCase error using the given formatter.
§Examples
use cobia;
let s=cobia::CapeStringConstNoCase::from_string("idealGasEnthalpy");
assert_eq!(format!("{}",s),"idealgasenthalpy"); //note that CapeStringConstNoCase stores strings in lower case