22 #include "mythtypes.h" 23 #include "private/builtin.h" 32 uint32_t Myth::StringToId(
const std::string& str)
35 string_to_uint32(str.c_str(), &id);
39 std::string Myth::IdToString(uint32_t
id)
43 uint32_to_string(
id, buf);
44 return std::string(buf);
47 time_t Myth::StringToTime(
const std::string& isotime)
49 time_t time = INVALID_TIME;
50 string_to_time(isotime.c_str(), &time);
54 std::string Myth::TimeToString(time_t time,
bool utc)
58 char buf[TIMESTAMP_UTC_LEN + 1];
60 time_to_iso8601utc(time, buf);
61 return std::string(buf);
65 char buf[TIMESTAMP_LEN + 1];
67 time_to_iso8601(time, buf);
68 return std::string(buf);
72 int Myth::StringToInt(
const std::string& str)
75 string_to_int32(str.c_str(), &i);
79 std::string Myth::IntToString(
int i)
83 int32_to_string(i, buf);
84 return std::string(buf);
100 static int __tValFromString(
protoref_t *map,
unsigned sz,
unsigned proto,
const std::string& sVal,
int unk)
102 for (
unsigned i = 0; i < sz; ++i)
104 if (proto >= map[i].protoVer && sVal.compare(map[i].sVal) == 0)
110 static int __tValFromNum(
protoref_t *map,
unsigned sz,
unsigned proto,
int iVal,
int unk)
112 for (
unsigned i = 0; i < sz; ++i)
114 if (proto >= map[i].protoVer && iVal == map[i].iVal)
120 static const char *__tValToString(
protoref_t *map,
unsigned sz,
unsigned proto,
int tVal,
const char *unk)
122 for (
unsigned i = 0; i < sz; ++i)
124 if (proto >= map[i].protoVer && tVal == map[i].tVal)
130 static int __tValToNum(
protoref_t *map,
unsigned sz,
unsigned proto,
int tVal,
int unk)
132 for (
unsigned i = 0; i < sz; ++i)
134 if (proto >= map[i].protoVer && tVal == map[i].tVal)
147 { 79, RT_TemplateRecord, 11,
"Recording Template" },
148 { 79, RT_NotRecording, 0,
"Not Recording" },
149 { 76, RT_OneRecord, 6,
"Record One" },
150 { 75, RT_SingleRecord, 1,
"Single Record" },
151 { 75, RT_DailyRecord, 2,
"Record Daily" },
152 { 75, RT_ChannelRecord, 3,
"Channel Record" },
153 { 75, RT_AllRecord, 4,
"Record All" },
154 { 75, RT_WeeklyRecord, 5,
"Record Weekly" },
155 { 75, RT_OneRecord, 6,
"Find One" },
156 { 75, RT_OverrideRecord, 7,
"Override Recording" },
157 { 75, RT_DontRecord, 8,
"Do not Record" },
158 { 75, RT_FindDailyRecord, 9,
"Find Daily" },
159 { 75, RT_FindWeeklyRecord, 10,
"Find Weekly" },
160 { 75, RT_TemplateRecord, 11,
"Not Recording" },
161 { 75, RT_NotRecording, 0,
"Not Recording" },
164 RT_t Myth::RuleTypeFromString(
unsigned proto,
const std::string& type)
166 static unsigned sz =
sizeof(ruleType) /
sizeof(
protoref_t);
167 return (RT_t)__tValFromString(ruleType, sz, proto, type, (
int)RT_UNKNOWN);
170 RT_t Myth::RuleTypeFromNum(
unsigned proto,
int type)
172 static unsigned sz =
sizeof(ruleType) /
sizeof(
protoref_t);
173 return (RT_t)__tValFromNum(ruleType, sz, proto, type, (
int)RT_UNKNOWN);
176 const char *Myth::RuleTypeToString(
unsigned proto, RT_t type)
178 static unsigned sz =
sizeof(ruleType) /
sizeof(
protoref_t);
179 return __tValToString(ruleType, sz, proto, (
int)type,
"");
182 int Myth::RuleTypeToNum(
unsigned proto, RT_t type)
184 static unsigned sz =
sizeof(ruleType) /
sizeof(
protoref_t);
185 return __tValToNum(ruleType, sz, proto, (
int)type, 0);
195 { 75, DI_InRecorded, 0x01,
"Current Recordings" },
196 { 75, DI_InOldRecorded, 0x02,
"Previous Recordings" },
197 { 75, DI_InAll, 0x0F,
"All Recordings" },
198 { 75, DI_NewEpi, 0x10,
"New Episodes Only" },
201 DI_t Myth::DupInFromString(
unsigned proto,
const std::string& type)
203 static unsigned sz =
sizeof(dupIn) /
sizeof(
protoref_t);
204 return (DI_t)__tValFromString(dupIn, sz, proto, type, (
int)DI_UNKNOWN);
207 DI_t Myth::DupInFromNum(
unsigned proto,
int type)
209 static unsigned sz =
sizeof(dupIn) /
sizeof(
protoref_t);
210 return (DI_t)__tValFromNum(dupIn, sz, proto, type, (
int)DI_UNKNOWN);
213 const char *Myth::DupInToString(
unsigned proto, DI_t type)
215 static unsigned sz =
sizeof(dupIn) /
sizeof(
protoref_t);
216 return __tValToString(dupIn, sz, proto, (
int)type,
"");
219 int Myth::DupInToNum(
unsigned proto, DI_t type)
221 static unsigned sz =
sizeof(dupIn) /
sizeof(
protoref_t);
222 return __tValToNum(dupIn, sz, proto, (
int)type, 0);
232 { 75, DM_CheckNone, 0x01,
"None" },
233 { 75, DM_CheckSubtitle, 0x02,
"Subtitle" },
234 { 75, DM_CheckDescription, 0x04,
"Description" },
235 { 75, DM_CheckSubtitleAndDescription, 0x06,
"Subtitle and Description" },
236 { 75, DM_CheckSubtitleThenDescription, 0x08,
"Subtitle then Description" },
239 DM_t Myth::DupMethodFromString(
unsigned proto,
const std::string& type)
241 static unsigned sz =
sizeof(dupMethod) /
sizeof(
protoref_t);
242 return (DM_t)__tValFromString(dupMethod, sz, proto, type, (
int)DM_UNKNOWN);
245 DM_t Myth::DupMethodFromNum(
unsigned proto,
int type)
247 static unsigned sz =
sizeof(dupMethod) /
sizeof(
protoref_t);
248 return (DM_t)__tValFromNum(dupMethod, sz, proto, type, (
int)DM_UNKNOWN);
251 const char *Myth::DupMethodToString(
unsigned proto, DM_t type)
253 static unsigned sz =
sizeof(dupMethod) /
sizeof(
protoref_t);
254 return __tValToString(dupMethod, sz, proto, (
int)type,
"");
257 int Myth::DupMethodToNum(
unsigned proto, DM_t type)
259 static unsigned sz =
sizeof(dupMethod) /
sizeof(
protoref_t);
260 return __tValToNum(dupMethod, sz, proto, (
int)type, 0);
270 { 75, ST_NoSearch, 0,
"None" },
271 { 75, ST_PowerSearch, 1,
"Power Search" },
272 { 75, ST_TitleSearch, 2,
"Title Search" },
273 { 75, ST_KeywordSearch, 3,
"Keyword Search" },
274 { 75, ST_PeopleSearch, 4,
"People Search" },
275 { 75, ST_ManualSearch, 5,
"Manual Search" },
278 ST_t Myth::SearchTypeFromString(
unsigned proto,
const std::string& type)
280 static unsigned sz =
sizeof(searchType) /
sizeof(
protoref_t);
281 return (ST_t)__tValFromString(searchType, sz, proto, type, (
int)ST_UNKNOWN);
284 ST_t Myth::SearchTypeFromNum(
unsigned proto,
int type)
286 static unsigned sz =
sizeof(searchType) /
sizeof(
protoref_t);
287 return (ST_t)__tValFromNum(searchType, sz, proto, type, (
int)ST_UNKNOWN);
290 const char *Myth::SearchTypeToString(
unsigned proto, ST_t type)
292 static unsigned sz =
sizeof(searchType) /
sizeof(
protoref_t);
293 return __tValToString(searchType, sz, proto, (
int)type,
"");
296 int Myth::SearchTypeToNum(
unsigned proto, ST_t type)
298 static unsigned sz =
sizeof(searchType) /
sizeof(
protoref_t);
299 return __tValToNum(searchType, sz, proto, (
int)type, 0);
309 { 79, CATT_CategoryNone, 0,
"" },
310 { 79, CATT_CategoryMovie, 1,
"movie" },
311 { 79, CATT_CategorySeries, 2,
"series" },
312 { 79, CATT_CategorySports, 3,
"sports" },
313 { 79, CATT_CategoryTVShow, 4,
"tvshow" },
316 CATT_t Myth::CategoryTypeFromString(
unsigned proto,
const std::string& type)
318 static unsigned sz =
sizeof(categoryType) /
sizeof(
protoref_t);
320 return CATT_CategoryNone;
321 return (CATT_t)__tValFromString(categoryType, sz, proto, type, (
int)CATT_UNKNOWN);
324 CATT_t Myth::CategoryTypeFromNum(
unsigned proto,
int type)
326 static unsigned sz =
sizeof(categoryType) /
sizeof(
protoref_t);
327 return (CATT_t)__tValFromNum(categoryType, sz, proto, type, (
int)CATT_UNKNOWN);
330 const char *Myth::CategoryTypeToString(
unsigned proto, CATT_t type)
332 static unsigned sz =
sizeof(categoryType) /
sizeof(
protoref_t);
333 return __tValToString(categoryType, sz, proto, (
int)type,
"");
336 int Myth::CategoryTypeToNum(
unsigned proto, CATT_t type)
338 static unsigned sz =
sizeof(categoryType) /
sizeof(
protoref_t);
339 return __tValToNum(categoryType, sz, proto, (
int)type, 0);
349 { 75, RS_TUNING, -10,
"Tuning" },
350 { 75, RS_FAILED, -9,
"Failed" },
351 { 75, RS_TUNER_BUSY, -8,
"Tuner busy" },
352 { 75, RS_LOW_DISKSPACE, -7,
"Low disk space" },
353 { 75, RS_CANCELLED, -6,
"Cancelled" },
354 { 75, RS_MISSED, -5,
"Missed" },
355 { 75, RS_ABORTED, -4,
"Aborted" },
356 { 75, RS_RECORDED, -3,
"Recorded" },
357 { 75, RS_RECORDING, -2,
"Recording" },
358 { 75, RS_WILL_RECORD, -1,
"Will record" },
359 { 75, RS_UNKNOWN, 0,
"Unknown" },
360 { 75, RS_DONT_RECORD, 1,
"Don't record" },
361 { 75, RS_PREVIOUS_RECORDING, 2,
"Previous recording" },
362 { 75, RS_CURRENT_RECORDING, 3,
"Current recording" },
363 { 75, RS_EARLIER_RECORDING, 4,
"Earlier recording" },
364 { 75, RS_TOO_MANY_RECORDINGS, 5,
"Too many recordings" },
365 { 75, RS_NOT_LISTED, 6,
"Not listed" },
366 { 75, RS_CONFLICT, 7,
"Conflict" },
367 { 75, RS_LATER_SHOWING, 8,
"Later showing" },
368 { 75, RS_REPEAT, 9,
"Repeat" },
369 { 75, RS_INACTIVE, 10,
"Inactive" },
370 { 75, RS_NEVER_RECORD, 11,
"Never record" },
371 { 75, RS_OFFLINE, 12,
"Offline" },
372 { 75, RS_OTHER_SHOWING, 13,
"Other showing" },
375 RS_t Myth::RecStatusFromString(
unsigned proto,
const std::string& type)
377 static unsigned sz =
sizeof(recStatus) /
sizeof(
protoref_t);
378 return (RS_t)__tValFromString(recStatus, sz, proto, type, (
int)RT_UNKNOWN);
381 RS_t Myth::RecStatusFromNum(
unsigned proto,
int type)
383 static unsigned sz =
sizeof(recStatus) /
sizeof(
protoref_t);
384 return (RS_t)__tValFromNum(recStatus, sz, proto, type, (
int)RT_UNKNOWN);
387 const char *Myth::RecStatusToString(
unsigned proto, RS_t type)
389 static unsigned sz =
sizeof(recStatus) /
sizeof(
protoref_t);
390 return __tValToString(recStatus, sz, proto, (
int)type,
"");
393 int Myth::RecStatusToNum(
unsigned proto, RS_t type)
395 static unsigned sz =
sizeof(recStatus) /
sizeof(
protoref_t);
396 return __tValToNum(recStatus, sz, proto, (
int)type, 0);
This is the main namespace that encloses all public classes.