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.

164 lines
3.5 KiB

  1. // comptest.cpp : Defines the entry point for the console application.
  2. //
  3. #pragma warning( disable:4786 )
  4. #include <iostream>
  5. #include <compfile.h>
  6. using namespace std;
  7. //
  8. // main() entry point
  9. //
  10. int
  11. __cdecl
  12. main(
  13. int argc,
  14. char* argv[]
  15. )
  16. {
  17. if(argc > 1){
  18. try{
  19. ComplianceFile inputFile(argv[1]);
  20. if (argc > 2) {
  21. ofstream outFile(argv[2]);
  22. if (!outFile.good())
  23. throw ComplianceFile::InvalidFileName(argv[2]);
  24. inputFile.executeTestCases(outFile);
  25. }
  26. else
  27. inputFile.executeTestCases(cerr);
  28. }
  29. catch(ComplianceFile::InvalidFileFormat iff) {
  30. cerr << iff;
  31. }
  32. catch(ComplianceFile::InvalidFileName ifn) {
  33. cerr << ifn;
  34. }
  35. catch(ComplianceFile::MissingSection ms) {
  36. cerr << ms;
  37. }
  38. catch(Section::InvalidSectionFormat isf) {
  39. cerr << isf;
  40. }
  41. catch(Section::InvalidSectionName isn) {
  42. cerr << isn;
  43. }
  44. catch(ValueSection::ValueNotFound vnf) {
  45. cerr << vnf;
  46. }
  47. catch(TestCase::InvalidFormat itf) {
  48. cerr << itf;
  49. }
  50. catch(...){
  51. cerr << "Unknown Exception caught... :(" << endl;
  52. }
  53. }
  54. else{
  55. cerr << "illegal usage :(" << endl;
  56. }
  57. return 0;
  58. }
  59. /*
  60. namespace Compliance {
  61. //
  62. // static data initialization
  63. //
  64. const string UpgradeTestCase::m_szDelimiters = ":#";
  65. //
  66. // utility function to tokenize a given line based on the delimiters
  67. // specified
  68. //
  69. template< class T >
  70. unsigned Tokenize(const T &szInput, const T & szDelimiters, vector<T>& tokens) {
  71. unsigned uDelimiterCount = 0;
  72. tokens.clear();
  73. if(!szInput.empty()){
  74. if(!szDelimiters.empty()){
  75. T::const_iterator inputIter = szInput.begin();
  76. T::const_iterator copyIter = szInput.begin();
  77. while(inputIter != szInput.end()){
  78. if(szDelimiters.find(*inputIter) != string::npos){
  79. if (copyIter < inputIter) {
  80. tokens.push_back(szInput.substr(copyIter - szInput.begin(),
  81. inputIter - copyIter));
  82. }
  83. uDelimiterCount++;
  84. inputIter++;
  85. copyIter = inputIter;
  86. continue;
  87. }
  88. inputIter++;
  89. }
  90. if(copyIter != inputIter){
  91. tokens.push_back(szInput.substr(copyIter - szInput.begin(),
  92. inputIter - szInput.begin()));
  93. }
  94. }
  95. else
  96. tokens.push_back(szInput);
  97. }
  98. return uDelimiterCount;
  99. }
  100. //
  101. // debug output for section
  102. //
  103. ostream& operator<<(ostream &os, const Section &section){
  104. os << "Section Name: " << section.name() << endl;
  105. os << "Number of child sections : " << section.childSections().size() << endl;
  106. os << "Section content : " << endl;
  107. vector<string>::const_iterator liter = section.lines().begin();
  108. while (liter != section.lines().end())
  109. os << *liter++ << endl;
  110. // dump all the child sections
  111. vector<Section>::const_iterator iter = section.childSections().begin();
  112. while (iter != section.childSections().end()) {
  113. os << (const Section &)(*iter) << endl;
  114. iter++;
  115. }
  116. return os;
  117. }
  118. //
  119. // debug output for compliance file
  120. //
  121. ostream& operator<<(ostream& os, const ComplianceFile &cf){
  122. os << "------------------------------------------------------------" << endl;
  123. os << "Compliance File State - Dump" << endl;
  124. os << "Name : " << cf.name() << endl;
  125. os << "Num Lines : " << cf.lines().size() << endl;
  126. os << "Section Dump : " << endl;
  127. if (cf.topLevelSection())
  128. os << *(cf.topLevelSection()) << endl;
  129. os << "------------------------------------------------------------" << endl;
  130. return os;
  131. }
  132. }
  133. */