Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.7 KiB

  1. #pragma warning( disable:4786 )
  2. #include <compfile.h>
  3. //
  4. // ComplianceFile methods
  5. //
  6. void ComplianceFile::readLines() {
  7. ifstream inputFile(m_szFileName.c_str());
  8. if (!inputFile)
  9. throw InvalidFileName(m_szFileName);
  10. char szTemp[256];
  11. int counter = 0;
  12. while (!inputFile.eof()) {
  13. inputFile.getline(szTemp, sizeof(szTemp));
  14. if (szTemp[0] && szTemp[0] != ';')
  15. m_lines.push_back(szTemp);
  16. }
  17. }
  18. bool ComplianceFile::isSectionName(const string& szLine) const{
  19. if (szLine.length() > 2)
  20. return (szLine[0] == '[' && szLine[szLine.length() - 1] == ']');
  21. else
  22. return false;
  23. }
  24. void ComplianceFile::createSections() {
  25. vector<string>::const_iterator iter = m_lines.begin();
  26. vector<string> sectionLines;
  27. string sectionName;
  28. while (iter != m_lines.end()) {
  29. if ((*iter)[0] == '[') {
  30. if (!isSectionName(*iter))
  31. throw Section::InvalidSectionFormat(*iter);
  32. if (iter != m_lines.begin()) {
  33. Section *pSec = sectionFactory().create(sectionName, sectionLines, *this);
  34. m_sections.push_back(pSec);
  35. if (sectionName == "[type#values]")
  36. m_typesSection = dynamic_cast<ValueSection *>(pSec);
  37. else if (sectionName == "[var#values]")
  38. m_varsSection = dynamic_cast<ValueSection *>(pSec);
  39. else if (sectionName == "[suite#values]")
  40. m_suitesSection = dynamic_cast<ValueSection *>(pSec);
  41. else if (sectionName == "[oldsource#values]")
  42. m_sourcesSection = dynamic_cast<ValueSection *>(pSec);
  43. else if (sectionName == "[error#values]")
  44. m_errorsSection = dynamic_cast<ValueSection *>(pSec);
  45. }
  46. sectionLines.clear();
  47. sectionName = (*iter);
  48. } else {
  49. sectionLines.push_back(*iter);
  50. }
  51. iter++;
  52. }
  53. if ((sectionLines.size() > 0) && isSectionName(sectionName))
  54. m_sections.push_back(sectionFactory().create(sectionName, sectionLines, *this));
  55. //
  56. // copy all the test sections here
  57. //
  58. vector<Section*>::const_iterator sec = m_sections.begin();
  59. while (sec != m_sections.end()) {
  60. if ((*sec)->name().find("[test#") != (*sec)->name().npos)
  61. m_upgSections.push_back(dynamic_cast<TestSection*>(*sec));
  62. sec++;
  63. }
  64. }
  65. void ComplianceFile::executeTestCases(ostream& os) {
  66. vector<TestSection*>::iterator iter = m_upgSections.begin();
  67. while (iter != m_upgSections.end()) {
  68. (*iter)->executeTestCases(os);
  69. iter++;
  70. }
  71. }
  72. vector<Section*>::iterator
  73. ComplianceFile::findSection(vector<Section*> &sections, const string& szName){
  74. vector<Section*>::iterator iter = sections.begin();
  75. while (iter != sections.end()) {
  76. if ((*iter)->name() == szName)
  77. return iter;
  78. iter++;
  79. }
  80. return iter;
  81. }