示例#1
0
        //  Writes an object (and all of its associated component objects if any)
        //  to the file at the current index (appending or updating the element
        //  at the corresponding index in the file_elements Vector). In the case
        //  where the index is set past the end of the current size of file_elements,
        //  the intervening Vector elements, if any, will also be filled with the
        //  written object.

        static public void write_element(Object file, Object element)
        {
            Object_File obj_file = (Object_File)file;

            long extension_count
                = obj_file.index - (long)obj_file.file_elements.Count;

            //  Append the element to the end of the file, adding as many additional
            //  element copies as needed when extension_count > 1.

            if (extension_count > 0)
            {
                long elt_count;

                for (elt_count = 1; elt_count <= extension_count; elt_count++)
                {
                    obj_file.file_elements.Add(element);
                }
            }

            //  The write is an update to an existing element, so remove the
            //  element at that index and replace it with the new element.

            else
            {
                obj_file.file_elements.RemoveAt((int)obj_file.index - 1);
                obj_file.file_elements.Insert
                    ((int)obj_file.index - 1, element);
            }

            obj_file.updated = true;
        }
示例#2
0
        //  Reads the next element from the file (the object in the file_elements
        //  Vector at the current file index - 1). The exception End_Error will
        //  be thrown if no element exists at the currently specified index.

        static public Object read_element(Object file)
        {
            Object_File obj_file = (Object_File)file;

            try {
                return(obj_file.file_elements[(int)obj_file.index - 1]);
            }
            catch (ArgumentOutOfRangeException) {
                throw new ada.io_exceptions.end_error();
            }
        }
示例#3
0
        //  Returns true (end-of-file condition) when the file index is equal to
        //  the current size of the file_elements Vector.

        static public bool object_eof(Object file)
        {
            Object_File obj_file = (Object_File)file;

            return(obj_file.index > (long)obj_file.file_elements.Count);
        }