All Classes Files Functions Variables Enumerations Enumerator Macros
gap.cpp
Go to the documentation of this file.
1 #include "output.hpp"
7 
16 // Outputs missing information from objects
17 void OutPut::outputMissing( Library *libObj, ostream &tout )
18 {
19  // Check if Library objects don't exist
20  if( libObj == NULL )
21  {
22  // Write to the standard console output
23  cout << "Error: no data found in Parser object" << endl;
24  }
25  // Library objects exist
26  else
27  {
28  // For each show
29  for( unsigned int i = 0; i < libObj->shows.size(); i++ )
30  {
31  // Create a season missing flag set to false
32  bool sMiss = false;
33  // Create a episode missing flag set to false
34  bool eMiss = false;
35 
36  // Store the last season checked
37  int lastSeason = 0;
38 
39  if( i > 0 )
40  {
41  // Add a newline after every show
42  tout << endl << endl;
43  }
44 
45  // Output showname
46  tout << libObj->shows[i].getShowname() << endl;
47 
48  // For each season
49  for( unsigned int j = 0; j < libObj->shows[i].seasons.size(); j++ )
50  {
51  // Store the last episode checked
52  int lastEpisode = 0;
53  // Store the difference between current season and last season
54  int sDif = libObj->shows[i].seasons[j].getNumber() - lastSeason;
55 
56  // Check if the difference is more than one season
57  if( sDif > 1 )
58  {
59  // Set season missing flag to true
60  sMiss = true;
61  // For each season missing
62  for( int sCount = 1; sCount < sDif; sCount++ )
63  {
64  // Output the missing season number
65  tout << " [Season " << lastSeason + sCount << "] - missing" << endl;
66  }
67  }
68 
69  // Output Season number
70  tout << " [Season " << libObj->shows[i].seasons[j].getNumber() << "]";
71 
72  // Update last season number to current season number before checking next season
73  lastSeason = libObj->shows[i].seasons[j].getNumber();
74 
75  // For each episode
76  for( unsigned int k = 0; k < libObj->shows[i].seasons[j].episodes.size(); k++ )
77  {
78  // Store the difference between current episode and last episode
79  int eDif = libObj->shows[i].seasons[j].episodes[k].getNumber() - lastEpisode;
80 
81  // Check if the difference is more than one episode
82  if( eDif > 1 )
83  {
84  // Set episode missing flag to true
85  eMiss = true;
86  // For each episode missing
87  for( int eCount = 1; eCount < eDif; eCount++ )
88  {
89  // Output the missing episode number
90  tout << endl << " [Episode " << lastEpisode + eCount << "] - missing";
91  }
92  }
93 
94  // Update last episode number to current episode number before checking next episode
95  lastEpisode = libObj->shows[i].seasons[j].episodes[k].getNumber();
96  }
97 
98  // Check if no missing episodes
99  if( eMiss == false )
100  {
101  tout << " - No missing episodes detected";
102  if( j+1 < libObj->shows[i].seasons.size() )
103  {
104  tout << endl;
105  }
106  }
107  // Missing episodes found
108  else
109  {
110  // Reset episode missing flag
111  eMiss = false;
112  // Add a return before next season
113  tout << endl;
114  }
115 
116  }
117 
118  // Check if missing seasons
119  if( sMiss == true )
120  {
121  // Reset season missing flag
122  sMiss = false;
123  }
124 
125  if( i+1 == libObj->shows.size() )
126  {
127  // Add a newline after every show
128  tout << endl;
129  }
130  }
131  }
132 };
The OutPut class prints summary and error information from objects.
vector< Show > shows
A vector that holds each Show.
Definition: library.hpp:41
static void outputMissing(Library *, ostream &)
Outputs gaps in a given Library object's contents.
Definition: gap.cpp:17
Stores all info required to describe all shows.
Definition: library.hpp:30