KCoreAddons

kosrelease.h
1 /*
2  SPDX-FileCopyrightText: 2014-2019 Harald Sitter <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #ifndef KOSRELEASE_H
8 #define KOSRELEASE_H
9 
10 #include <kcoreaddons_export.h>
11 
12 #include <QString>
13 #include <QStringList>
14 
15 #include <memory>
16 
17 /**
18  * @brief The OSRelease class parses /etc/os-release files
19  *
20  * https://www.freedesktop.org/software/systemd/man/os-release.html
21  *
22  * os-release is a free desktop standard for describing an operating system.
23  * This class parses and models os-release files.
24  *
25  * @since 5.58.0
26  */
27 class KCOREADDONS_EXPORT KOSRelease Q_DECL_FINAL
28 {
29 public:
30  /**
31  * Constructs a new OSRelease instance. Parsing happens in the constructor
32  * and the data is not cached across instances.
33  *
34  * @note The format specification makes no assertions about trailing #
35  * comments being supported. They result in undefined behavior.
36  *
37  * @param filePath The path to the os-release file. By default the first
38  * available file of the paths specified in the os-release manpage is
39  * parsed.
40  */
41  explicit KOSRelease(const QString &filePath = QString());
42  ~KOSRelease();
43 
44  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#NAME= */
45  QString name() const;
46  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION= */
47  QString version() const;
48  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#ID= */
49  QString id() const;
50  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#ID_LIKE= */
51  QStringList idLike() const;
52  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION_CODENAME= */
53  QString versionCodename() const;
54  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION_ID= */
55  QString versionId() const;
56  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#PRETTY_NAME= */
57  QString prettyName() const;
58  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#ANSI_COLOR= */
59  QString ansiColor() const;
60  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#CPE_NAME= */
61  QString cpeName() const;
62  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
63  QString homeUrl() const;
64  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
65  QString documentationUrl() const;
66  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
67  QString supportUrl() const;
68  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
69  QString bugReportUrl() const;
70  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
71  QString privacyPolicyUrl() const;
72  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#BUILD_ID= */
73  QString buildId() const;
74  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VARIANT= */
75  QString variant() const;
76  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VARIANT_ID= */
77  QString variantId() const;
78  /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#LOGO= */
79  QString logo() const;
80 
81  /**
82  * Extra keys are keys that are unknown or specified by a vendor.
83  */
84  QStringList extraKeys() const;
85 
86  /** Extra values are values assoicated with keys that are unknown. */
87  QString extraValue(const QString &key) const;
88 
89 private:
90  Q_DISABLE_COPY(KOSRelease)
91 
92  std::unique_ptr<class KOSReleasePrivate> const d;
93 };
94 
95 #endif // KOSRELEASE_H
The OSRelease class parses /etc/os-release files.
Definition: kosrelease.h:27
unsigned int version()
Returns a numerical version number of KCoreAddons at run-time in the form 0xMMNNPP (MM = major,...
Definition: kcoreaddons.cpp:18
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 04:04:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.