00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CMDLINEOPTIONS_H
00029 #define CMDLINEOPTIONS_H
00030
00031 #ifdef _WIN32
00032 #include <windows.h>
00033 #endif
00034
00035 #include <string>
00036 #include <map>
00037 #include <set>
00038 #include <cstdlib>
00039 #include <iostream>
00040 #include <fstream>
00041 #include <vector>
00042
00043 #include "stringtools.h"
00044 #include "enums.h"
00045
00046
00047 #define OPT_ADDCONFDIR "add-config-dir"
00048 #define OPT_ADDDATADIR "add-data-dir"
00049 #define OPT_ANCHORS "anchors"
00050 #define OPT_ANCHOR_FN "anchor-filename"
00051 #define OPT_ANCHOR_PFX "anchor-prefix"
00052 #define OPT_ANSI "ansi"
00053 #define OPT_BABEL "babel"
00054 #define OPT_BASE_FONT "font"
00055 #define OPT_BASE_FONT_SIZE "font-size"
00056 #define OPT_BATCHREC "batch-recursive"
00057 #define OPT_CLASSNAME "class-name"
00058 #define OPT_DATADIR "data-dir"
00059 #define OPT_DELTABS "replace-tabs"
00060 #define OPT_DOC_TITLE "doc-title"
00061 #define OPT_ENCLOSE_PRE "enclose-pre"
00062 #define OPT_ENCODING "encoding"
00063 #define OPT_FILLZEROES "zeroes"
00064 #define OPT_FORCE_OUTPUT "force"
00065 #define OPT_FORMAT "reformat"
00066 #define OPT_FRAGMENT "fragment"
00067 #define OPT_HELP "help"
00068 #define OPT_HTML "html"
00069 #define OPT_IN "input"
00070 #define OPT_INC_STYLE "include-style"
00071 #define OPT_INDEXFILE "print-index"
00072 #define OPT_INLINE_CSS "inline-css"
00073 #define OPT_KW_CASE "kw-case"
00074 #define OPT_LATEX "latex"
00075 #define OPT_LINENO "linenumbers"
00076 #define OPT_LINE_LEN "line-length"
00077 #define OPT_LISTLANGS "list-langs"
00078 #define OPT_LISTTHEMES "list-themes"
00079 #define OPT_LNR_LEN "line-number-length"
00080 #define OPT_LNR_START "line-number-start"
00081 #define OPT_MARK_LINES "mark-line"
00082 #define OPT_ORDERED_LIST "ordered-list"
00083 #define OPT_OUT "output"
00084 #define OPT_OUTDIR "outdir"
00085 #define OPT_RTF_PAGE_SIZE "page-size"
00086 #define OPT_RTF_CHAR_STYLES "char-styles"
00087 #define OPT_PRINT_CONFIG "print-config"
00088 #define OPT_PROGRESSBAR "progress"
00089 #define OPT_QUIET "quiet"
00090 #define OPT_REPLACE_QUOTES "replace-quotes"
00091 #define OPT_RTF "rtf"
00092 #define OPT_STYLE "style"
00093 #define OPT_STYLE_IN "style-infile"
00094 #define OPT_STYLE_OUT "style-outfile"
00095 #define OPT_SYNTAX "syntax"
00096 #define OPT_TEST_INPUT "validate-input"
00097 #define OPT_TEX "tex"
00098 #define OPT_VERBOSE "verbose"
00099 #define OPT_VERSION "version"
00100 #define OPT_WRAP "wrap"
00101 #define OPT_WRAPSIMPLE "wrap-simple"
00102 #define OPT_XHTML "xhtml"
00103 #define OPT_XML "xml"
00104 #define OPT_XTERM256 "xterm256"
00105 #define OPT_SVG "svg"
00106 #define OPT_SVG_WIDTH "width"
00107 #define OPT_SVG_HEIGHT "height"
00108 #define OPT_SKIP_UNKNOWN "skip"
00109 #define OPT_CTAGS_FILE "ctags-file"
00110 #define OPT_PRETTY_SYMBOLS "pretty-symbols"
00111 #define OPT_EOL_DELIM_CR "delim-cr"
00112 #define OPT_BBCODE "bbcode"
00113 #define OPT_START_NESTED "start-nested"
00114 #define OPT_PRINT_STYLE "print-style"
00115 #define OPT_NO_TRAILING_NL "no-trailing-nl"
00116
00117
00118 #define OPT_COMPAT_DOC "doc"
00119 #define OPT_COMPAT_NODOC "no-doc"
00120 #define OPT_COMPAT_TAB "tab"
00121 #define OPT_COMPAT_CSS "css"
00122 #define OPT_COMPAT_OUTDIR "output-dir"
00123 #define OPT_COMPAT_FAILSAFE "failsafe"
00124 #define OPT_COMPAT_OUTFORMAT "out-format"
00125 #define OPT_COMPAT_SRCLANG "src-lang"
00126 #define OPT_COMPAT_LINENUM "line-number"
00127 #define OPT_COMPAT_LINEREF "line-number-ref"
00128
00129 using namespace std;
00130
00132
00133 class CmdLineOptions
00134 {
00135 public:
00136
00141 CmdLineOptions ( const int argc, const char *argv[] );
00142 ~CmdLineOptions();
00143
00145 const string &getSingleOutFilename();
00146
00148 const string &getSingleInFilename() const;
00149
00151 const string& getOutDirectory() ;
00152
00154 const string getStyleOutFilename() const;
00155
00157 const string& getStyleInFilename() const;
00158
00160 const string& getEncoding() const;
00161
00163 const string& getSVGWidth() const;
00164
00166 const string& getSVGHeight() const;
00167
00169 int getNumberSpaces() const;
00170
00172 bool printVersion() const;
00173
00175 bool printHelp() const;
00176
00178 bool printDebugInfo() const;
00179
00181 bool printConfigInfo() const;
00182
00184 bool includeStyleDef() const;
00185
00187 bool printLineNumbers() const;
00188
00190 bool useCRDelimiter() const;
00191
00193 string getThemeName() const ;
00194
00196 int helpLanguage() const;
00197
00199 bool enableBatchMode() const;
00200
00202 bool fragmentOutput() const;
00203
00205 string getOutFileSuffix() const;
00206
00208 bool attachLineAnchors() const;
00209
00211 bool showThemes() const;
00212
00214 bool showLangdefs() const;
00215
00217 bool outDirGiven() const;
00218
00220
00221
00223 bool dataDirGiven() const;
00224
00226 bool additionalDataDirGiven() const;
00227
00229 bool printIndexFile() const;
00230
00232 bool replaceQuotes() const;
00233
00235 bool disableBabelShorthands() const;
00236
00238 bool useFNamesAsAnchors() const;
00239
00241 const string &getDataDir() const;
00242
00244 const string &getAdditionalDataDir() const;
00245
00247 const string &getAdditionalConfDir() const;
00248
00250 const string &getConfigFilePath() const;
00251
00253 bool syntaxGiven() const;
00254
00256 bool quietMode() const;
00257
00259 bool printProgress() const;
00260
00262 bool fillLineNrZeroes() const;
00263
00265 const string &getLanguage() const ;
00266
00268 highlight::WrapMode getWrappingStyle() const;
00269
00271 const vector <string> & getInputFileNames() const;
00272
00274 const map <int,string> &getMarkLines();
00275
00277 string getIndentScheme() const;
00278
00280 const string &getPageSize() const;
00281
00283 highlight::OutputType getOutputType() const;
00284
00286 bool formatSupportsExtStyle();
00287
00289 bool styleOutPathDefined() const
00290 {
00291 return opt_stylepath_explicit;
00292 }
00293
00295 bool omitEncoding() const;
00296
00298 bool forceOutput() const;
00299
00301 bool orderedList() const;
00302
00304 bool hasBaseFont() const ;
00305
00307 bool validateInput() const ;
00308
00310 bool inlineCSS() const ;
00311
00313 bool enclosePreTag() const ;
00314
00316 bool includeCharStyles() const ;
00317
00319 bool prettySymbols() const;
00320
00322 bool printOnlyStyle() const;
00323
00325 const string& getBaseFont() const ;
00326
00328 const string& getDocumentTitle() const ;
00329
00331 const string& getAnchorPrefix() const ;
00332
00334 const string& getClassName() const ;
00335
00337 const string& getTagsFile() const ;
00338
00340 bool hasBaseFontSize() const ;
00341
00343 bool disableTrailingNL() const ;
00344
00346 const string& getBaseFontSize() const ;
00347
00349 const string& getStartNestedLang() const ;
00350
00352 int getNumberWidth();
00353
00355 int getLineLength();
00356
00358 int getNumberStart();
00359
00361 StringTools::KeywordCase getKeywordCase() const;
00362
00363 bool isSkippedExt ( const string& ext )
00364 {
00365 return ignoredFileTypes.count ( ext );
00366 }
00367
00368 private:
00369
00370 int numberSpaces;
00371 int lineNrWidth;
00372 int lineLength;
00373 int lineNrStart;
00374 highlight::WrapMode wrappingStyle;
00375 highlight::OutputType outputType;
00376 StringTools::KeywordCase keywordCase;
00377
00378
00379 string outFilename,
00380
00381 outDirectory,
00382
00383 syntax,
00384
00385 styleName,
00386
00387 styleOutFilename,
00388
00389 styleInFilename,
00390
00391 dataDir, additionalDataDir, additionalConfigDir;
00392
00393 string indentScheme,
00394 pageSize, startNestedLang;
00395
00396 string baseFont, baseFontSize;
00397 string docTitle, className;
00398 string markLinesArg;
00399 string skipArg;
00400 string svg_height, svg_width;
00401 string ctagsFile;
00402
00403 bool opt_syntax;
00404 bool opt_include_style;
00405 bool opt_help;
00406 bool opt_version ;
00407 bool opt_verbose;
00408 bool opt_print_config;
00409 bool opt_linenumbers;
00410 bool opt_style;
00411 bool opt_batch_mode;
00412 bool opt_fragment;
00413 bool opt_attach_line_anchors;
00414 bool opt_show_themes;
00415 bool opt_show_langdefs;
00416 bool opt_asformat_output;
00417 bool opt_printindex;
00418 bool opt_quiet;
00419 bool opt_replacequotes;
00420 bool opt_babel;
00421 bool opt_print_progress;
00422 bool opt_fill_zeroes;
00423 bool opt_stylepath_explicit;
00424 bool opt_force_output;
00425 bool opt_ordered_list;
00426 bool opt_fnames_as_anchors;
00427 bool opt_validate;
00428 bool opt_inline_css;
00429 bool opt_enclose_pre;
00430 bool opt_char_styles;
00431 bool opt_pretty_symbols;
00432 bool opt_delim_CR;
00433 bool opt_print_style;
00434 bool opt_no_trailing_nl;
00435
00436 bool configFileRead;
00437
00438 string anchorPrefix;
00439
00440 string helpLang, encodingName;
00441 string configFilePath;
00442
00444 vector <string> inputFileNames;
00445
00447 map <int, string> markLines;
00448
00450 set <string> ignoredFileTypes;
00451
00453 void loadConfigurationFile();
00454
00456 string getFileSuffix ( const string & fileName ) const;
00457
00459 string getDirName ( const string & path );
00460
00462 void readDirectory ( const string & wildcard );
00463
00465 bool getFlag ( const string& paramVal );
00466
00468 string validateDirPath ( const string & path );
00469 };
00470
00471 #endif