ClassFlow.cpp 2.0 KB

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