ReportDocument.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //-----------------------------------------------------------------------------
  2. // ReportDocument.h
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. #pragma once
  8. namespace XnaGraphicsProfileChecker
  9. {
  10. using namespace System;
  11. using namespace System::Collections::Generic;
  12. // Formats profile checker results as an HTML or text report.
  13. ref class ReportDocument
  14. {
  15. public:
  16. ReportDocument();
  17. String^ ToText() { return ToText(report); }
  18. String^ ToHtml() { return ToHtml(report); }
  19. private:
  20. // Each line of the report is stored as a tuple, where the first item
  21. // is an HTML formatting element (p, h1, etc), and the second is either
  22. // a text string or a nested ElementList (for recursive elements).
  23. typedef Tuple<String^, Object^> Element;
  24. // Helper method provides a nicer Add syntax.
  25. ref class ElementList : List<Element^>
  26. {
  27. public:
  28. void Add(String^ element, Object^ contents)
  29. {
  30. Add(gcnew Element(element, contents));
  31. }
  32. };
  33. // The entire report is stored as a list of elements.
  34. ElementList^ report;
  35. // Recursive formatting helper methods.
  36. static String^ ToText(ElementList^ elements);
  37. static String^ ToHtml(ElementList^ elements);
  38. };
  39. }