KWeatherCore

locationqueryresult.cpp
1 /*
2  * SPDX-FileCopyrightText: 2020-2021 Han Young <[email protected]>
3  * SPDX-FileCopyrightText: 2020 Devin Lin <[email protected]>
4  *
5  * SPDX-License-Identifier: LGPL-2.0-or-later
6  */
7 #include "locationqueryresult.h"
8 #include <memory>
9 #include <optional>
10 namespace KWeatherCore
11 {
12 class LocationQueryResult::LocationQueryResultPrivate
13 {
14 public:
15  double latitude, longitude;
17  std::optional<QString> subdivision;
18 };
19 LocationQueryResult::LocationQueryResult()
20  : d(std::make_unique<LocationQueryResultPrivate>())
21 {
22 }
23 LocationQueryResult::LocationQueryResult(LocationQueryResult &&other) = default;
24 LocationQueryResult::LocationQueryResult(double latitude,
25  double longitude,
26  QString toponymName,
27  QString name,
28  QString countryCode,
29  QString countryName,
30  QString geonameId,
31  std::optional<QString> subdivision)
32  : d(std::make_unique<LocationQueryResultPrivate>())
33 {
34  d->latitude = latitude;
35  d->longitude = longitude;
36  d->toponymName = std::move(toponymName);
37  d->name = std::move(name);
38  d->countryCode = std::move(countryCode);
39  d->countryName = std::move(countryName);
40  d->geonameId = std::move(geonameId);
41  d->subdivision = std::move(subdivision);
42 }
43 LocationQueryResult::LocationQueryResult(const LocationQueryResult &other)
44  : d(std::make_unique<LocationQueryResultPrivate>())
45 {
46  *d = *other.d;
47 }
48 LocationQueryResult::~LocationQueryResult() = default;
49 LocationQueryResult &LocationQueryResult::operator=(const LocationQueryResult &other)
50 {
51  *d = *other.d;
52  return *this;
53 }
54 LocationQueryResult &LocationQueryResult::operator=(LocationQueryResult &&other) = default;
55 double LocationQueryResult::latitude() const
56 {
57  return d->latitude;
58 }
59 double LocationQueryResult::longitude() const
60 {
61  return d->longitude;
62 }
64 {
65  return d->toponymName;
66 }
68 {
69  return d->name;
70 }
72 {
73  return d->countryCode;
74 }
76 {
77  return d->countryName;
78 }
80 {
81  return d->geonameId;
82 }
83 const std::optional<QString> &LocationQueryResult::subdivision() const
84 {
85  return d->subdivision;
86 }
87 }
Class represents location query result.
const QString & countryName() const
country name
const std::optional< QString > & subdivision() const
Country subdivision such as state, province, etc.
const QString & name() const
display name, short
const QString & countryCode() const
country code, follow no standard but should be unique
const QString & geonameId() const
internal unique id
const QString & toponymName() const
toponym name of location, detailed
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 23:05:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.