ESLA
Embeddable Scriting LAnguage
Stanford University, Rock Fracture Project research group
© 2003
00001 /************************************************************************* 00002 * ESLA: Embeddable Scripting LAnguage 00003 * Copyright (C) 2003 Frantz Maerten 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License as 00007 * published by the Free Software Foundation; either version 2 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * If you modify this software, you should contact the author, include 00011 * a notice giving the name of the person performing the modification, 00012 * the date of modification, and the reason for such modification. 00013 * 00014 * Note that the GNU General Public License does not permit 00015 * incorporating the Software into proprietary programs. 00016 * 00017 * Contact: Frantz Maerten 00018 * frantz@pangea.stanford.edu 00019 * 00020 * Dept. of Geological & Environmental Sciences 00021 * Stanford University 00022 * Stanford, CA 94305-2115 00023 * USA 00024 *************************************************************************/ 00025 00026 00027 #ifndef HELP_DISPLAY_H__ 00028 #define HELP_DISPLAY_H__ 00029 00030 #include "../esla_namespace.h" 00031 #include <iostream> 00032 #include <string> 00033 #include <vector> 00034 00035 00036 BEGIN_LIB_NAMESPACE 00037 00050 class HelpDisplay { 00051 struct Section { 00052 std::string name ; 00053 std::vector<std::string> texts ; 00054 std::vector<int> offsets ; 00055 int space ; 00056 } ; 00057 public: 00058 HelpDisplay(const std::string& prog_name) ; 00059 void preformat(int size) ; 00060 00061 void begin_description() ; 00062 void new_section(const std::string& section_name, int space = 6) ; 00063 bool add_section_text(const std::string& section_name, const std::string& text, int offset = 0) ; 00064 void end_description() ; 00065 00066 void display(std::ostream&) ; 00067 00068 private: 00069 typedef std::vector<Section> ListSections ; 00070 typedef ListSections::iterator iterator ; 00071 ListSections sections_ ; 00072 int line_size_ ; 00073 std::string prog_name_ ; 00074 00075 void display(std::ostream&, const Section&) ; 00076 void display(std::ostream&, const std::string&, int) ; 00077 } ; 00078 00079 END_LIB_NAMESPACE 00080 00081 #endif