ClassFlow.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. 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] == '[') || ((input[0] == ';') && (input[1] == '[')))
  32. {
  33. return true;
  34. }
  35. return false;
  36. }
  37. bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
  38. {
  39. while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
  40. if (isNewParagraph(aktparamgraph))
  41. return true;
  42. return false;
  43. }
  44. ClassFlow::ClassFlow(void)
  45. {
  46. SetInitialParameter();
  47. }
  48. ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc)
  49. {
  50. SetInitialParameter();
  51. ListFlowControll = lfc;
  52. }
  53. ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc, ClassFlow *_prev)
  54. {
  55. SetInitialParameter();
  56. ListFlowControll = lfc;
  57. previousElement = _prev;
  58. }
  59. bool ClassFlow::ReadParameter(FILE* pfile, string &aktparamgraph)
  60. {
  61. return false;
  62. }
  63. bool ClassFlow::doFlow(string time)
  64. {
  65. return false;
  66. }
  67. string ClassFlow::getHTMLSingleStep(string host){
  68. return "";
  69. }
  70. string ClassFlow::getReadout()
  71. {
  72. return string();
  73. }
  74. std::string ClassFlow::GetParameterName(std::string _input)
  75. {
  76. string _param;
  77. int _pospunkt = _input.find_first_of(".");
  78. if (_pospunkt > -1)
  79. {
  80. _param = _input.substr(_pospunkt+1, _input.length() - _pospunkt - 1);
  81. }
  82. else
  83. {
  84. _param = _input;
  85. }
  86. // printf("Parameter: %s, Pospunkt: %d\n", _param.c_str(), _pospunkt);
  87. return _param;
  88. }
  89. bool ClassFlow::getNextLine(FILE* pfile, string *rt)
  90. {
  91. char zw[1024];
  92. if (pfile == NULL)
  93. {
  94. *rt = "";
  95. return false;
  96. }
  97. if (!fgets(zw, 1024, pfile))
  98. {
  99. *rt = "";
  100. printf("END OF FILE\n");
  101. return false;
  102. }
  103. printf("%s", zw);
  104. *rt = zw;
  105. *rt = trim(*rt);
  106. while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
  107. {
  108. *rt = "";
  109. if (!fgets(zw, 1024, pfile))
  110. return false;
  111. printf("%s", zw);
  112. *rt = zw;
  113. *rt = trim(*rt);
  114. }
  115. return true;
  116. }