ClassFlow.cpp 2.3 KB

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