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.

73 lines
1.8 KiB

  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmDocumentationFormatter.h"
  14. cmDocumentationFormatter::cmDocumentationFormatter()
  15. {
  16. }
  17. cmDocumentationFormatter::~cmDocumentationFormatter()
  18. {
  19. }
  20. void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
  21. const char* text)
  22. {
  23. if(!text)
  24. {
  25. return;
  26. }
  27. const char* ptr = text;
  28. while(*ptr)
  29. {
  30. // Any ptrs starting in a space are treated as preformatted text.
  31. std::string preformatted;
  32. while(*ptr == ' ')
  33. {
  34. for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
  35. {
  36. preformatted.append(1, ch);
  37. }
  38. if(*ptr)
  39. {
  40. ++ptr;
  41. preformatted.append(1, '\n');
  42. }
  43. }
  44. if(preformatted.length())
  45. {
  46. this->PrintPreformatted(os, preformatted.c_str());
  47. }
  48. // Other ptrs are treated as paragraphs.
  49. std::string paragraph;
  50. for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
  51. {
  52. paragraph.append(1, ch);
  53. }
  54. if(*ptr)
  55. {
  56. ++ptr;
  57. paragraph.append(1, '\n');
  58. }
  59. if(paragraph.length())
  60. {
  61. this->PrintParagraph(os, paragraph.c_str());
  62. }
  63. }
  64. }