fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. //PARSER_H_
  6. #include <iostream>
  7. //SERIESTRUCT_H_
  8. #include <string>
  9. #include <vector>
  10.  
  11.  
  12. #ifndef SERIESTRUCT_H_
  13. #define SERIESTRUCT_H_
  14.  
  15. class Episode
  16. {
  17. public:
  18. Episode(int nr);
  19. Episode(std::string name, int nr);
  20. Episode(std::string name, int nr, bool watched);
  21.  
  22. std::string getName() const { return _name; }
  23. int getNr() const { return _episodeNr; }
  24. bool getWatched() const { return _watched; }
  25. void setWatched(bool watched) { _watched = watched; }
  26. std::string changeName(std::string newName);
  27.  
  28. private:
  29. std::string _name;
  30. unsigned int _episodeNr;
  31. bool _watched;
  32. };
  33.  
  34. class Season
  35. {
  36. using Iter = std::vector<Episode>::iterator;
  37. public:
  38. Season(int nr) : _seasonNr(nr) {}
  39.  
  40. int getNr() const { return _seasonNr; }
  41. void changeNr(int newNr) { _seasonNr = newNr; }
  42.  
  43. Iter begin() { return std::begin(_episodes); }
  44. Iter end() { return std::end(_episodes); }
  45.  
  46. bool addEpisode(std::string name, int nr);
  47. bool addEpisode(std::string name, int nr, bool watched);
  48. bool operator==(const Season&);
  49.  
  50. private:
  51. std::vector<Episode> _episodes;
  52. int _seasonNr;
  53. };
  54.  
  55.  
  56. class Serie
  57. {
  58. using Iter = std::vector<Season>::iterator;
  59. public:
  60. Serie(std::string name) : _name(name) {}
  61.  
  62. std::string getName() const { return _name; }
  63. void setName(std::string newName){ _name = newName; }
  64.  
  65.  
  66. Iter begin() { return std::begin(_seasons); }
  67. Iter end() { return std::end(_seasons); }
  68.  
  69. bool addSeason(int nr);
  70.  
  71. private:
  72. std::vector<Season> _seasons;
  73. std::string _name;
  74. };
  75.  
  76. #endif
  77. #include <string>
  78.  
  79. #ifndef FILEPARSER_H_
  80. #define FILEPARSER_H_
  81.  
  82. enum class lineIdentifier{ OPEN, CLOSE, INFO, ERROR };
  83.  
  84. template<template <class, class> class ContainerT,
  85. typename Allocator>
  86. void parseToSerie(std::istream& is, ContainerT< Serie, Allocator> cont);
  87.  
  88. struct lineSyntax
  89. {
  90. std::string first;
  91. std::string second;
  92. lineIdentifier state;
  93. };
  94.  
  95. //FILEPARSER_TPP_
  96.  
  97.  
  98.  
  99.  
  100. template<template <class, class> class ContainerT,
  101. typename Allocator>
  102. void parseToSerie(std::istream& is, ContainerT<Serie, Allocator> cont)
  103. {
  104. std::cout << "called" << std::endl;
  105.  
  106. }
  107. #endif
  108.  
  109. //SERIESTRUCT_H_
  110. #include <string>
  111. #include <vector>
  112.  
  113.  
  114. #ifndef SERIESTRUCT_H_
  115. #define SERIESTRUCT_H_
  116.  
  117. class Episode
  118. {
  119. public:
  120. Episode(int nr);
  121. Episode(std::string name, int nr);
  122. Episode(std::string name, int nr, bool watched);
  123.  
  124. std::string getName() const { return _name; }
  125. int getNr() const { return _episodeNr; }
  126. bool getWatched() const { return _watched; }
  127. void setWatched(bool watched) { _watched = watched; }
  128. std::string changeName(std::string newName);
  129.  
  130. private:
  131. std::string _name;
  132. unsigned int _episodeNr;
  133. bool _watched;
  134. };
  135.  
  136. class Season
  137. {
  138. using Iter = std::vector<Episode>::iterator;
  139. public:
  140. Season(int nr) : _seasonNr(nr) {}
  141.  
  142. int getNr() const { return _seasonNr; }
  143. void changeNr(int newNr) { _seasonNr = newNr; }
  144.  
  145. Iter begin() { return std::begin(_episodes); }
  146. Iter end() { return std::end(_episodes); }
  147.  
  148. bool addEpisode(std::string name, int nr);
  149. bool addEpisode(std::string name, int nr, bool watched);
  150. bool operator==(const Season&);
  151.  
  152. private:
  153. std::vector<Episode> _episodes;
  154. int _seasonNr;
  155. };
  156.  
  157.  
  158. class Serie
  159. {
  160. using Iter = std::vector<Season>::iterator;
  161. public:
  162. Serie(std::string name) : _name(name) {}
  163.  
  164. std::string getName() const { return _name; }
  165. void setName(std::string newName){ _name = newName; }
  166.  
  167.  
  168. Iter begin() { return std::begin(_seasons); }
  169. Iter end() { return std::end(_seasons); }
  170.  
  171. bool addSeason(int nr);
  172.  
  173. private:
  174. std::vector<Season> _seasons;
  175. std::string _name;
  176. };
  177.  
  178. #endif
  179.  
  180. int main()
  181. {
  182. std::vector < Serie > serien;
  183. parseToSerie(std::cin, serien);
  184.  
  185.  
  186. return 0;
  187. }
Success #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
called