00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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