add string to generated dex

This commit is contained in:
Jean-Marie Mineau 2023-12-01 11:23:59 +01:00
parent 2ed4acc71c
commit df9149c068
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
8 changed files with 92 additions and 28 deletions

View file

@ -12,6 +12,8 @@
//! | 3 | U+0800 | U+FFFF | 16 | 1110xxxx | 10xxxxxx | 10xxxxxx | | | |
//! | 6 | U+10000 | U+FFFFF | 20 | 11101101 | 1010xxxx | 10xxxxxx | 11101101 | 1011xxxx | 10xxxxxx |
use std::cmp::{Ord, Ordering, PartialOrd};
use crate as androscalpel_serializer;
use crate::core::*;
pub use androscalpel_serializer_derive::*;
@ -32,6 +34,22 @@ const VALUE_SURROGATED_BYTE_2_PREFIX: u8 = 0b1011_0000;
const MASK_TRAYLING_BYTE_PREFIX: u8 = 0b1100_0000;
const VALUE_TRAYLING_BYTE_PREFIX: u8 = 0b1000_0000;
impl Ord for StringDataItem {
fn cmp(&self, other: &Self) -> Ordering {
self.data
.cmp(&other.data)
.then(self.utf16_size.cmp(&other.utf16_size))
}
}
impl PartialOrd for StringDataItem {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.data
.partial_cmp(&other.data)
.map(|ord| ord.then(self.utf16_size.cmp(&other.utf16_size)))
}
}
impl TryFrom<&StringDataItem> for String {
type Error = Error;
fn try_from(item: &StringDataItem) -> Result<String> {