Re: KMime API review

Ingo Klöcker <[email protected]> Wed, 04 Feb 2026 19:29:07 +0100
Newsgroups gmane.comp.kde.devel.pim
Message-ID <7617307.9J7NaK4W3v@daneel>
--nextPart10393178.eNJFYEL58v
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"; protected-headers="v1"
From: Ingo =?UTF-8?B?S2zDtmNrZXI=?= <[email protected]>
To: [email protected]
Subject: Re: KMime API review
Date: Wed, 04 Feb 2026 19:29:07 +0100
Message-ID: <7617307.9J7NaK4W3v@daneel>
In-Reply-To: <[email protected]>
References: <2013350.PYKUYFuaPT@xps15> <[email protected]>
MIME-Version: 1.0

On Mittwoch, 4. Februar 2026 16:31:26 Mitteleurop=C3=A4ische Normalzeit Sun=
e=20
Vuorela wrote:
> On 2025-09-15, Albert Astals Cid <[email protected]> wrote:
> > As requested during Akademy.
>=20
> I have been toying a bit with the new API, and so far I at least have a
> couple of questions:
>=20
> Content/Message:
>=20
> The overload is a bit confusing I_think:
>      KMime::Headers::Subject *subject(CreatePolicy create =3D Create);
>      [[nodiscard]] const KMime::Headers::Subject *subject() const
>=20
> if `this` is const, the function takes one optional argument, else no
> arguments.

I think you didn't write what you meant to write.

If `this` is const, the function *does not take* an argument. Otherwise, it=
=20
takes one optional argument. This makes a lot of sense to me because you=20
cannot create/add a new header to a const object. The argument-less overloa=
d=20
prevents you from calling subject() with Create. Hmm, is your concern that =
the=20
non-const overload creates a new header if called without argument while th=
e=20
const overload doesn't create a new header?

> Types:
>  At least KMime::Type::Address have a public QList member

What do you suggest? I guess one could make the member private and add a=20
public inline `const QList<KMime::Type::Address> &` getter to avoid the sme=
ll=20
of a public member variable and, at the same time, avoid a prohibitive=20
performance penalty. Or maybe Address should simply be a struct (with one=20
private member variable) instead of a class if it's supposed to be used lik=
e a=20
struct (like AddrSpec is).

Regards,
Ingo
--nextPart10393178.eNJFYEL58v
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit

-----BEGIN PGP SIGNATURE-----

iJEEABYKADkWIQTbjgIOMowwlCBgvyGxb1mVFkdKugUCaYOP8xsUgAAAAAAEAA5t
YW51MiwyLjUrMS4xMSwyLDIACgkQsW9ZlRZHSrpSkAD+IPF4yaPn1/L08FRfhh2W
Jd0cfaeWepJ+lyBxLBxJCxIA/AmQ331TqILFZQouzW0M7V08ASDQqa6KFaR+OO8j
Fi4K
=qzs5
-----END PGP SIGNATURE-----

--nextPart10393178.eNJFYEL58v--