ClassFlow.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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, std::string delimiter);
  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. ListFlowControll = NULL;
  46. }
  47. ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc)
  48. {
  49. SetInitialParameter();
  50. ListFlowControll = lfc;
  51. }
  52. bool ClassFlow::ReadParameter(FILE* pfile, string &aktparamgraph)
  53. {
  54. return false;
  55. }
  56. bool ClassFlow::doFlow(string time)
  57. {
  58. return false;
  59. }
  60. string ClassFlow::getHTMLSingleStep(string host){
  61. return "";
  62. }
  63. string ClassFlow::getReadout()
  64. {
  65. return string();
  66. }
  67. bool ClassFlow::getNextLine(FILE* pfile, string *rt)
  68. {
  69. char zw[1024];
  70. if (pfile == NULL)
  71. {
  72. *rt = "";
  73. return false;
  74. }
  75. fgets(zw, 1024, pfile);
  76. printf("%s", zw);
  77. if ((strlen(zw) == 0) && feof(pfile))
  78. {
  79. *rt = "";
  80. return false;
  81. }
  82. *rt = zw;
  83. *rt = trim(*rt);
  84. while (zw[0] == '#' || (rt->size() == 0)) // Kommentarzeilen und Leerzeilen überspringen
  85. {
  86. fgets(zw, 1024, pfile);
  87. printf("%s", zw);
  88. if (feof(pfile))
  89. {
  90. *rt = "";
  91. return false;
  92. }
  93. *rt = zw;
  94. *rt = trim(*rt);
  95. }
  96. return true;
  97. }