ClassFlow.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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::getReadout()
  60. {
  61. return string();
  62. }
  63. bool ClassFlow::getNextLine(FILE* pfile, string *rt)
  64. {
  65. char zw[1024];
  66. if (pfile == NULL)
  67. {
  68. *rt = "";
  69. return false;
  70. }
  71. fgets(zw, 1024, pfile);
  72. printf("%s", zw);
  73. if ((strlen(zw) == 0) && feof(pfile))
  74. {
  75. *rt = "";
  76. return false;
  77. }
  78. *rt = zw;
  79. *rt = trim(*rt);
  80. while (zw[0] == '#' || (rt->size() == 0)) // Kommentarzeilen und Leerzeilen überspringen
  81. {
  82. fgets(zw, 1024, pfile);
  83. printf("%s", zw);
  84. if (feof(pfile))
  85. {
  86. *rt = "";
  87. return false;
  88. }
  89. *rt = zw;
  90. *rt = trim(*rt);
  91. }
  92. return true;
  93. }