with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLAttributeCollection2_Interface is

   procedure Initialize (This : in out IHTMLAttributeCollection2_Type) is
   begin
      Set_IID (This, IID_IHTMLAttributeCollection2);
   end Initialize;

   function Pointer (This : IHTMLAttributeCollection2_Type)
     return Pointer_To_IHTMLAttributeCollection2
   is
   begin
      return To_Pointer_To_IHTMLAttributeCollection2 (Address (This));
   end Pointer;

   procedure Attach (This    : in out IHTMLAttributeCollection2_Type;
                     Pointer : in     Pointer_To_IHTMLAttributeCollection2)
   is
   begin
      Attach (This, GNATCOM.IInterface.To_Pointer_To_IUnknown
              (Pointer.all'Address));
   end Attach;

   function getNamedItem
     (This       : IHTMLAttributeCollection2_Type;
      bstrName   : GNATCOM.Types.BSTR;
      Free       : Boolean := True)
     return Pointer_To_IHTMLDOMAttribute
   is
       RetVal : aliased Pointer_To_IHTMLDOMAttribute;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.getNamedItem
         (Pointer (This),
          bstrName,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrName);
      
      end if;

      return RetVal;
   end getNamedItem;

   function setNamedItem
     (This       : IHTMLAttributeCollection2_Type;
      ppNode     : Pointer_To_IHTMLDOMAttribute)
     return Pointer_To_IHTMLDOMAttribute
   is
       RetVal : aliased Pointer_To_IHTMLDOMAttribute;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.setNamedItem
         (Pointer (This),
          ppNode,
          RetVal'Unchecked_Access));

      return RetVal;
   end setNamedItem;

   function removeNamedItem
     (This       : IHTMLAttributeCollection2_Type;
      bstrName   : GNATCOM.Types.BSTR;
      Free       : Boolean := True)
     return Pointer_To_IHTMLDOMAttribute
   is
       RetVal : aliased Pointer_To_IHTMLDOMAttribute;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.removeNamedItem
         (Pointer (This),
          bstrName,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrName);
      
      end if;

      return RetVal;
   end removeNamedItem;

end MSHTML.IHTMLAttributeCollection2_Interface;

