Document(DocumentRecord),
IntegerInfo(IntegerInfoRecord),
FloatInfo(FloatInfoRecord),
- VariableSets(UnencodedString),
+ VariableSets(TextRecord),
VarDisplay(VarDisplayRecord),
MultipleResponse(MultipleResponseRecord),
LongStringValueLabels(LongStringValueLabelRecord),
Encoding(EncodingRecord),
NumberOfCases(NumberOfCasesRecord),
- ProductInfo(UnencodedString),
- LongNames(UnencodedString),
- LongStrings(UnencodedString),
- FileAttributes(UnencodedString),
- VariableAttributes(UnencodedString),
+ ProductInfo(TextRecord),
+ LongNames(TextRecord),
+ LongStrings(TextRecord),
+ FileAttributes(TextRecord),
+ VariableAttributes(TextRecord),
OtherExtension(Extension),
EndOfHeaders(u32),
ZHeader(ZHeader),
}
}
-#[derive(Copy, Clone, PartialEq, Eq, Hash)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum VarType {
Numeric,
String,
}
}
+#[derive(Clone, Debug)]
+pub struct TextRecord {
+ /// Offset from the start of the file to the start of the record.
+ pub offset: u64,
+
+ /// The text content of the record.
+ pub text: UnencodedString,
+}
+
+impl From<Extension> for TextRecord {
+ fn from(source: Extension) -> Self {
+ TextRecord { offset: source.offset, text: source.data.into() }
+ }
+}
+
#[derive(Clone, Debug)]
pub struct Extension {
/// Offset from the start of the file to the start of the record.
endian,
|_| (),
)?)),
- 5 => Ok(Record::VariableSets(UnencodedString(extension.data))),
- 10 => Ok(Record::ProductInfo(UnencodedString(extension.data))),
- 13 => Ok(Record::LongNames(UnencodedString(extension.data))),
- 14 => Ok(Record::LongStrings(UnencodedString(extension.data))),
- 17 => Ok(Record::FileAttributes(UnencodedString(extension.data))),
- 18 => Ok(Record::VariableAttributes(UnencodedString(extension.data))),
+ 5 => Ok(Record::VariableSets(extension.into())),
+ 10 => Ok(Record::ProductInfo(extension.into())),
+ 13 => Ok(Record::LongNames(extension.into())),
+ 14 => Ok(Record::LongStrings(extension.into())),
+ 17 => Ok(Record::FileAttributes(extension.into())),
+ 18 => Ok(Record::VariableAttributes(extension.into())),
_ => Ok(Record::OtherExtension(extension)),
}
}