with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IDOMParser_Interface is

   procedure Initialize (This : in out IDOMParser_Type) is
   begin
      Set_IID (This, IID_IDOMParser);
   end Initialize;

   function Pointer (This : IDOMParser_Type)
     return Pointer_To_IDOMParser
   is
   begin
      return To_Pointer_To_IDOMParser (Address (This));
   end Pointer;

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

   function parseFromString
     (This      : IDOMParser_Type;
      xmlSource : GNATCOM.Types.BSTR;
      mimeType  : GNATCOM.Types.BSTR;
      Free      : Boolean := True)
     return Pointer_To_IHTMLDocument2
   is
       RetVal : aliased Pointer_To_IHTMLDocument2;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.parseFromString
         (Pointer (This),
          xmlSource,
          mimeType,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (xmlSource);
               GNATCOM.IInterface.Free (mimeType);
      
      end if;

      return RetVal;
   end parseFromString;

end MSHTML.IDOMParser_Interface;

