/// <summary>
        /// Initializes a new instance of the <see cref="EhfaStructureType" /> class.
        /// </summary>
        /// <param name="name">The structure type name.</param>
        /// <param name="dictionary">The type dictionary.</param>
        /// <param name="definitions">The item definitions.</param>
        private EhfaStructureType(String name, HfaDictionary dictionary, String definitions)
        {
            DataPlacement = DataPlacement.Internal;
            ItemName      = name;
            Dictionary    = dictionary;

            ParseItemDefinitions(definitions);
        }
        /// <summary>
        /// Returns a structure type from the object type definition.
        /// </summary>
        /// <param name="definition">The object type definition string.</param>
        /// <param name="dictionary">The type dictionary where the definition is located.</param>
        /// <returns>The produced structure type.</returns>
        /// <exception cref="ArgumentNullException">The definition is null.</exception>
        public static EhfaStructureType FromObjectDefinition(String definition, HfaDictionary dictionary)
        {
            if (definition == null)
            {
                throw new ArgumentNullException(nameof(definition), "The definition is null.");
            }

            return(ParseObjectDefinition(definition, 0, definition.Length, dictionary));
        }
        /// <summary>
        /// Gets the type of a structure that is embedded in another structure.
        /// </summary>
        /// <param name="definitions">The item definitions.</param>
        /// <param name="index">The zero-based index of the type within the definition.</param>
        /// <returns>The structure type.</returns>
        private IEhfaObjectType GetFollowingDefinedObjectType(String definitions, ref Int32 index)
        {
            if (Dictionary == null)
            {
                return(null);
            }

            Int32 length = HfaDictionary.GetObjectLength(definitions, 0) + 1;

            index += length;

            return(FromObjectDefinition(definitions, index, length, Dictionary));
        }
Example #4
0
 /// <summary>
 /// Completes the defenition of this type based on the existing dictionary
 /// </summary>
 /// <param name="dictionary"></param>
 public void CompleteDefn(HfaDictionary dictionary)
 {
     // This may already be done, if an earlier object required this
     // object (as a field), and forced and early computation of the size
     if (_numBytes != 0) return;
     // Complete each fo the fields, totaling up the sizes.  This 
     // isn't really accurate for objects with variable sized
     // subobjects.
     foreach (HfaField field in _fields)
     {
         field.CompleteDefn(dictionary);
         if (field.NumBytes < 0 || _numBytes == -1)
         {
             _numBytes = -1;
         }
         else
         {
             _numBytes += field.NumBytes;
         }
     }
 }
Example #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dict"></param>
        public void CompleteDefn(HfaDictionary dict)
        {
            // Get a reference to the type object if we have a type name
            // for this field (not a build in).
            if (_itemObjectTypeString != null)
            {
                _itemObjectType = dict[_itemObjectTypeString];
            }
            // Figure out the size
            if (_pointer == 'p')
            {
                _numBytes = -1;
            }
            else if (_itemObjectType != null)
            {
                _itemObjectType.CompleteDefn(dict);
                if (_itemObjectType.NumBytes == -1)
                {
                    _numBytes = -1;
                }
                else
                {
                    _numBytes = (short)(_itemObjectType.NumBytes * _itemCount);
                }
                if (_pointer == '*' && _numBytes != -1) _numBytes += 8;
            }
            else
            {
                _numBytes = (short)(HfaDictionary.GetItemSize(_itemType) * _itemCount);
            }


        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EhfaEntry" /> class.
 /// </summary>
 /// <param name="structureType">The EHFA structure type.</param>
 /// <param name="dictionary">The HFA dictionary where the entry is located.</param>
 public EhfaEntry(EhfaStructureType structureType, HfaDictionary dictionary) : base(structureType)
 {
     Dictionary = dictionary;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EhfaStructureType" /> class.
 /// </summary>
 /// <param name="name">The structure type name.</param>
 /// <param name="dictionary">The type dictionary.</param>
 public EhfaStructureType(String name, HfaDictionary dictionary)
 {
     DataPlacement = DataPlacement.Internal;
     ItemName      = name;
     Dictionary    = dictionary;
 }
        /// <summary>
        /// Parses the object definition.
        /// </summary>
        /// <param name="definition">The object definition string.</param>
        /// <param name="startIndex">The zero-based starting position of the definition within the string.</param>
        /// <param name="length">The length of the definition.</param>
        /// <param name="dictionary">The HFA dictionary where the definition is located.</param>
        /// <returns>The produced structure type.</returns>
        private static EhfaStructureType ParseObjectDefinition(String definition, Int32 startIndex, Int32 length, HfaDictionary dictionary)
        {
            Match objectMatch = ObjectDefinitionExpression.Match(definition, startIndex, length);

            if (!objectMatch.Success)
            {
                return(null);
            }

            return(new EhfaStructureType(objectMatch.Groups["name"].Value, dictionary, objectMatch.Groups["itemDefinitions"].Value));
        }
        /// <summary>
        /// Returns a structure type from the object type definition.
        /// </summary>
        /// <param name="definition">The object type definition string.</param>
        /// <param name="startIndex">The zero-based starting position of the definition within the string.</param>
        /// <param name="length">The length of the definition.</param>
        /// <param name="dictionary">The type dictionary where the definition is located.</param>
        /// <returns>The produced structure type.</returns>
        /// <exception cref="ArgumentNullException">The definition is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The starting index is less than 0.
        /// or
        /// The starting index is greater than or equal to the length of the definition.
        /// </exception>
        public static EhfaStructureType FromObjectDefinition(String definition, Int32 startIndex, Int32 length, HfaDictionary dictionary)
        {
            if (definition == null)
            {
                throw new ArgumentNullException(nameof(definition), "The definition is null.");
            }
            if (startIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(startIndex), "The starting index is less than 0.");
            }
            if (startIndex >= definition.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(startIndex), "The starting index is greater than or equal to the length of the definition.");
            }

            return(ParseObjectDefinition(definition, startIndex, length, dictionary));
        }