1------------------------------------------------------------------------------ 2-- -- 3-- Matreshka Project -- 4-- -- 5-- XML Processor -- 6-- -- 7-- Runtime Library Component -- 8-- -- 9------------------------------------------------------------------------------ 10-- -- 11-- Copyright © 2010, Vadim Godunko <vgodunko@gmail.com> -- 12-- All rights reserved. -- 13-- -- 14-- Redistribution and use in source and binary forms, with or without -- 15-- modification, are permitted provided that the following conditions -- 16-- are met: -- 17-- -- 18-- * Redistributions of source code must retain the above copyright -- 19-- notice, this list of conditions and the following disclaimer. -- 20-- -- 21-- * Redistributions in binary form must reproduce the above copyright -- 22-- notice, this list of conditions and the following disclaimer in the -- 23-- documentation and/or other materials provided with the distribution. -- 24-- -- 25-- * Neither the name of the Vadim Godunko, IE nor the names of its -- 26-- contributors may be used to endorse or promote products derived from -- 27-- this software without specific prior written permission. -- 28-- -- 29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- 30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- 31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- 32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- 33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- 34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- 35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- 36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- 37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- 38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- 39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- 40-- -- 41------------------------------------------------------------------------------ 42-- $Revision: 2026 $ $Date: 2011-07-23 00:16:17 +0400 (Sat, 23 Jul 2011) $ 43------------------------------------------------------------------------------ 44with Matreshka.Internals.Strings; 45 46package Matreshka.Internals.XML.Attribute_Tables is 47 48 pragma Preelaborate; 49 50 type Attribute_Table is limited private; 51 52 procedure New_CDATA_Attribute 53 (Self : in out Attribute_Table; 54 Name : Symbol_Identifier; 55 Attribute : out Attribute_Identifier); 56 -- Allocates new attribute of CDATA type. 57 58 procedure New_Entity_Attribute 59 (Self : in out Attribute_Table; 60 Name : Symbol_Identifier; 61 Attribute : out Attribute_Identifier); 62 -- Allocates new attribute of ENTITY type. 63 64 procedure New_Entities_Attribute 65 (Self : in out Attribute_Table; 66 Name : Symbol_Identifier; 67 Attribute : out Attribute_Identifier); 68 -- Allocates new attribute of ENTITIES type. 69 70 procedure New_Id_Attribute 71 (Self : in out Attribute_Table; 72 Name : Symbol_Identifier; 73 Attribute : out Attribute_Identifier); 74 -- Allocates new attribute of ID type. 75 76 procedure New_IdRef_Attribute 77 (Self : in out Attribute_Table; 78 Name : Symbol_Identifier; 79 Attribute : out Attribute_Identifier); 80 -- Allocates new attribute of IDREF type. 81 82 procedure New_IdRefs_Attribute 83 (Self : in out Attribute_Table; 84 Name : Symbol_Identifier; 85 Attribute : out Attribute_Identifier); 86 -- Allocates new attribute of IDREFS type. 87 88 procedure New_NmToken_Attribute 89 (Self : in out Attribute_Table; 90 Name : Symbol_Identifier; 91 Attribute : out Attribute_Identifier); 92 -- Allocates new attribute of NMTOKEN type. 93 94 procedure New_NmTokens_Attribute 95 (Self : in out Attribute_Table; 96 Name : Symbol_Identifier; 97 Attribute : out Attribute_Identifier); 98 -- Allocates new attribute of NMTOKENS type. 99 100 procedure New_Notation_Attribute 101 (Self : in out Attribute_Table; 102 Name : Symbol_Identifier; 103 Attribute : out Attribute_Identifier); 104 -- Allocates new attribute of NOTATION type. 105 106 procedure New_Enumeration_Attribute 107 (Self : in out Attribute_Table; 108 Name : Symbol_Identifier; 109 Attribute : out Attribute_Identifier); 110 -- Allocates new attribute of enumeration type. 111 112 function Is_ID 113 (Self : Attribute_Table; 114 Attribute : Attribute_Identifier) return Boolean; 115 -- Returns True when attribute has ID type. 116 117 function Is_CDATA 118 (Self : Attribute_Table; 119 Attribute : Attribute_Identifier) return Boolean; 120 -- Returns True when attribute has CDATA type. 121 122 procedure Append 123 (Self : in out Attribute_Table; 124 Attribute : Attribute_Identifier; 125 Next : Attribute_Identifier); 126 -- Append attribute specified by Next to the list of attributes started 127 -- by Attribute. 128 129 function Name 130 (Self : Attribute_Table; 131 Attribute : Attribute_Identifier) return Symbol_Identifier; 132 -- Returns name of the attribute. 133 134 function Next 135 (Self : Attribute_Table; 136 Attribute : Attribute_Identifier) return Attribute_Identifier; 137 -- Returns next attribute in the list of attributes of the element. 138 139 function Is_Required 140 (Self : Attribute_Table; 141 Attribute : Attribute_Identifier) return Boolean; 142 143 procedure Set_Is_Required 144 (Self : in out Attribute_Table; 145 Attribute : Attribute_Identifier; 146 Value : Boolean); 147 148 function Is_Implied 149 (Self : Attribute_Table; 150 Attribute : Attribute_Identifier) return Boolean; 151 152 procedure Set_Is_Implied 153 (Self : in out Attribute_Table; 154 Attribute : Attribute_Identifier; 155 Value : Boolean); 156 157 function Is_Fixed 158 (Self : Attribute_Table; 159 Attribute : Attribute_Identifier) return Boolean; 160 161 procedure Set_Is_Fixed 162 (Self : in out Attribute_Table; 163 Attribute : Attribute_Identifier; 164 Value : Boolean); 165 166 function Default 167 (Self : Attribute_Table; 168 Attribute : Attribute_Identifier) 169 return not null Matreshka.Internals.Strings.Shared_String_Access; 170 171 procedure Set_Default 172 (Self : in out Attribute_Table; 173 Attribute : Attribute_Identifier; 174 Value : not null Matreshka.Internals.Strings.Shared_String_Access); 175 176 function Has_Default 177 (Self : Attribute_Table; 178 Attribute : Attribute_Identifier) return Boolean; 179 -- Returns True when attribute has default value. This is synthetic value, 180 -- attribute has default value when it is not declared as REQUIRED or 181 -- IMPLIED. 182 183 function Symbol_Of_Type_Name 184 (Self : Attribute_Table; 185 Attribute : Attribute_Identifier) return Symbol_Identifier; 186 -- Returns symbol of type name of the attribute. 187 188 procedure Reset (Self : in out Attribute_Table); 189 -- Resets internal structures to initial state. 190 191 procedure Finalize (Self : in out Attribute_Table); 192 -- Releases all ocupied resources. 193 194private 195 196 type Attribute_Types is 197 (CDATA, 198 ENTITY, 199 ENTITIES, 200 ID, 201 IDREF, 202 IDREFS, 203 NMTOKEN, 204 NMTOKENS, 205 NOTATION, 206 ENUMERATION); 207 208 type Attribute_Record is record 209 Name : Symbol_Identifier; 210 The_Type : Attribute_Types; 211 Is_Required : Boolean; 212 Is_Implied : Boolean; 213 Is_Fixed : Boolean; 214 Default : Matreshka.Internals.Strings.Shared_String_Access; 215 Next : Attribute_Identifier; 216 -- Next attribute for the same element type. 217 end record; 218 219 type Attribute_Array is 220 array (Attribute_Identifier range <>) of Attribute_Record; 221 222 type Attribute_Array_Access is access all Attribute_Array; 223 224 type Attribute_Table is limited record 225 Table : Attribute_Array_Access := new Attribute_Array (1 .. 16); 226 Last : Attribute_Identifier := No_Attribute; 227 end record; 228 229 pragma Inline (Name); 230 pragma Inline (Next); 231 pragma Inline (Default); 232 pragma Inline (Is_CDATA); 233 pragma Inline (Is_Fixed); 234 pragma Inline (Is_ID); 235 pragma Inline (Is_Implied); 236 pragma Inline (Is_Required); 237 pragma Inline (Set_Default); 238 pragma Inline (Set_Is_Fixed); 239 pragma Inline (Set_Is_Implied); 240 pragma Inline (Set_Is_Required); 241 242end Matreshka.Internals.XML.Attribute_Tables; 243