ClassFlow.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. std::string ClassFlow::GetParameterName(std::string _input)
  76. {
  77. string _param;
  78. int _pospunkt = _input.find_first_of(".");
  79. if (_pospunkt > -1)
  80. {
  81. _param = _input.substr(_pospunkt+1, _input.length() - _pospunkt - 1);
  82. }
  83. else
  84. {
  85. _param = _input;
  86. }
  87. // printf("Parameter: %s, Pospunkt: %d\n", _param.c_str(), _pospunkt);
  88. return _param;
  89. }
  90. bool ClassFlow::getNextLine(FILE* pfile, string *rt)
  91. {
  92. char zw[1024];
  93. if (pfile == NULL)
  94. {
  95. *rt = "";
  96. return false;
  97. }
  98. if (!fgets(zw, 1024, pfile))
  99. {
  100. *rt = "";
  101. printf("END OF FILE\n");
  102. return false;
  103. }
  104. printf("%s", zw);
  105. *rt = zw;
  106. *rt = trim(*rt);
  107. while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
  108. {
  109. if (!fgets(zw, 1024, pfile))
  110. {
  111. *rt = "";
  112. return false;
  113. }
  114. printf("%s", zw);
  115. *rt = zw;
  116. *rt = trim(*rt);
  117. }
  118. return true;
  119. }