cobia/
cape_array_string.rs

1use crate::{CapeArrayStringProviderIn,CapeArrayStringProviderOut,CapeStringIn,CapeStringOut,CapeArrayStringInFromProvider};
2use std::fmt;
3use std::marker::PhantomData;
4
5use crate::COBIAError;
6use crate::C;
7use crate::cape_result_value::*;
8
9/// CapeArrayStringIn wraps an ICapeArrayString interface pointer in a read-only manner
10///
11/// Given a reference to an ICapeArrayString interface pointer, this allows getting,
12/// but not setting the elements.
13///
14/// This interface is typically used as arguments to rust methods
15/// on traits that are generated from CAPE-OPEN interfaces that have
16/// ICapeArrayString input arguments.
17///
18/// A NULL interface pointer is treated as an empty array.
19///
20/// # Examples
21///
22/// ```
23/// use cobia::*;
24///
25/// fn test_content(a: &CapeArrayStringIn) {
26///		assert_eq!(a.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
27/// }
28/// 
29/// let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
30/// test_content(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
31/// ```
32
33pub struct CapeArrayStringIn<'a> {
34	data: *mut *mut C::ICapeString,
35	size: C::CapeSize,
36	interface : &'a *mut C::ICapeArrayString,
37	_lifetime: PhantomData<&'a ()> //even though we do not refer to the interace after contruction, life time is bound to the interface, as each of the elements are
38}
39
40impl<'a> CapeArrayStringIn<'a> {
41	/// Create a new CapeStringIn from an ICapeArrayString interface pointer.
42	///
43	/// # Arguments
44	///
45	/// * `interface` - A pointer to an ICapeArrayString interface
46	///
47	/// # Examples
48	///
49	/// ```
50	/// use cobia::*;
51	/// use cobia::prelude::*;
52	/// let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
53	///	let i_cape_array_string=arr.as_cape_array_string_in();
54	///	let mut i_cape_array_string_ptr=(&i_cape_array_string as *const C::ICapeArrayString).cast_mut(); //normally a pointer to the interface is received
55	///	let sa = cobia::CapeArrayStringIn::new(&mut i_cape_array_string_ptr); //CapeArrayStringIn from *mut C::ICapeArrayString
56	/// assert_eq!(sa.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
57	/// ```
58
59	pub fn new(interface: &'a *mut C::ICapeArrayString) -> CapeArrayStringIn<'a> {
60		if interface.is_null() {
61			CapeArrayStringIn {
62				data: std::ptr::null_mut(),
63				size: 0,
64				interface,
65				_lifetime : std::default::Default::default()
66			}
67		} else {
68			let mut data: *mut *mut C::ICapeString = std::ptr::null_mut();
69			let mut size: C::CapeSize = 0;
70			unsafe { (*(**interface).vTbl).get.unwrap()((**interface).me, &mut data, &mut size) };
71			CapeArrayStringIn {
72				data,
73				size,
74				interface,
75				_lifetime : std::default::Default::default()
76			}
77		}
78	}
79
80	/// Return the size of the vector
81	///
82	/// # Examples
83	///
84	/// ```
85	/// use cobia::*;
86	///
87	/// fn test_size(a: &CapeArrayStringIn) {
88	///		assert_eq!(a.size(), 2);
89	/// }
90	/// 
91	/// let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
92	/// test_size(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
93	/// ```
94	pub fn size(&self) -> usize {
95		self.size as usize
96	}
97
98	/// Check if the array is empty
99	///
100	/// # Examples
101	///
102	/// ```
103	/// use cobia::*;
104	///
105	/// fn test_empty(a: &CapeArrayStringIn) {
106	///		assert!(a.is_empty());
107	/// }
108	/// 
109	/// let arr = cobia::CapeArrayStringVec::new();
110	/// test_empty(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
111	/// ```
112	pub fn is_empty(&self) -> bool {
113		self.size == 0
114	}
115
116	/// Return the content of the string array as a string vector.
117	///
118	/// # Examples
119	///
120	/// ```
121	/// use cobia::*;
122	///
123	/// fn test_content(a: &CapeArrayStringIn) {
124	///		assert_eq!(a.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
125	/// }
126	/// 
127	/// let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
128	/// test_content(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
129	/// ```
130
131	pub fn as_string_vec(&self) -> Vec<String> {
132		let mut vec = Vec::new();
133		vec.reserve(self.size as usize);
134		for i in 0..self.size {
135			let p=unsafe { *self.data.add(i as usize) };
136			if p.is_null() {
137				//this provided by the implementor of ICapeArrayString and should not be null
138				vec.push(String::new());
139			} else {
140				vec.push(CapeStringIn::new(&p).as_string());
141			}
142		}
143		vec
144	}
145
146	/// Get an element
147	///
148	/// # Arguments
149	///
150	/// * `index` - The index of the element to get
151	/// 
152	/// Note that neither Index and IndexMut is 
153	/// provided for CapeArrayStringIn, because these interfaces
154	/// yield a reference to the element, whereas the elements
155	/// of CapeArrayStringIn are represented by an interface,
156	/// which is conveniently wrapped into CapeStringIn. 
157	/// 
158	/// Note that the life time of the CapeStringIn is tied to the
159	/// life time of the CapeArrayStringIn.
160	///
161	/// # Examples
162	///
163	/// ```
164	/// use cobia::*;
165	///
166	/// fn test_element(a: &CapeArrayStringIn) {
167	///		assert_eq!(a.at(1).unwrap().to_string(), "idealGasEntropy".to_string());
168	/// }
169	/// 
170	/// let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
171	/// test_element(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
172	/// ```
173
174	pub fn at(&self, index: usize) -> Result<CapeStringIn<'a>, COBIAError> {
175		if index >= self.size as usize {
176			return Err(COBIAError::Code(COBIAERR_NOSUCHITEM));
177		}
178		let p=unsafe { self.data.add(index) };
179		if (unsafe { *p }).is_null() {
180			//this provided by the implementor of ICapeArrayString and should not be null
181			Err(COBIAError::Code(COBIAERR_NULLPOINTER))
182		} else {
183			Ok(CapeStringIn::new(unsafe { &mut *p} ))
184		}
185	}
186}
187
188pub struct CapeArrayStringInIterator<'a> {
189	arr: &'a CapeArrayStringIn<'a>,
190	index: usize,
191}
192
193impl<'a> Iterator for CapeArrayStringInIterator<'a> {
194	type Item = CapeStringIn<'a>;
195
196	fn next(&mut self) -> Option<Self::Item> {
197		if self.index < self.arr.size as usize {
198			let res = self.arr.at(self.index);
199			self.index += 1;
200			Some(res.unwrap())
201		} else {
202			None
203		}
204	}
205}
206
207impl<'a> CapeArrayStringIn<'a> {
208	/// Return an iterator over the string array.
209	///
210	/// # Examples
211	///
212	/// ```
213	/// use cobia::*;
214	///
215	/// fn test_iter(a: &CapeArrayStringIn) {
216	///		let mut iter = a.iter();
217	///		assert_eq!(iter.next().unwrap().to_string(), "idealGasEnthalpy".to_string());
218	///		assert_eq!(iter.next().unwrap().to_string(), "idealGasEntropy".to_string());
219	///		assert!(!iter.next().is_some());
220	/// }
221	/// 
222	/// let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
223	/// test_iter(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
224	/// ```
225
226	pub fn iter(&self) -> CapeArrayStringInIterator<'_> {
227		CapeArrayStringInIterator {
228			arr: &self,
229			index: 0,
230		}
231	}
232}
233
234impl<'a> fmt::Display for CapeArrayStringIn<'a> {
235	/// Display the content of the string array as a string vector.
236	///
237	/// # Examples
238	///
239	/// ```
240	/// use cobia::*;
241	///
242	/// fn test_format(a: &CapeArrayStringIn) {
243	///		assert_eq!(format!("{}", a), "[\"idealGasEnthalpy\", \"idealGasEntropy\"]");
244	/// }
245	/// 
246	/// let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
247	/// test_format(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
248	/// ```
249
250	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
251		write!(f, "[")?;
252		for (count, v) in self.iter().enumerate() {
253			if count != 0 {
254				write!(f, ", ")?;
255			}
256			write!(f, "\"{}\"", v)?;
257		}
258		write!(f, "]")
259	}
260}
261
262impl<'a> CapeArrayStringProviderIn for CapeArrayStringIn<'a> {
263	fn as_cape_array_string_in(&self) -> C::ICapeArrayString {
264		unsafe { **self.interface }
265	}
266}
267
268/// CapeArrayStringOut wraps an ICapeArrayString interface pointer.
269///
270/// Given a reference to an ICapeArrayString interface pointer, this allows setting
271///  and getting the elements.
272///
273/// This interface is typically used as arguments to rust methods
274/// on traits that are generated from CAPE-OPEN interfaces that have
275/// ICapeArrayString output arguments.
276///
277/// NULL interface pointers are not allowed.
278///
279/// # Examples
280///
281/// ```
282/// use cobia::*;
283///
284/// fn set_content(a: &mut CapeArrayStringOut) {
285///		a.put_array(&["idealGasEnthalpy", "idealGasEntropy"]).unwrap();
286/// }
287/// 
288/// let mut arr = cobia::CapeArrayStringVec::new();
289/// set_content(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
290/// assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
291/// ```
292
293pub struct CapeArrayStringOut<'a> {
294	interface: &'a mut *mut C::ICapeArrayString,
295	data: *mut *mut C::ICapeString,
296	size: C::CapeSize,
297}
298
299impl<'a> CapeArrayStringOut<'a> {
300	/// Create a new CapeStringOut from an ICapeArrayString interface pointer.
301	///
302	/// # Arguments
303	///
304	/// * `interface` - A pointer to an ICapeArrayString interface
305	///
306	/// # Examples
307	///
308	/// ```
309	/// use cobia::*;
310	/// use cobia::prelude::*;
311	/// let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
312	///	let i_cape_array_string=arr.as_cape_array_string_out();
313	///	let mut i_cape_array_string_ptr=(&i_cape_array_string as *const C::ICapeArrayString).cast_mut(); //normally a pointer to the interface is received
314	///	let sa = cobia::CapeArrayStringOut::new(&mut i_cape_array_string_ptr); //CapeArrayStringOut from *mut C::ICapeArrayString
315	/// assert_eq!(sa.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
316	/// ```
317
318	pub fn new(interface: &'a mut *mut C::ICapeArrayString) -> CapeArrayStringOut<'a> {
319		let mut data: *mut *mut C::ICapeString = std::ptr::null_mut();
320		let mut size: C::CapeSize = 0;
321		unsafe {
322			(*(**interface).vTbl).get.unwrap()((**interface).me, &mut data, &mut size);
323		}
324		CapeArrayStringOut {
325			interface,
326			data,
327			size,
328		}
329	}
330
331	/// Return the content of the string array as a string vector.
332	///
333	/// # Examples
334	///
335	/// ```
336	/// use cobia::*;
337	/// use cobia::prelude::*;
338	/// let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
339	///	let i_cape_array_string=arr.as_cape_array_string_out();
340	///	let mut i_cape_array_string_ptr=(&i_cape_array_string as *const C::ICapeArrayString).cast_mut(); //normally a pointer to the interface is received
341	///	let sa = cobia::CapeArrayStringOut::new(&mut i_cape_array_string_ptr); //CapeArrayStringOut from *mut C::ICapeArrayString
342	/// assert_eq!(sa.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
343	/// ```
344
345	pub fn as_string_vec(&self) -> Vec<String> {
346		let mut vec = Vec::new();
347		vec.reserve(self.size as usize);
348		for i in 0..self.size {
349			let p=unsafe { self.data.add(i as usize) };
350			if p.is_null() {
351				//this provided by the implementor of ICapeArrayString and should not be null
352				vec.push(String::new());
353			} else {
354				vec.push(CapeStringOut::new(unsafe { &mut *p }).as_string());
355			}
356		}
357		vec
358	}
359
360	/// Return the size of the vector
361	///
362	/// # Examples
363	///
364	/// ```
365	/// use cobia::*;
366	///
367	/// fn test_size(a: &mut CapeArrayStringOut) {
368	///		assert_eq!(a.size(), 2);
369	/// }
370	/// 
371	/// let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
372	/// test_size(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
373	/// ```
374	pub fn size(&self) -> usize {
375		self.size as usize
376	}
377
378	/// Check if the array is empty
379	///
380	/// # Examples
381	///
382	/// ```
383	/// use cobia::*;
384	///
385	/// fn test_empty(a: &mut CapeArrayStringOut) {
386	///		assert!(a.is_empty());
387	/// }
388	/// 
389	/// let mut arr = cobia::CapeArrayStringVec::new();
390	/// test_empty(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
391	/// ```
392	pub fn is_empty(&self) -> bool {
393		self.size == 0
394	}
395
396	/// Set the content of the string array from a slice of string slices.
397	///
398	/// # Arguments
399	///
400	/// * `arr` - A slice or array of vector of strings or string slices
401	///
402	/// # Examples
403	///
404	/// ```
405	/// use cobia::*;
406	///
407	/// fn set_content(a: &mut CapeArrayStringOut) {
408	///		a.put_array(&["idealGasEnthalpy", "idealGasEntropy"]).unwrap();
409	/// }
410	/// 
411	/// let mut arr = cobia::CapeArrayStringVec::new();
412	/// set_content(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
413	/// assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
414	/// ```
415
416	pub fn put_array<T: AsRef<str>>(&mut self, array: &[T]) -> Result<(), COBIAError> {
417		let mut data:*mut *mut C::ICapeString=std::ptr::null_mut();
418		let res = unsafe {
419			(*(**self.interface).vTbl).setsize.unwrap()(
420				(**self.interface).me,
421				array.len() as C::CapeSize,
422				&mut data,
423			)
424		};
425		if res == COBIAERR_NOERROR {
426			self.size = array.len() as C::CapeSize;
427			self.data=data;
428			for (i, s) in array.iter().enumerate() {
429				let p=unsafe { self.data.add(i as usize) }; 
430				if p.is_null() {
431					//this provided by the implementor of ICapeArrayString and should not be null
432					return Err(COBIAError::Code(COBIAERR_NULLPOINTER));
433				}
434				let el = CapeStringOut::new(unsafe { &mut *p });
435				el.set_string((*s).as_ref())?;
436			}
437			Ok(())
438		} else {
439			Err(COBIAError::Code(res))
440		}
441	}
442
443	/// Get an element
444	///
445	/// # Arguments
446	///
447	/// * `index` - The index of the element to get
448	/// 
449	/// Note that neither Index and IndexMut is 
450	/// provided for CapeArrayStringOut, because these interfaces
451	/// yield a reference to the element, whereas the elements
452	/// of CapeArrayStringOut are represented by an interface,
453	/// which is conveniently wrapped into CapeStringOut. 
454	/// 
455	/// Note that the life time of the CapeStringOut is tied to the
456	/// life time of the CapeArrayStringOut.
457	///
458	/// # Examples
459	///
460	/// ```
461	/// use cobia::*;
462	///
463	/// fn test_element(a: &mut CapeArrayStringOut) {
464	///		assert_eq!(a.at(1).unwrap().to_string(), "idealGasEntropy".to_string());
465	/// }
466	/// 
467	/// let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
468	/// test_element(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
469	/// ```
470
471	pub fn at(&self, index: usize) -> Result<CapeStringOut<'a>, COBIAError> {
472		if index >= self.size as usize {
473			return Err(COBIAError::Code(COBIAERR_NOSUCHITEM));
474		}
475		let p=unsafe { self.data.add(index) };
476		if p.is_null() {
477			//this provided by the implementor of ICapeArrayString and should not be null
478			Err(COBIAError::Code(COBIAERR_NULLPOINTER))
479		} else {
480			Ok(CapeStringOut::new(unsafe { &mut *p} ))
481		}
482	}
483
484	/// Resize
485	///
486	/// # Arguments
487	///
488	/// * `size` - The new size of the array
489	///
490	/// # Examples
491	///
492	/// ```
493	/// use cobia::*;
494	///
495	/// fn set_content(a: &mut CapeArrayStringOut) {
496	///		a.resize(3).unwrap();
497	///		a.at(0).unwrap().set_string("idealGasEnthalpy").unwrap();
498	///		a.at(1).unwrap().set_string("idealGasEntropy").unwrap();
499	///		a.at(2).unwrap().set_string("density").unwrap();
500	/// }
501	/// 
502	/// let mut arr = cobia::CapeArrayStringVec::new();
503	/// set_content(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
504	/// assert_eq!(arr.as_string_vec(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string(), "density".to_string()]); //the values have been stored on the object that implements ICapeArrayString
505	/// ```
506	pub fn resize(&mut self, size: usize) -> Result<(), COBIAError> {
507		let mut data:*mut *mut C::ICapeString=std::ptr::null_mut();
508		let res = unsafe {
509			(*(**self.interface).vTbl).setsize.unwrap()(
510				(**self.interface).me,
511				size as C::CapeSize,
512				&mut data,
513			)
514		};
515		if res == COBIAERR_NOERROR {
516			self.size = size as C::CapeSize;
517			self.data=data;
518			Ok(())
519		} else {
520			Err(COBIAError::Code(res))
521		}
522	}
523
524	/// Set an element
525	///
526	/// # Arguments
527	///
528	/// * `index` - The index of the element to set
529	/// * `value` - The value to set
530	///
531	/// # Examples
532	///
533	/// ```
534	/// use cobia::*;
535	///
536	/// fn set_content(a: &mut CapeArrayStringOut) {
537	///		a.resize(3).unwrap();
538	///		a.at(0).unwrap().set_string("idealGasEnthalpy").unwrap();
539	///		a.at(1).unwrap().set_string("idealGasEntropy").unwrap();
540	///		a.at(2).unwrap().set_string("density").unwrap();
541	/// }
542	/// 
543	/// let mut arr = cobia::CapeArrayStringVec::new();
544	/// set_content(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
545	/// assert_eq!(arr.as_string_vec(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string(), "density".to_string()]); //the values have been stored on the object that implements ICapeArrayString
546	/// ```
547	pub fn set_string<T: AsRef<str>>(&mut self, index: usize, value: T) -> Result<(), COBIAError> {
548		if index >= self.size as usize {
549			return Err(COBIAError::Code(COBIAERR_NOSUCHITEM));
550		}
551		let p=unsafe { self.data.add(index) };
552		if p.is_null() {
553			//this provided by the implementor of ICapeArrayString and should not be null
554			return Err(COBIAError::Code(COBIAERR_NULLPOINTER));
555		}
556		let el = CapeStringOut::new(unsafe { &mut *p });
557		el.set_string(value.as_ref())
558	}
559
560	/// Set the content of the string array from any object that implements CapeArrayStringProviderIn.
561	///
562	/// # Arguments
563	/// * `array` - An object that implements CapeArrayStringProviderIn
564	///
565	/// # Examples
566	///
567	/// ```
568	/// use cobia::*;
569	/// let mut arr = cobia::CapeArrayStringVec::new();
570	/// let mut arr1 = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
571	/// CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out().set(&arr1);
572	/// assert_eq!(arr.as_string_vec(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]); //the values have been stored on the object that implements ICapeArrayString
573	/// ```
574
575	pub fn set<T:CapeArrayStringProviderIn>(&mut self,array:&T) -> Result<(), COBIAError> {
576		let mut string_array_in_from_provider = CapeArrayStringInFromProvider::from(array);
577		let string_array=string_array_in_from_provider.as_cape_array_string_in();
578		self.resize(string_array.size())?;
579		for i in 0..string_array.size() {
580			self.at(i)?.set(&string_array.at(i)?)?;
581		}
582		Ok(())
583	}
584
585}
586
587pub struct CapeArrayStringIterator<'a> {
588	arr: &'a CapeArrayStringOut<'a>,
589	index: usize,
590}
591
592impl<'a> Iterator for CapeArrayStringIterator<'a> {
593	type Item = CapeStringOut<'a>;
594
595	fn next(&mut self) -> Option<Self::Item> {
596		if self.index < self.arr.size as usize {
597			let res = self.arr.at(self.index);
598			self.index += 1;
599			Some(res.unwrap())
600		} else {
601			None
602		}
603	}
604}
605
606impl<'a> CapeArrayStringOut<'a> {
607	/// Return an iterator over the string array.
608	///
609	/// # Examples
610	///
611	/// ```
612	/// use cobia::*;
613	///
614	/// fn test_iter(a: &mut CapeArrayStringOut) {
615	///		let mut iter = a.iter();
616	///		assert_eq!(iter.next().unwrap().to_string(), "idealGasEnthalpy".to_string());
617	///		assert_eq!(iter.next().unwrap().to_string(), "idealGasEntropy".to_string());
618	///		assert!(!iter.next().is_some());
619	/// }
620	/// 
621	/// let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
622	/// test_iter(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
623	/// ```
624
625	pub fn iter(&self) -> CapeArrayStringIterator<'_> {
626		CapeArrayStringIterator {
627			arr: &self,
628			index: 0,
629		}
630	}
631}
632
633impl<'a> fmt::Display for CapeArrayStringOut<'a> {
634	/// Display the content of the string array as a string vector.
635	///
636	/// # Examples
637	///
638	/// ```
639	/// use cobia::*;
640	///
641	/// fn test_format(a: &mut CapeArrayStringOut) {
642	///		assert_eq!(format!("{}", a), "[\"idealGasEnthalpy\", \"idealGasEntropy\"]");
643	/// }
644	/// 
645	/// let mut arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
646	/// test_format(&mut CapeArrayStringOutFromProvider::from(&mut arr).as_cape_array_string_out());
647	/// ```
648
649	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
650		write!(f, "[")?;
651		for (count, v) in self.iter().enumerate() {
652			if count != 0 {
653				write!(f, ", ")?;
654			}
655			write!(f, "\"{}\"", v)?;
656		}
657		write!(f, "]")
658	}
659}
660
661impl<'a> CapeArrayStringProviderOut  for CapeArrayStringOut<'a> {
662	fn as_cape_array_string_out(&mut self) -> C::ICapeArrayString {
663		unsafe { **self.interface }
664	}
665}