public Gumbo(string html, GumboLibraryOptions?options = null) { _options = CreateOptions(options); _html = NativeUtf8.NativeUtf8FromString(html); _outputPtr = NativeMethods.gumbo_parse(_html); var output = Marshal.PtrToStructure <GumboOutput>(_outputPtr); _gumboDocumentNode = output.GetDocument(); Errors = output.GetErrors(); var lazyFactory = new LazyFactory(() => _disposed, typeof(Gumbo).Name); _gumboFactory = new GumboFactory(lazyFactory); Document = (Document)_gumboFactory.CreateNode(_gumboDocumentNode); }
/// <summary> /// Release the memory used for the parse tree and parse errors. /// </summary> /// <param name="options"></param> /// <param name="output"></param> [DllImport(LibraryName, CallingConvention = CallingConvention.Cdecl)] public static extern void gumbo_destroy_output(ref GumboOptions options, IntPtr output);
/// <summary> /// Extended version of <see cref="gumbo_parse"/> that takes an explicit options structure, /// buffer, and length. /// </summary> /// <param name="options"></param> /// <param name="buffer"></param> /// <param name="buffer_length"></param> /// <returns></returns> [DllImport(LibraryName, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr gumbo_parse_with_options(ref GumboOptions options, IntPtr buffer, [MarshalAs(UnmanagedType.SysUInt)] uint buffer_length);
public static extern IntPtr gumbo_parse_with_options(ref GumboOptions options, IntPtr buffer, [MarshalAs(UnmanagedType.SysUInt)] uint buffer_length);
public static extern void gumbo_destroy_output(ref GumboOptions options, IntPtr output);