#[error("Invalid variable name in long string value label record. {0}")]
InvalidLongStringValueLabelName(IdError),
+ #[error("Invalid variable name in attribute record. {0}")]
+ InvalidAttributeVariableName(IdError),
+
#[error("Details TBD")]
TBD,
}
LongNames(LongNameRecord),
VeryLongStrings(VeryLongStringRecord),
FileAttributes(FileAttributeRecord),
- //VariableAttributes(UnencodedString),
+ VariableAttributes(VariableAttributeRecord),
//OtherExtension(Extension),
//EndOfHeaders(u32),
//ZHeader(ZHeader),
}
}
+#[derive(Clone, Debug)]
pub struct VarAttributeSet {
- pub long_var_name: String,
+ pub long_var_name: Identifier,
pub attributes: AttributeSet,
}
decoder: &Decoder,
input: &'a str,
warn: &impl Fn(Error),
- ) -> Result<(VarAttributeSet, &'a str), Error> {
+ ) -> Result<(Option<VarAttributeSet>, &'a str), Error> {
let Some((long_var_name, rest)) = input.split_once(':') else {
return Err(Error::TBD);
};
let (attributes, rest) = AttributeSet::parse(decoder, rest, Some('/'), warn)?;
- Ok((
- VarAttributeSet {
- long_var_name: long_var_name.into(),
+ let var_attribute = Identifier::new(long_var_name, decoder.encoding)
+ .map_err(|e| Error::InvalidAttributeVariableName(e))
+ .warn_on_error(warn)
+ .map(|name| VarAttributeSet {
+ long_var_name: name,
attributes,
- },
- rest,
- ))
+ });
+ Ok((var_attribute, rest))
}
}
+#[derive(Clone, Debug)]
pub struct VariableAttributeRecord(Vec<VarAttributeSet>);
impl VariableAttributeRecord {
else {
break;
};
- var_attribute_sets.push(var_attribute);
+ if let Some(var_attribute) = var_attribute {
+ var_attribute_sets.push(var_attribute);
+ }
input = rest;
}
Ok(VariableAttributeRecord(var_attribute_sets))