Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmDocumentationFormatter.cxx
blobb02be7950b14cf04a8089e402a9cf25d7df97c3e
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDocumentationFormatter.cxx,v $
5 Language: C++
6 Date: $Date: 2007/09/19 13:05:28 $
7 Version: $Revision: 1.1 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmDocumentationFormatter.h"
19 cmDocumentationFormatter::cmDocumentationFormatter()
23 cmDocumentationFormatter::~cmDocumentationFormatter()
27 void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
28 const char* text)
30 if(!text)
32 return;
34 const char* ptr = text;
35 while(*ptr)
37 // Any ptrs starting in a space are treated as preformatted text.
38 std::string preformatted;
39 while(*ptr == ' ')
41 for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
43 preformatted.append(1, ch);
45 if(*ptr)
47 ++ptr;
48 preformatted.append(1, '\n');
51 if(preformatted.length())
53 this->PrintPreformatted(os, preformatted.c_str());
56 // Other ptrs are treated as paragraphs.
57 std::string paragraph;
58 for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
60 paragraph.append(1, ch);
62 if(*ptr)
64 ++ptr;
65 paragraph.append(1, '\n');
67 if(paragraph.length())
69 this->PrintParagraph(os, paragraph.c_str());