mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
port SymbologyIdentifier test
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::{any::Any, rc::Rc};
|
||||
|
||||
use crate::common::ECIStringBuilder;
|
||||
use crate::{common::ECIStringBuilder, Exceptions};
|
||||
|
||||
use super::StructuredAppendInfo;
|
||||
|
||||
@@ -18,6 +18,7 @@ where
|
||||
readerInit: bool, // = false;
|
||||
//Error _error;
|
||||
//std::shared_ptr<CustomData> _extra;
|
||||
error: Option<Exceptions>,
|
||||
extra: Rc<T>,
|
||||
}
|
||||
|
||||
@@ -34,6 +35,7 @@ where
|
||||
structuredAppend: Default::default(),
|
||||
isMirrored: false,
|
||||
readerInit: false,
|
||||
error: None,
|
||||
extra: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -53,7 +55,7 @@ where
|
||||
}
|
||||
|
||||
pub fn isValid(&self) -> bool {
|
||||
self.content.symbology.code != 0
|
||||
self.content.symbology.code != 0 && self.error.is_none()
|
||||
//return includeErrors || (_content.symbology.code != 0 && !_error);
|
||||
}
|
||||
|
||||
@@ -196,6 +198,17 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
pub fn error(&self) -> &Option<Exceptions> {
|
||||
&self.error
|
||||
}
|
||||
pub fn setError(&mut self, error: Option<Exceptions>) {
|
||||
self.error = error
|
||||
}
|
||||
pub fn withError(mut self, error: Option<Exceptions>) -> DecoderResult<T> {
|
||||
self.setError(error);
|
||||
self
|
||||
}
|
||||
|
||||
// pub fn build(self) -> DecoderResult<T> {
|
||||
|
||||
// }
|
||||
@@ -214,7 +227,7 @@ where
|
||||
if s.code > 0 {
|
||||
format!(
|
||||
"]{}{}",
|
||||
vec!['1'; s.code as usize].into_iter().collect::<String>(),
|
||||
char::from(s.code),
|
||||
char::from(
|
||||
s.modifier
|
||||
+ if self.content.has_eci {
|
||||
|
||||
@@ -41,26 +41,28 @@ pub fn UpdateMinMaxFloat(min: &mut f64, max: &mut f64, val: f64) {
|
||||
|
||||
// template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
|
||||
pub fn ToString<T: Into<usize>>(val: T, len: usize) -> Result<String> {
|
||||
let mut len = len;
|
||||
let mut val = val.into();
|
||||
let mut len = len as isize;
|
||||
let val = val.into();
|
||||
let mut val = val as isize;
|
||||
|
||||
let mut result: String = vec!['0'; len].iter().collect();
|
||||
let mut result = vec!['0'; len as usize];
|
||||
len -= 1;
|
||||
// std::string result(len--, '0');
|
||||
if (val < 0) {
|
||||
if val < 0 {
|
||||
return Err(Exceptions::format_with("Invalid value"));
|
||||
}
|
||||
while len >= 0 && val != 0 {
|
||||
result.replace_range(len..len, &char::from(b'0' + (val % 10) as u8).to_string());
|
||||
result[len as usize] = char::from(b'0' + (val % 10) as u8);
|
||||
// result.replace_range((len as usize)..(len as usize), &char::from(b'0' + (val % 10) as u8).to_string());
|
||||
|
||||
len -= 1;
|
||||
val /= 10;
|
||||
}
|
||||
// for (; len >= 0 && val != 0; --len, val /= 10) {
|
||||
// result[len] = '0' + val % 10;}
|
||||
if (val != 0) {
|
||||
if val != 0 {
|
||||
return Err(Exceptions::format_with("Invalid value"));
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
Ok(result.iter().collect())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user