xee_interpreter/atomic/
types.rs

1use xee_schema_type::Xs;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4pub enum IntegerType {
5    Integer,
6    NonPositiveInteger,
7    NegativeInteger,
8    NonNegativeInteger,
9    PositiveInteger,
10    Long,
11    Int,
12    Short,
13    Byte,
14    UnsignedLong,
15    UnsignedInt,
16    UnsignedShort,
17    UnsignedByte,
18}
19
20impl IntegerType {
21    pub(crate) fn schema_type(&self) -> Xs {
22        match self {
23            IntegerType::Integer => Xs::Integer,
24            IntegerType::Long => Xs::Long,
25            IntegerType::Int => Xs::Int,
26            IntegerType::Short => Xs::Short,
27            IntegerType::Byte => Xs::Byte,
28            IntegerType::UnsignedLong => Xs::UnsignedLong,
29            IntegerType::UnsignedInt => Xs::UnsignedInt,
30            IntegerType::UnsignedShort => Xs::UnsignedShort,
31            IntegerType::UnsignedByte => Xs::UnsignedByte,
32            IntegerType::NonPositiveInteger => Xs::NonPositiveInteger,
33            IntegerType::NegativeInteger => Xs::NegativeInteger,
34            IntegerType::NonNegativeInteger => Xs::NonNegativeInteger,
35            IntegerType::PositiveInteger => Xs::PositiveInteger,
36        }
37    }
38}
39
40/// The types of string supported as atomic values.
41#[allow(clippy::upper_case_acronyms)]
42#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
43pub enum StringType {
44    /// xs:string
45    String,
46    /// xs:normalizedString
47    NormalizedString,
48    /// xs:token
49    Token,
50    /// xs:language
51    Language,
52    /// xs:NMTOKEN
53    NMTOKEN,
54    /// xs:Name
55    Name,
56    /// xs:NCName
57    NCName,
58    /// xs:ID
59    ID,
60    /// xs:IDREF
61    IDREF,
62    /// xs:ENTITY
63    ENTITY,
64    // the qt3 tests make the assumption AnyURI is a type of string
65    /// xs:anyURI
66    AnyURI,
67}
68
69impl StringType {
70    pub(crate) fn schema_type(&self) -> Xs {
71        match self {
72            StringType::String => Xs::String,
73            StringType::NormalizedString => Xs::NormalizedString,
74            StringType::Token => Xs::Token,
75            StringType::Language => Xs::Language,
76            StringType::NMTOKEN => Xs::NMTOKEN,
77            StringType::Name => Xs::Name,
78            StringType::NCName => Xs::NCName,
79            StringType::ID => Xs::ID,
80            StringType::IDREF => Xs::IDREF,
81            StringType::ENTITY => Xs::ENTITY,
82            StringType::AnyURI => Xs::AnyURI,
83        }
84    }
85}
86
87/// The types of binary supported as atomic values.
88#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
89pub enum BinaryType {
90    /// xs:base64Binary
91    Base64,
92    /// xs:hexBinary
93    Hex,
94}
95
96impl BinaryType {
97    pub(crate) fn schema_type(&self) -> Xs {
98        match self {
99            BinaryType::Base64 => Xs::Base64Binary,
100            BinaryType::Hex => Xs::HexBinary,
101        }
102    }
103}