[filesystem][SpecialProtocol] Removed assert from GetPath
[xbmc.git] / xbmc / pictures / PictureInfoTag.h
blobeff58fbc617449042798a9cb1ad94fc0f630f1b1
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "XBDateTime.h"
12 #include "libexif.h"
13 #include "utils/IArchivable.h"
14 #include "utils/ISerializable.h"
15 #include "utils/ISortable.h"
17 #include <string>
18 #include <vector>
20 namespace KODI
22 namespace ADDONS
24 class CImageDecoder;
25 } /* namespace ADDONS */
26 } /* namespace KODI */
28 class CVariant;
30 class CPictureInfoTag : public IArchivable, public ISerializable, public ISortable
32 friend class KODI::ADDONS::CImageDecoder;
34 // Mimic structs from libexif.h but with C++ types instead of arrays
35 struct ExifInfo
37 ExifInfo() = default;
38 ExifInfo(const ExifInfo&) = default;
39 ExifInfo(ExifInfo&&) = default;
40 ExifInfo(const ExifInfo_t& other);
42 ExifInfo& operator=(const ExifInfo&) = default;
43 ExifInfo& operator=(ExifInfo&&) = default;
45 std::string CameraMake;
46 std::string CameraModel;
47 std::string DateTime;
48 int Height{};
49 int Width{};
50 int Orientation{};
51 int IsColor{};
52 int Process{};
53 int FlashUsed{};
54 float FocalLength{};
55 float ExposureTime{};
56 float ApertureFNumber{};
57 float Distance{};
58 float CCDWidth{};
59 float ExposureBias{};
60 float DigitalZoomRatio{};
61 int FocalLength35mmEquiv{};
62 int Whitebalance{};
63 int MeteringMode{};
64 int ExposureProgram{};
65 int ExposureMode{};
66 int ISOequivalent{};
67 int LightSource{};
68 int CommentsCharset{};
69 int XPCommentsCharset{};
70 std::string Comments;
71 std::string FileComment;
72 std::string XPComment;
73 std::string Description;
75 unsigned ThumbnailOffset{};
76 unsigned ThumbnailSize{};
77 unsigned LargestExifOffset{};
79 char ThumbnailAtEnd{};
80 int ThumbnailSizeOffset{};
82 std::vector<int> DateTimeOffsets;
84 int GpsInfoPresent{};
85 std::string GpsLat;
86 std::string GpsLong;
87 std::string GpsAlt;
89 private:
90 static std::string Convert(int charset, const char* data);
93 struct IPTCInfo
95 IPTCInfo() = default;
96 IPTCInfo(const IPTCInfo&) = default;
97 IPTCInfo(IPTCInfo&&) = default;
98 IPTCInfo(const IPTCInfo_t& other);
100 IPTCInfo& operator=(const IPTCInfo&) = default;
101 IPTCInfo& operator=(IPTCInfo&&) = default;
103 std::string RecordVersion;
104 std::string SupplementalCategories;
105 std::string Keywords;
106 std::string Caption;
107 std::string Author;
108 std::string Headline;
109 std::string SpecialInstructions;
110 std::string Category;
111 std::string Byline;
112 std::string BylineTitle;
113 std::string Credit;
114 std::string Source;
115 std::string CopyrightNotice;
116 std::string ObjectName;
117 std::string City;
118 std::string State;
119 std::string Country;
120 std::string TransmissionReference;
121 std::string Date;
122 std::string Urgency;
123 std::string ReferenceService;
124 std::string CountryCode;
125 std::string TimeCreated;
126 std::string SubLocation;
127 std::string ImageType;
130 public:
131 CPictureInfoTag() { Reset(); }
132 virtual ~CPictureInfoTag() = default;
133 void Reset();
134 void Archive(CArchive& ar) override;
135 void Serialize(CVariant& value) const override;
136 void ToSortable(SortItem& sortable, Field field) const override;
137 const std::string GetInfo(int info) const;
139 bool Loaded() const { return m_isLoaded; }
140 bool Load(const std::string &path);
142 void SetInfo(const std::string& key, const std::string& value);
145 * GetDateTimeTaken() -- Returns the EXIF DateTimeOriginal for current picture
147 * The exif library returns DateTimeOriginal if available else the other
148 * DateTime tags. See libexif CExifParse::ProcessDir for details.
150 const CDateTime& GetDateTimeTaken() const;
151 private:
152 static int TranslateString(const std::string &info);
154 ExifInfo m_exifInfo;
155 IPTCInfo m_iptcInfo;
156 bool m_isLoaded; // Set to true if metadata has been loaded from the picture file successfully
157 bool m_isInfoSetExternally; // Set to true if metadata has been set by an external call to SetInfo
158 CDateTime m_dateTimeTaken;
159 void ConvertDateTime();