3 * Copyright (C) 2012 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
37 // special fields used during sorting
39 FieldSort, // used to store the string to use for sorting
40 FieldSortSpecial, // whether the item needs special handling (0 = no, 1 = sort on top, 2 = sort on bottom)
44 FieldRow, // the row number in a dataset
46 // special fields not retrieved from the database
59 // fields retrievable from the database
90 FieldNumberOfEpisodes,
91 FieldNumberOfWatchedEpisodes,
96 FieldEpisodeNumberSpecialSort,
97 FieldSeasonSpecialSort,
105 FieldVideoResolution,
106 FieldVideoAspectRatio,
111 FieldSubtitleLanguage,
115 typedef std::set<Field> Fields;
116 typedef std::vector<Field> FieldList;
125 MediaTypeVideoCollection,
133 DatabaseQueryPartSelect,
134 DatabaseQueryPartWhere,
135 DatabaseQueryPartOrderBy,
138 typedef std::map<Field, CVariant> DatabaseResult;
139 typedef std::vector<DatabaseResult> DatabaseResults;
144 static std::string MediaTypeToString(MediaType mediaType);
145 static MediaType MediaTypeFromString(const std::string &strMediaType);
147 static std::string GetField(Field field, MediaType mediaType, DatabaseQueryPart queryPart);
148 static int GetFieldIndex(Field field, MediaType mediaType);
149 static bool GetSelectFields(const Fields &fields, MediaType mediaType, FieldList &selectFields);
151 static bool GetFieldValue(const dbiplus::field_value &fieldValue, CVariant &variantValue);
152 static bool GetDatabaseResults(MediaType mediaType, const FieldList &fields, const std::auto_ptr<dbiplus::Dataset> &dataset, DatabaseResults &results);
154 static std::string BuildLimitClause(int end, int start = 0);