2 * Copyright (C) 2012-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.
11 #include "media/MediaType.h"
20 enum class VideoDbContentType
;
30 // special fields used during sorting
33 FieldSort
, // used to store the string to use for sorting
34 FieldSortSpecial
, // whether the item needs special handling (0 = no, 1 = sort on top, 2 = sort on bottom)
38 FieldRow
, // the row number in a dataset
40 // special fields not retrieved from the database
60 // fields retrievable from the database
102 FieldNumberOfEpisodes
,
103 FieldNumberOfWatchedEpisodes
,
109 FieldEpisodeNumberSpecialSort
,
110 FieldSeasonSpecialSort
,
120 FieldVideoResolution
,
121 FieldVideoAspectRatio
,
126 FieldSubtitleLanguage
,
142 FieldRelevance
, // Used for actors' appearances
143 FieldClientChannelOrder
,
156 typedef std::set
<Field
> Fields
;
157 typedef std::vector
<Field
> FieldList
;
160 DatabaseQueryPartSelect
,
161 DatabaseQueryPartWhere
,
162 DatabaseQueryPartOrderBy
,
165 typedef std::map
<Field
, CVariant
> DatabaseResult
;
166 typedef std::vector
<DatabaseResult
> DatabaseResults
;
171 static MediaType
MediaTypeFromVideoContentType(VideoDbContentType videoContentType
);
173 static std::string
GetField(Field field
, const MediaType
&mediaType
, DatabaseQueryPart queryPart
);
174 static int GetField(Field field
, const MediaType
&mediaType
);
175 static int GetFieldIndex(Field field
, const MediaType
&mediaType
);
176 static bool GetSelectFields(const Fields
&fields
, const MediaType
&mediaType
, FieldList
&selectFields
);
178 static bool GetFieldValue(const dbiplus::field_value
&fieldValue
, CVariant
&variantValue
);
179 static bool GetDatabaseResults(const MediaType
&mediaType
, const FieldList
&fields
, const std::unique_ptr
<dbiplus::Dataset
> &dataset
, DatabaseResults
&results
);
181 static std::string
BuildLimitClause(int end
, int start
= 0);
182 static std::string
BuildLimitClauseOnly(int end
, int start
= 0);
183 static size_t GetLimitCount(int end
, int start
);
186 static int GetField(Field field
, const MediaType
&mediaType
, bool asIndex
);