style.h

// Style used in SVG output. Value is the SVG style to be applied to elements
// with the given tag, e.g., "stroke: #D04030; fill: #D89080;"
struct Style {
    Tag tag;
    char* value;
};

// Hash map of styles indexed by tag
struct StyleMap {
    uint64_t capacity;  // allocated capacity
    uint64_t count;     // number of items in the map
    Style* items;       // array with length capacity

    void print(bool all) const;

    // Deallocates the whole map, including its contents
    void clear();

    // The instance should be zeroed before using copy_from
    void copy_from(const StyleMap& map);

    // Internal use
    void resize(uint64_t new_capacity);
    Style* get_slot(Tag tag) const;

    // Value is internally allocated and copied
    void set(Tag tag, const char* value);
    const char* get(Tag tag) const;
    bool del(Tag tag);

    // Function to iterate over all values in the map:
    // for (Style* style = style_map.next(NULL); style;
    //      style = style_map.next(style)) {…}
    Style* next(const Style* current) const;
};