preformatter.h

00001 /***************************************************************************
00002                         PreFormatter.cpp  -  description
00003                              -------------------
00004     begin                : Mo Jan 03 2005
00005     copyright            : (C) 2005 by André Simon
00006     email                : andre.simon1@gmx.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef PreFormatter_H
00019 #define PreFormatter_H
00020 
00021 #define LB_CHARS " \t[](){}-+<>.:,;"
00022 #define WS_CHARS " \n\r\t"
00023 #define INDENT_MARKERS "{(="
00024 
00025 #include <string>
00026 #include <iostream>
00027 
00028 #include "stringtools.h"
00029 
00030 namespace highlight {
00031 
00036 class PreFormatter{
00037 public:
00040     PreFormatter(bool wrap, bool replTabs);
00041 
00042     PreFormatter();
00043 
00044     ~PreFormatter();
00045 
00049     bool hasMoreLines();
00050 
00055     void setLine(const std::string  newline);
00056 
00061     std::string  getNextLine();
00062 
00066     bool indentCode();
00067 
00072     void setWrappingProperties(unsigned int maxlength=80, bool indentAfterOpenBraces=true);
00073 
00078     void setNumberSpaces(unsigned int num);
00079 
00083     bool isEnabled(){
00084       return wrapLines || replaceTabs;
00085     }
00086 
00087 private:
00088 
00089     unsigned int maxLineLength;
00090 
00091     std::string line, wsPrefix;
00092     unsigned int index;
00093     unsigned int numberSpaces;
00094     size_t wsPrefixLength;
00095     bool hasMore, indentAfterOpenBraces;
00096     bool redefineWsPrefix;
00097     bool wrapLines, replaceTabs;
00098 };
00099 
00100 }
00101 
00102 #endif

Generated on Fri Apr 27 13:12:36 2007 for Highlight Code Converter by  doxygen 1.5.2