Statistics
| Branch: | Tag: | Revision:

dvbd / src / recording.cpp @ 904d298f

History | View | Annotate | Download (1.91 KB)

1
/*
2
  Copyright 2003 John Knottenbelt
3
  
4
  This program is free software; you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation; either version 2 of the License, or
7
  (at your option) any later version.
8
 
9
  This program is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
 
14
  You should have received a copy of the GNU General Public License
15
  along with this program; if not, write to the Free Software
16
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17
*/
18

    
19
#include "config.h"
20
#include "utils.h"
21
#include "stringutil.h"
22
#include "recording.h"
23

    
24
Recording::~Recording()
25
{
26
}
27

    
28
std::ostream& Recording::printOn(std::ostream &o) const
29
{
30
  char dateTime[128];
31

    
32
  strftime(dateTime, sizeof(dateTime), "%Y-%m-%d %H:%M:%S", 
33
           localtime(&startTime));
34

    
35
  o << job << " " << uid << " " << dateTime << " " << type << " " 
36
    << escapeWS(channel) << " " << ::toString(convertToPS) << " "
37
    << duration << " " << priority << " " << escapeWS(path) << " "
38
    << "[" << escapeWS(extra) << "]";
39

    
40
  return o;
41
}
42

    
43
std::istream &operator >> (std::istream &i, Recording &r)
44
{
45
  std::string datePart, timePart, channel, path, convertToPS, extra;
46

    
47
  i >> r.job 
48
    >> r.uid >> datePart >> timePart >> r.type >> channel
49
    >> convertToPS >> r.duration >> r.priority >> path
50
    >> extra;
51

    
52
  r.channel = unescapeWS(channel);
53
  r.convertToPS = toBool(convertToPS);
54
  r.path = unescapeWS(path);
55

    
56
  if (extra.size() >= 2)
57
    r.extra = unescapeWS(extra.substr(1, extra.size() - 2));
58
  else
59
    r.extra = "";
60
  
61
  std::string dateTime = datePart + " " + timePart;
62
  struct tm tm;
63
  if (strptime(dateTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm) != NULL)
64
    r.startTime = mktime(&tm);
65

    
66
  return i;
67
}
68