Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/arts/dev.xml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ There are two structs defined in ``xml_io_struct.h``:
static void read(std::istream&, T&, bifstream* = nullptr) = delete;

// Binary streaming IO (optional)
static void get(std::span<const T>, bofstream*) = delete;
static void put(std::span<T>, bifstream*) = delete;
static void get(std::span<T>, bifstream*) = delete;
static void put(std::span<const T>, bofstream*) = delete;

// Text streaming (optional)
static void parse(std::span<T>, std::istream&) = delete;
Expand Down
4 changes: 2 additions & 2 deletions src/core/rtepack/rtepack_mueller_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ Array<muelmat_vector> forward_cumulative_transmission(
} // namespace rtepack

template <>

struct std::formatter<rtepack::muelmat> : std::formatter<Matrix44> {};

template <>
struct xml_io_stream<rtepack::muelmat> : xml_io_stream<Matrix44> {};
struct xml_io_stream<rtepack::muelmat>
: xml_io_stream_inherit<Matrix44, rtepack::muelmat> {};
4 changes: 2 additions & 2 deletions src/core/rtepack/rtepack_propagation_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ propmat_vector operator*(Numeric x, const propmat_vector_const_view &y);
} // namespace rtepack

template <>

struct std::formatter<rtepack::propmat> : std::formatter<Vector7> {};

template <>
struct xml_io_stream<rtepack::propmat> : xml_io_stream<Vector7> {};
struct xml_io_stream<rtepack::propmat>
: xml_io_stream_inherit<Vector7, rtepack::propmat> {};
4 changes: 2 additions & 2 deletions src/core/rtepack/rtepack_spectral_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ using specmat_tensor3_const_view = matpack::view_t<const specmat, 3>;
} // namespace rtepack

template <>

struct std::formatter<rtepack::specmat> : std::formatter<ComplexMatrix44> {};

template <>
struct xml_io_stream<rtepack::specmat> : xml_io_stream<ComplexMatrix44> {};
struct xml_io_stream<rtepack::specmat>
: xml_io_stream_inherit<ComplexMatrix44, rtepack::specmat> {};
4 changes: 2 additions & 2 deletions src/core/rtepack/rtepack_stokes_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ using stokvec_tensor6_const_view = matpack::view_t<const stokvec, 6>;
} // namespace rtepack

template <>

struct std::formatter<rtepack::stokvec> : std::formatter<Vector4> {};

template <>
struct xml_io_stream<rtepack::stokvec> : xml_io_stream<Vector4> {};
struct xml_io_stream<rtepack::stokvec>
: xml_io_stream_inherit<Vector4, rtepack::stokvec> {};
29 changes: 27 additions & 2 deletions src/core/xml/xml_io_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ struct xml_io_stream {
static void read(std::istream&, T&, bifstream* = nullptr) = delete;

// Binary streaming IO (optional)
static void get(std::span<const T>, bofstream*) = delete;
static void put(std::span<T>, bifstream*) = delete;
static void get(std::span<T>, bifstream*) = delete;
static void put(std::span<const T>, bofstream*) = delete;

// Text streaming (optional)
static void parse(std::span<T>, std::istream&) = delete;
Expand Down Expand Up @@ -103,3 +103,28 @@ template <typename T>
concept xml_io_parseable = requires(std::span<T> b, std::istream& is) {
xml_io_stream<T>::parse(b, is);
};

//! Explicitly inherit and cast between spans
template <arts_xml_ioable U, std::derived_from<U> T>
struct xml_io_stream_inherit : xml_io_stream<U> {
static void get(std::span<T> b, bifstream* pbifs)
requires(xml_io_binary<U>)
{
xml_io_stream<U>::get(std::span{reinterpret_cast<U*>(b.data()), b.size()},
pbifs);
}

static void put(std::span<const T> b, bofstream* pbofs)
requires(xml_io_binary<U>)
{
xml_io_stream<U>::put(
std::span{reinterpret_cast<const U*>(b.data()), b.size()}, pbofs);
}

static void parse(std::span<T> b, std::istream& is)
requires(xml_io_parseable<U>)
{
xml_io_stream<U>::parse(std::span{reinterpret_cast<U*>(b.data()), b.size()},
is);
}
};
8 changes: 4 additions & 4 deletions src/core/xml/xml_io_stream_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@ struct xml_io_stream<std::array<T, N>> {
}
ARTS_METHOD_ERROR_CATCH

static void put(std::span<const std::array<T, N>> v, bifstream* pbifs)
static void put(std::span<const std::array<T, N>> v, bofstream* pbofs)
requires(xml_io_binary<T>)
{
inner::put(std::span(reinterpret_cast<const T*>(v.data()), N), pbifs);
inner::put(std::span(reinterpret_cast<const T*>(v.data()), N), pbofs);
}

static void get(std::span<std::array<T, N>> v, bofstream* pbofs)
static void get(std::span<std::array<T, N>> v, bifstream* pbifs)
requires(xml_io_binary<T>)
{
inner::get(std::span(reinterpret_cast<T*>(v.data()), N), pbofs);
inner::get(std::span(reinterpret_cast<T*>(v.data()), N), pbifs);
}

static void parse(std::span<std::array<T, N>> v, std::istream& is)
Expand Down
Loading