ClassFlow.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include "ClassFlow.h"
  2. #include <fstream>
  3. #include <string>
  4. #include <iostream>
  5. #include <string.h>
  6. void ClassFlow::SetInitialParameter(void)
  7. {
  8. ListFlowControll = NULL;
  9. previousElement = NULL;
  10. }
  11. std::vector<string> ClassFlow::ZerlegeZeile(std::string input, std::string delimiter)
  12. {
  13. std::vector<string> Output;
  14. // std::string delimiter = " =,";
  15. input = trim(input, delimiter);
  16. size_t pos = findDelimiterPos(input, delimiter);
  17. std::string token;
  18. while (pos != std::string::npos) {
  19. token = input.substr(0, pos);
  20. token = trim(token, delimiter);
  21. Output.push_back(token);
  22. input.erase(0, pos + 1);
  23. input = trim(input, delimiter);
  24. pos = findDelimiterPos(input, delimiter);
  25. }
  26. Output.push_back(input);
  27. return Output;
  28. }
  29. bool ClassFlow::isNewParagraph(string input)
  30. {
  31. if (input[0] == '[')
  32. return true;
  33. return false;
  34. }
  35. bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
  36. {
  37. while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph));
  38. if (this->isNewParagraph(aktparamgraph))
  39. return true;
  40. return false;
  41. }
  42. ClassFlow::ClassFlow(void)
  43. {
  44. SetInitialParameter();
  45. }
  46. ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc)
  47. {
  48. SetInitialParameter();
  49. ListFlowControll = lfc;
  50. }
  51. ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc, ClassFlow *_prev)
  52. {
  53. SetInitialParameter();
  54. ListFlowControll = lfc;
  55. previousElement = _prev;
  56. }
  57. bool ClassFlow::ReadParameter(FILE* pfile, string &aktparamgraph)
  58. {
  59. return false;
  60. }
  61. bool ClassFlow::doFlow(string time)
  62. {
  63. return false;
  64. }
  65. string ClassFlow::getHTMLSingleStep(string host){
  66. return "";
  67. }
  68. string ClassFlow::getReadout()
  69. {
  70. return string();
  71. }
  72. bool ClassFlow::getNextLine(FILE* pfile, string *rt)
  73. {
  74. char zw[1024];
  75. if (pfile == NULL)
  76. {
  77. *rt = "";
  78. return false;
  79. }
  80. fgets(zw, 1024, pfile);
  81. printf("%s", zw);
  82. if ((strlen(zw) == 0) && feof(pfile))
  83. {
  84. *rt = "";
  85. return false;
  86. }
  87. *rt = zw;
  88. *rt = trim(*rt);
  89. while (zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) // Kommentarzeilen (; oder #) und Leerzeilen überspringen
  90. {
  91. fgets(zw, 1024, pfile);
  92. printf("%s", zw);
  93. if (feof(pfile))
  94. {
  95. *rt = "";
  96. return false;
  97. }
  98. *rt = zw;
  99. *rt = trim(*rt);
  100. }
  101. return true;
  102. }