serenity/Userland/Applications/Spreadsheet/Position.h
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00

51 lines
896 B
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteString.h>
#include <AK/Types.h>
#include <LibURL/URL.h>
namespace Spreadsheet {
class Sheet;
struct Position {
Position() = default;
Position(size_t column, size_t row)
: column(column)
, row(row)
, m_hash(pair_int_hash(column, row))
{
}
ALWAYS_INLINE u32 hash() const
{
if (m_hash == 0)
return m_hash = int_hash(column * 65537 + row);
return m_hash;
}
bool operator==(Position const& other) const
{
return row == other.row && column == other.column;
}
ByteString to_cell_identifier(Sheet const& sheet) const;
URL::URL to_url(Sheet const& sheet) const;
size_t column { 0 };
size_t row { 0 };
private:
mutable u32 m_hash { 0 };
};
}