aboutsummaryrefslogtreecommitdiff
path: root/lib/gumbo-parser/vector.h
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2021-03-07 11:58:37 +0100
committerFelix Queißner <felix@ib-queissner.de>2021-03-08 02:23:16 +0100
commit64e271dce2e5aca07abdca8e335b3f7cb9ba1114 (patch)
treee3aed2f5057f4db7eccc9505125c3a539ad543c1 /lib/gumbo-parser/vector.h
parent2e4bd9e8a1f0ee14fb58c91ae2d94bcb96c6cbce (diff)
downloadkristall-64e271dce2e5aca07abdca8e335b3f7cb9ba1114.tar.gz
Starts to implement new HTML renderer based on gumbo. Everything is a bit borked and only trivial documents work correctly.
Diffstat (limited to 'lib/gumbo-parser/vector.h')
-rw-r--r--lib/gumbo-parser/vector.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/gumbo-parser/vector.h b/lib/gumbo-parser/vector.h
new file mode 100644
index 0000000..70fe6fa
--- /dev/null
+++ b/lib/gumbo-parser/vector.h
@@ -0,0 +1,67 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Author: jdtang@google.com (Jonathan Tang)
+
+#ifndef GUMBO_VECTOR_H_
+#define GUMBO_VECTOR_H_
+
+#include "gumbo.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Forward declaration since it's passed into some of the functions in this
+// header.
+struct GumboInternalParser;
+
+// Initializes a new GumboVector with the specified initial capacity.
+void gumbo_vector_init(struct GumboInternalParser* parser,
+ size_t initial_capacity, GumboVector* vector);
+
+// Frees the memory used by an GumboVector. Does not free the contained
+// pointers.
+void gumbo_vector_destroy(
+ struct GumboInternalParser* parser, GumboVector* vector);
+
+// Adds a new element to an GumboVector.
+void gumbo_vector_add(
+ struct GumboInternalParser* parser, void* element, GumboVector* vector);
+
+// Removes and returns the element most recently added to the GumboVector.
+// Ownership is transferred to caller. Capacity is unchanged. If the vector is
+// empty, NULL is returned.
+void* gumbo_vector_pop(struct GumboInternalParser* parser, GumboVector* vector);
+
+// Inserts an element at a specific index. This is potentially O(N) time, but
+// is necessary for some of the spec's behavior.
+void gumbo_vector_insert_at(struct GumboInternalParser* parser, void* element,
+ unsigned int index, GumboVector* vector);
+
+// Removes an element from the vector, or does nothing if the element is not in
+// the vector.
+void gumbo_vector_remove(
+ struct GumboInternalParser* parser, void* element, GumboVector* vector);
+
+// Removes and returns an element at a specific index. Note that this is
+// potentially O(N) time and should be used sparingly.
+void* gumbo_vector_remove_at(struct GumboInternalParser* parser,
+ unsigned int index, GumboVector* vector);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // GUMBO_VECTOR_H_